Search in sources :

Example 51 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.

the class ServiceAccountEnricherTest method testServiceAccountCreationFromFragment.

@Test
public void testServiceAccountCreationFromFragment() {
    final KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("cheese").endMetadata().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withImage("cheese-image").endContainer().withServiceAccount("ribbon").endSpec().endTemplate().endSpec().build());
    enrichAndAssert(builder);
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 52 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.

the class ContainerEnvJavaOptionsMergeTest method setUp.

@Before
public void setUp() {
    containerEnvJavaOptionsMergeEnricher = new ContainerEnvJavaOptionsMergeEnricher(context);
    kubernetesListBuilder = new KubernetesListBuilder();
    properties = new Properties();
    // @formatter:off
    kubernetesListBuilder.addToItems(new DeploymentBuilder().withNewSpec().withNewTemplate().withNewSpec().addToContainers(new ContainerBuilder().withImage("the-image:latest").addToEnv(new EnvVar("JAVA_OPTIONS", "val-from-container", null)).build()).endSpec().endTemplate().endSpec().build());
    new Expectations() {

        {
            context.getConfiguration();
            result = Configuration.builder().image(imageConfiguration).build();
            context.getProperties();
            result = properties;
        }
    };
// @formatter:on
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Expectations(mockit.Expectations) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Properties(java.util.Properties) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Before(org.junit.Before)

Example 53 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.

the class DebugEnricherTest method setUp.

@Before
public void setUp() {
    properties = new Properties();
    processorConfig = new ProcessorConfig();
    klb = new KubernetesListBuilder();
    // @formatter:off
    klb.addToItems(new DeploymentBuilder().editOrNewSpec().editOrNewTemplate().editOrNewMetadata().withName("template-name").endMetadata().editOrNewSpec().addNewContainer().withImage("container/image").endContainer().endSpec().endTemplate().endSpec().build());
    new Expectations() {

        {
            context.getProperties();
            result = properties;
            context.getConfiguration().getProcessorConfig();
            result = processorConfig;
        }
    };
// @formatter:on
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Expectations(mockit.Expectations) Properties(java.util.Properties) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 54 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.

the class DefaultMetadataEnricherTest method setUp.

@Before
public void setUp() throws Exception {
    Configuration configuration = Configuration.builder().resource(ResourceConfig.builder().annotations(MetaDataConfig.builder().all(properties("all-annotation", 1)).deployment(properties("deployment", "Deployment")).ingress(properties("ingress", "Ingress")).serviceAccount(properties("service-account", "ServiceAccount")).build()).labels(MetaDataConfig.builder().all(properties("all-label", 10L)).deployment(properties("deployment-label", "Deployment")).ingress(properties("ingress-label", "Ingress")).serviceAccount(properties("service-account-label", "ServiceAccount")).build()).build()).build();
    // @formatter:off
    new Expectations() {

        {
            buildContext.getConfiguration();
            result = configuration;
        }
    };
    // @formatter:on
    defaultMetadataEnricher = new DefaultMetadataEnricher(buildContext);
    configMap = new ConfigMapBuilder().withNewMetadata().endMetadata();
    deployment = new DeploymentBuilder();
    genericResource = new GenericKubernetesResourceBuilder().withNewMetadata().endMetadata();
    ingressV1 = new io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder();
    ingressV1beta1 = new io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder();
    serviceAccount = new ServiceAccountBuilder();
    klb = new KubernetesListBuilder().addToItems(configMap).addToItems(deployment).addToItems(genericResource).addToItems(ingressV1).addToItems(ingressV1beta1).addToItems(serviceAccount);
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) ServiceAccountBuilder(io.fabric8.kubernetes.api.model.ServiceAccountBuilder) GenericKubernetesResourceBuilder(io.fabric8.kubernetes.api.model.GenericKubernetesResourceBuilder) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) DeploymentBuilder(io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder) Before(org.junit.Before)

Example 55 with DeploymentBuilder

use of io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder in project jkube by eclipse.

the class DefaultNamespaceEnricherTest method enrichWithPropertiesInKubernetesShouldAddNamespaceWithStatus.

@Test
public void enrichWithPropertiesInKubernetesShouldAddNamespaceWithStatus() {
    // Given
    setNamespaceInResourceConfig("example");
    final KubernetesListBuilder klb = new KubernetesListBuilder();
    Namespace namespace = new NamespaceBuilder().editOrNewMetadata().withName("name").withNamespace("to-be-overwritten").endMetadata().editOrNewStatus().withPhase("active").endStatus().build();
    Deployment deployment = new DeploymentBuilder().withNewMetadata().withName("d1").endMetadata().build();
    klb.addToItems(namespace, deployment);
    // When
    new DefaultNamespaceEnricher(context).enrich(PlatformMode.kubernetes, klb);
    // Then
    assertThat(klb.build().getItems()).hasSize(2);
    assertThat(klb.build().getItems().get(1)).hasFieldOrPropertyWithValue("metadata.namespace", "example");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) Namespace(io.fabric8.kubernetes.api.model.Namespace) NamespaceBuilder(io.fabric8.kubernetes.api.model.NamespaceBuilder) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Aggregations

DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)153 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)80 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)60 Test (org.junit.Test)60 Test (org.junit.jupiter.api.Test)32 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)26 Expectations (mockit.Expectations)26 Test (org.testng.annotations.Test)22 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)17 ArrayList (java.util.ArrayList)17 Container (io.fabric8.kubernetes.api.model.Container)16 HashMap (java.util.HashMap)16 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)15 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)15 DeploymentBuilder (io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder)14 Properties (java.util.Properties)14 Pod (io.fabric8.kubernetes.api.model.Pod)13 PodTemplateSpecBuilder (io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder)13 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)12 InternalRecipe (org.eclipse.che.api.workspace.server.spi.environment.InternalRecipe)12