Search in sources :

Example 11 with PodTemplate

use of io.fabric8.kubernetes.api.model.PodTemplate in project keycloak by keycloak.

the class PodTemplateTest method testEmpty.

@Test
public void testEmpty() {
    // Arrange
    PodTemplateSpec additionalPodTemplate = null;
    // Act
    var podTemplate = getDeployment(additionalPodTemplate).getSpec().getTemplate();
    // Assert
    assertEquals("keycloak", podTemplate.getSpec().getContainers().get(0).getName());
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 12 with PodTemplate

use of io.fabric8.kubernetes.api.model.PodTemplate in project keycloak by keycloak.

the class PodTemplateTest method getDeployment.

Deployment getDeployment(PodTemplateSpec podTemplate) {
    var config = new Config() {

        @Override
        public Keycloak keycloak() {
            return new Keycloak() {

                @Override
                public String image() {
                    return "dummy-image";
                }

                @Override
                public String imagePullPolicy() {
                    return "Never";
                }

                @Override
                public String initContainerImage() {
                    return "quay.io/keycloak/keycloak-init-container:legacy";
                }

                @Override
                public String initContainerImagePullPolicy() {
                    return "Always";
                }
            };
        }
    };
    var kc = new Keycloak();
    var spec = new KeycloakSpec();
    spec.setUnsupported(new Unsupported(podTemplate));
    kc.setSpec(spec);
    var deployment = new KeycloakDeployment(null, config, kc, new Deployment());
    return (Deployment) deployment.getReconciledResource().get();
}
Also used : KeycloakDeployment(org.keycloak.operator.v2alpha1.KeycloakDeployment) KeycloakDeployment(org.keycloak.operator.v2alpha1.KeycloakDeployment) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) Unsupported(org.keycloak.operator.v2alpha1.crds.keycloakspec.Unsupported) KeycloakSpec(org.keycloak.operator.v2alpha1.crds.KeycloakSpec) Keycloak(org.keycloak.operator.v2alpha1.crds.Keycloak)

Example 13 with PodTemplate

use of io.fabric8.kubernetes.api.model.PodTemplate in project keycloak by keycloak.

the class PodTemplateTest method testVolumeMountsAreMerged.

@Test
public void testVolumeMountsAreMerged() {
    // Arrange
    var volumeMountName = "foo";
    var volumeMountPath = "/mnt/path";
    var additionalPodTemplate = new PodTemplateSpecBuilder().withNewSpec().addNewContainer().addNewVolumeMount().withName(volumeMountName).withMountPath(volumeMountPath).endVolumeMount().endContainer().endSpec().build();
    // Act
    var podTemplate = getDeployment(additionalPodTemplate).getSpec().getTemplate();
    // Assert
    assertEquals(volumeMountName, podTemplate.getSpec().getContainers().get(0).getVolumeMounts().get(0).getName());
    assertEquals(volumeMountPath, podTemplate.getSpec().getContainers().get(0).getVolumeMounts().get(0).getMountPath());
}
Also used : PodTemplateSpecBuilder(io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 14 with PodTemplate

use of io.fabric8.kubernetes.api.model.PodTemplate in project keycloak by keycloak.

the class PodTemplateTest method testMetadataIsMerged.

@Test
public void testMetadataIsMerged() {
    // Arrange
    var additionalPodTemplate = new PodTemplateSpecBuilder().withNewMetadata().addToLabels("one", "1").addToAnnotations("two", "2").endMetadata().build();
    // Act
    var podTemplate = getDeployment(additionalPodTemplate).getSpec().getTemplate();
    // Assert
    assertTrue(podTemplate.getMetadata().getLabels().containsKey("one"));
    assertTrue(podTemplate.getMetadata().getLabels().containsValue("1"));
    assertTrue(podTemplate.getMetadata().getAnnotations().containsKey("two"));
    assertTrue(podTemplate.getMetadata().getAnnotations().containsValue("2"));
}
Also used : PodTemplateSpecBuilder(io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 15 with PodTemplate

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

the class Example method listReplicationControllers.

protected static void listReplicationControllers(KubernetesClient kube) {
    System.out.println("\n\nLooking up replicationControllers");
    System.out.println("=========================================================================");
    ReplicationControllerList replicationControllers = kube.replicationControllers().list();
    List<ReplicationController> items = replicationControllers.getItems();
    for (ReplicationController item : items) {
        ReplicationControllerSpec replicationControllerSpec = item.getSpec();
        if (replicationControllerSpec != null) {
            System.out.println("ReplicationController " + KubernetesHelper.getName(item) + " labels: " + item.getMetadata().getLabels() + " replicas: " + replicationControllerSpec.getReplicas() + " replicatorSelector: " + replicationControllerSpec.getSelector() + " podTemplate: " + replicationControllerSpec.getTemplate());
        } else {
            System.out.println("ReplicationController " + KubernetesHelper.getName(item) + " labels: " + item.getMetadata().getLabels() + " no replicationControllerSpec");
        }
    }
    System.out.println();
}
Also used : ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) ReplicationControllerList(io.fabric8.kubernetes.api.model.ReplicationControllerList) ReplicationControllerSpec(io.fabric8.kubernetes.api.model.ReplicationControllerSpec)

Aggregations

QuarkusTest (io.quarkus.test.junit.QuarkusTest)6 Test (org.junit.jupiter.api.Test)6 PodTemplateSpecBuilder (io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder)5 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)3 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)2 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)2 ReplicationControllerList (io.fabric8.kubernetes.api.model.ReplicationControllerList)2 ReplicationControllerSpec (io.fabric8.kubernetes.api.model.ReplicationControllerSpec)2 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)2 ProcessorConfig (io.fabric8.maven.core.config.ProcessorConfig)2 Expectations (mockit.Expectations)2 FlinkPod (org.apache.flink.kubernetes.kubeclient.FlinkPod)2 KubernetesJobManagerSpecification (org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification)2 EnvSecretsDecorator (org.apache.flink.kubernetes.kubeclient.decorators.EnvSecretsDecorator)2 FlinkConfMountDecorator (org.apache.flink.kubernetes.kubeclient.decorators.FlinkConfMountDecorator)2 HadoopConfMountDecorator (org.apache.flink.kubernetes.kubeclient.decorators.HadoopConfMountDecorator)2 KerberosMountDecorator (org.apache.flink.kubernetes.kubeclient.decorators.KerberosMountDecorator)2 KubernetesStepDecorator (org.apache.flink.kubernetes.kubeclient.decorators.KubernetesStepDecorator)2 MountSecretsDecorator (org.apache.flink.kubernetes.kubeclient.decorators.MountSecretsDecorator)2 JSONArray (org.json.JSONArray)2