Search in sources :

Example 21 with Deployment

use of io.fabric8.kubernetes.api.model.apps.Deployment in project kubernetes by ballerinax.

the class DeploymentHandler method generate.

/**
 * Generate kubernetes deployment definition from annotation.
 *
 * @return Generated kubernetes @{@link Deployment} definition
 * @throws KubernetesPluginException If an error occurs while generating artifact.
 */
public String generate() throws KubernetesPluginException {
    List<ContainerPort> containerPorts = null;
    if (deploymentModel.getPorts() != null) {
        containerPorts = populatePorts(deploymentModel.getPorts());
    }
    Container container = generateContainer(deploymentModel, containerPorts);
    Deployment deployment = new DeploymentBuilder().withNewMetadata().withName(deploymentModel.getName()).withNamespace(deploymentModel.getNamespace()).withLabels(deploymentModel.getLabels()).endMetadata().withNewSpec().withReplicas(deploymentModel.getReplicas()).withNewTemplate().withNewMetadata().addToLabels(deploymentModel.getLabels()).endMetadata().withNewSpec().withContainers(container).withVolumes(populateVolume(deploymentModel)).endSpec().endTemplate().endSpec().build();
    try {
        return SerializationUtils.dumpWithoutRuntimeStateAsYaml(deployment);
    } catch (JsonProcessingException e) {
        String errorMessage = "Error while parsing yaml file for deployment: " + deploymentModel.getName();
        throw new KubernetesPluginException(errorMessage, e);
    }
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) Deployment(io.fabric8.kubernetes.api.model.extensions.Deployment) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DeploymentBuilder(io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder)

Example 22 with Deployment

use of io.fabric8.kubernetes.api.model.apps.Deployment in project fabric8 by jboss-fuse.

the class PatchBundlesIntegrationTest method createdeployment.

@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
    archive.addClass(ServiceLocator.class);
    archive.addClass(IOHelpers.class);
    archive.addPackage(ServiceTracker.class.getPackage());
    archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
    archive.setManifest(new Asset() {

        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleManifestVersion(2);
            builder.addImportPackages(Bundle.class, Service.class, PatchManagement.class, Validatable.class);
            return builder.openStream();
        }
    });
    // add the original bundle as well as the patch zip files as resources
    archive.add(createPatchableBundle("1.0.0"), "/bundles", ZipExporter.class);
    archive.add(createPatchZipFile("patch-01"), "/patches", ZipExporter.class);
    archive.add(createPatchZipFile("patch-02"), "/patches", ZipExporter.class);
    archive.add(createPatchZipFile("patch-02-without-range"), "/patches", ZipExporter.class);
    return archive;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) InputStream(java.io.InputStream) Bundle(org.osgi.framework.Bundle) PatchManagement(io.fabric8.patch.management.PatchManagement) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) Service(io.fabric8.patch.Service) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Validatable(io.fabric8.api.scr.Validatable) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 23 with Deployment

use of io.fabric8.kubernetes.api.model.apps.Deployment in project fabric8 by jboss-fuse.

the class PatchFilesIntegrationTest method createdeployment.

@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
    archive.addClass(ServiceLocator.class);
    archive.addClass(IOHelpers.class);
    archive.addPackage(ServiceTracker.class.getPackage());
    archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
    archive.setManifest(new Asset() {

        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleManifestVersion(2);
            builder.addImportPackages(Bundle.class, Service.class, PatchManagement.class, Validatable.class);
            return builder.openStream();
        }
    });
    // add the patch zip files as resources
    archive.add(createPatchZipFile("file-01"), "/patches", ZipExporter.class);
    archive.add(createPatchZipFile("file-02"), "/patches", ZipExporter.class);
    return archive;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Bundle(org.osgi.framework.Bundle) PatchManagement(io.fabric8.patch.management.PatchManagement) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) Service(io.fabric8.patch.Service) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Validatable(io.fabric8.api.scr.Validatable) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 24 with Deployment

use of io.fabric8.kubernetes.api.model.apps.Deployment in project fabric8 by jboss-fuse.

the class PatchMigratorTest method createdeployment.

@Deployment
public static JavaArchive createdeployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
    archive.setManifest(new Asset() {

        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleManifestVersion(2);
            builder.addImportPackages(Bundle.class, Service.class, PatchManagement.class, Validatable.class);
            return builder.openStream();
        }
    });
    archive.addClass(ServiceLocator.class);
    archive.addClass(IOHelpers.class);
    archive.addPackage(ServiceTracker.class.getPackage());
    archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
    // add the original bundle as well as the patch zip files as resources
    archive.add(createPatchZipFile("migrator-patch-01"), "/patches", ZipExporter.class);
    return archive;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) InputStream(java.io.InputStream) Bundle(org.osgi.framework.Bundle) PatchManagement(io.fabric8.patch.management.PatchManagement) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) Service(io.fabric8.patch.Service) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Validatable(io.fabric8.api.scr.Validatable) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 25 with Deployment

use of io.fabric8.kubernetes.api.model.apps.Deployment in project fabric8 by jboss-fuse.

the class PatchThePatchServiceTest method createdeployment.

@Deployment
public static JavaArchive createdeployment() throws Exception {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
    archive.addClass(ServiceLocator.class);
    archive.addClass(IOHelpers.class);
    archive.addPackage(ServiceTracker.class.getPackage());
    archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
    archive.addPackage(CommandSupport.class.getPackage());
    archive.addClass(VersionCleaner.class);
    archive.setManifest(new Asset() {

        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleManifestVersion(2);
            builder.addImportPackages(Bundle.class, Logger.class);
            builder.addImportPackages(AbstractCommand.class, Action.class, Function.class, Validatable.class);
            builder.addImportPackages(InvalidComponentException.class);
            builder.addImportPackage("org.apache.felix.service.command;status=provisional");
            return builder.openStream();
        }
    });
    // add the patch zip files as resource
    archive.add(createPatchZipFile(PATCH_ID), "/patches", ZipExporter.class);
    return archive;
}
Also used : Action(org.apache.felix.gogo.commands.Action) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Bundle(org.osgi.framework.Bundle) AbstractCommand(org.apache.felix.gogo.commands.basic.AbstractCommand) Logger(org.slf4j.Logger) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Validatable(io.fabric8.api.scr.Validatable) Function(org.apache.felix.service.command.Function) InvalidComponentException(io.fabric8.api.InvalidComponentException) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) CommandSupport(io.fabric8.itests.support.CommandSupport) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

File (java.io.File)62 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)52 Test (org.testng.annotations.Test)50 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)47 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)43 Container (io.fabric8.kubernetes.api.model.Container)32 Service (io.fabric8.kubernetes.api.model.Service)28 Test (org.junit.Test)28 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)27 InputStream (java.io.InputStream)26 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)25 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)25 Deployment (org.jboss.arquillian.container.test.api.Deployment)21 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)21 Asset (org.jboss.shrinkwrap.api.asset.Asset)21 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)21 IOException (java.io.IOException)20 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 FileInputStream (java.io.FileInputStream)19 CommandSupport (io.fabric8.itests.support.CommandSupport)18