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());
}
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();
}
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());
}
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"));
}
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();
}
Aggregations