use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class StatefulSetHandlerTest method statefulSetHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void statefulSetHandlerWithInvalidNameTest() {
// invalid controller name
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
StatefulSetHandler statefulSetHandler = new StatefulSetHandler(podTemplateHandler);
// with invalid controller name
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
statefulSetHandler.getStatefulSet(config, images);
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class StatefulSetHandlerTest method before.
@Before
public void before() {
// volume config with name and multiple mount
mounts.add("/path/system");
mounts.add("/path/sys");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
volumes1.add(volumeConfig1);
// container name with alias
BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
images.add(imageConfiguration);
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class StatefulSetHandlerTest method statefulSetHandlerTest.
@Test
public void statefulSetHandlerTest() {
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
StatefulSetHandler statefulSetHandler = new StatefulSetHandler(podTemplateHandler);
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
StatefulSet statefulSet = statefulSetHandler.getStatefulSet(config, images);
// Assertion
assertNotNull(statefulSet.getSpec());
assertNotNull(statefulSet.getMetadata());
assertEquals(5, statefulSet.getSpec().getReplicas().intValue());
assertNotNull(statefulSet.getSpec().getTemplate());
assertEquals("testing", statefulSet.getMetadata().getName());
assertEquals("testing", statefulSet.getSpec().getServiceName());
assertEquals("test-account", statefulSet.getSpec().getTemplate().getSpec().getServiceAccountName());
assertFalse(statefulSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
assertEquals("test", statefulSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
assertEquals("/test/path", statefulSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
assertNotNull(statefulSet.getSpec().getTemplate().getSpec().getContainers());
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class ContainerHandler method getVolumeMounts.
private List<VolumeMount> getVolumeMounts(ResourceConfig config) {
List<VolumeConfig> volumeConfigs = config.getVolumes();
List<VolumeMount> ret = new ArrayList<>();
if (volumeConfigs != null) {
for (VolumeConfig volumeConfig : volumeConfigs) {
List<String> mounts = volumeConfig.getMounts();
if (mounts != null) {
for (String mount : mounts) {
ret.add(new VolumeMountBuilder().withName(volumeConfig.getName()).withMountPath(mount).withReadOnly(false).build());
}
}
}
}
return ret;
}
use of io.fabric8.docker.client.Config in project fabric8-maven-plugin by fabric8io.
the class ContainerHandler method getContainers.
List<Container> getContainers(ResourceConfig config, List<ImageConfiguration> images) {
List<Container> ret = new ArrayList<>();
for (ImageConfiguration imageConfig : images) {
if (imageConfig.getBuildConfiguration() != null) {
Probe livenessProbe = probeHandler.getProbe(config.getLiveness());
Probe readinessProbe = probeHandler.getProbe(config.getReadiness());
Container container = new ContainerBuilder().withName(KubernetesResourceUtil.extractContainerName(project, imageConfig)).withImage(getImageName(imageConfig)).withImagePullPolicy(getImagePullPolicy(config)).withEnv(envVarHandler.getEnvironmentVariables(config.getEnv())).withSecurityContext(createSecurityContext(config)).withPorts(getContainerPorts(imageConfig)).withVolumeMounts(getVolumeMounts(config)).withLivenessProbe(livenessProbe).withReadinessProbe(readinessProbe).build();
ret.add(container);
}
}
return ret;
}
Aggregations