private void configureLivenessProbe(ContainerConfiguration containerConfiguration, ContainerBuilder containerBuilder, Set<Integer> ports) { Probe livenessProbe = new LivenessProbeCreator(properties, containerConfiguration).create(); Integer livenessProbePort = livenessProbe.getHttpGet().getPort().getIntVal(); if (livenessProbePort != null) { containerBuilder.withLivenessProbe(livenessProbe); ports.add(livenessProbePort); } }
@Override public void visit(ContainerBuilder container) { if (!container.hasReadinessProbe()) { Probe probe = getReadinessProbe(container); if (probe != null) { log.info("Adding readiness " + describe(probe)); container.withReadinessProbe(probe); } } if (!container.hasLivenessProbe()) { Probe probe = getLivenessProbe(container); if (probe != null) { log.info("Adding liveness " + describe(probe)); container.withLivenessProbe(probe); } } } });
@Override protected List<Container> getContainers() { return Collections.singletonList(new ContainerBuilder() .withName(USER_OPERATOR_CONTAINER_NAME) .withImage(getImage()) .withEnv(getEnvVars()) .withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP"))) .withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout)) .withReadinessProbe(createHttpProbe(readinessPath + "ready", HEALTHCHECK_PORT_NAME, readinessInitialDelay, readinessTimeout)) .withResources(ModelUtils.resources(getResources())) .withVolumeMounts(getVolumeMounts()) .build()); }
@Override public void visit(ContainerBuilder container) { if (!container.hasReadinessProbe()) { Probe probe = getReadinessProbe(container); if (probe != null) { log.info("Adding readiness " + describe(probe)); container.withReadinessProbe(probe); } } if (!container.hasLivenessProbe()) { Probe probe = getLivenessProbe(container); if (probe != null) { log.info("Adding liveness " + describe(probe)); container.withLivenessProbe(probe); } } } });
@Override protected List<Container> getContainers() { return Collections.singletonList(new ContainerBuilder() .withName(TOPIC_OPERATOR_CONTAINER_NAME) .withImage(getImage()) .withEnv(getEnvVars()) .withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP"))) .withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout)) .withReadinessProbe(createHttpProbe(readinessPath + "ready", HEALTHCHECK_PORT_NAME, readinessInitialDelay, readinessTimeout)) .withResources(ModelUtils.resources(getResources())) .withVolumeMounts(getVolumeMounts()) .build()); }
@Override protected List<Container> getContainers() { List<Container> containers = new ArrayList<>(); Container container = new ContainerBuilder() .withName(name) .withImage(getImage()) .withEnv(getEnvVars()) .withPorts(getContainerPortList()) .withLivenessProbe(createHttpProbe(livenessPath, REST_API_PORT_NAME, livenessInitialDelay, livenessTimeout)) .withReadinessProbe(createHttpProbe(readinessPath, REST_API_PORT_NAME, readinessInitialDelay, readinessTimeout)) .withVolumeMounts(getVolumeMounts()) .withResources(ModelUtils.resources(getResources())) .build(); containers.add(container); return containers; }
@Override protected List<Container> getContainers() { List<Container> containers = new ArrayList<>(); if (topicOperator != null) { containers.addAll(topicOperator.getContainers()); } if (userOperator != null) { containers.addAll(userOperator.getContainers()); } String tlsSidecarImage = EntityOperatorSpec.DEFAULT_TLS_SIDECAR_IMAGE; if (tlsSidecar != null && tlsSidecar.getImage() != null) { tlsSidecarImage = tlsSidecar.getImage(); } Container tlsSidecarContainer = new ContainerBuilder() .withName(TLS_SIDECAR_NAME) .withImage(tlsSidecarImage) .withLivenessProbe(ModelUtils.tlsSidecarLivenessProbe(tlsSidecar)) .withReadinessProbe(ModelUtils.tlsSidecarReadinessProbe(tlsSidecar)) .withResources(ModelUtils.tlsSidecarResources(tlsSidecar)) .withEnv(asList(ModelUtils.tlsSidecarLogEnvVar(tlsSidecar), buildEnvVar(ENV_VAR_ZOOKEEPER_CONNECT, zookeeperConnect))) .withVolumeMounts(createVolumeMount(TLS_SIDECAR_EO_CERTS_VOLUME_NAME, TLS_SIDECAR_EO_CERTS_VOLUME_MOUNT), createVolumeMount(TLS_SIDECAR_CA_CERTS_VOLUME_NAME, TLS_SIDECAR_CA_CERTS_VOLUME_MOUNT)) .withLifecycle(new LifecycleBuilder().withNewPreStop().withNewExec().withCommand("/opt/stunnel/stunnel_pre_stop.sh", String.valueOf(templateTerminationGracePeriodSeconds)).endExec().endPreStop().build()) .build(); containers.add(tlsSidecarContainer); return containers; }
.withEnv(getEnvVars()) .withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP"))) .withLivenessProbe(createHttpProbe(livenessPath + "healthy", HEALTHCHECK_PORT_NAME, livenessInitialDelay, livenessTimeout)) .withReadinessProbe(createHttpProbe(readinessPath + "ready", HEALTHCHECK_PORT_NAME, readinessInitialDelay, readinessTimeout)) .withResources(ModelUtils.resources(getResources())) .withName(TLS_SIDECAR_NAME) .withImage(tlsSidecarImage) .withLivenessProbe(ModelUtils.tlsSidecarLivenessProbe(tlsSidecar)) .withReadinessProbe(ModelUtils.tlsSidecarReadinessProbe(tlsSidecar)) .withResources(ModelUtils.tlsSidecarResources(tlsSidecar))
.withVolumeMounts(getVolumeMounts()) .withPorts(getContainerPortList()) .withLivenessProbe(ModelUtils.createExecProbe(Collections.singletonList(livenessPath), livenessInitialDelay, livenessTimeout)) .withReadinessProbe(ModelUtils.createExecProbe(Collections.singletonList(readinessPath), readinessInitialDelay, readinessTimeout)) .withResources(ModelUtils.resources(getResources())) .withName(TLS_SIDECAR_NAME) .withImage(tlsSidecarImage) .withLivenessProbe(ModelUtils.tlsSidecarLivenessProbe(tlsSidecar)) .withReadinessProbe(ModelUtils.tlsSidecarReadinessProbe(tlsSidecar)) .withResources(ModelUtils.tlsSidecarResources(tlsSidecar))
.withVolumeMounts(getVolumeMounts()) .withPorts(getContainerPortList()) .withLivenessProbe(createTcpSocketProbe(REPLICATION_PORT, livenessInitialDelay, livenessTimeout)) .withReadinessProbe(createTcpSocketProbe(REPLICATION_PORT, readinessInitialDelay, readinessTimeout)) .withResources(ModelUtils.resources(getResources())) .withName(TLS_SIDECAR_NAME) .withImage(tlsSidecarImage) .withLivenessProbe(ModelUtils.tlsSidecarLivenessProbe(tlsSidecar)) .withReadinessProbe(ModelUtils.tlsSidecarReadinessProbe(tlsSidecar)) .withResources(ModelUtils.tlsSidecarResources(tlsSidecar))
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(this.groupArtifactVersion, imageConfig)) .withImage(getImageName(imageConfig)) .withImagePullPolicy(getImagePullPolicy(config)) .withEnv(getEnvVars(config)) .withSecurityContext(createSecurityContext(config)) .withPorts(getContainerPorts(imageConfig)) .withVolumeMounts(getVolumeMounts(config)) .withLivenessProbe(livenessProbe) .withReadinessProbe(readinessProbe) .build(); ret.add(container); } } return ret; }
private Container generateContainer(DeploymentModel deploymentModel, List<ContainerPort> containerPorts) { return new ContainerBuilder() .withName(deploymentModel.getName()) .withImage(deploymentModel.getImage()) .withImagePullPolicy(deploymentModel.getImagePullPolicy()) .withPorts(containerPorts) .withEnv(populateEnvVar(deploymentModel.getEnv())) .withVolumeMounts(populateVolumeMounts(deploymentModel)) .withLivenessProbe(generateLivenessProbe(deploymentModel)) .build(); }
.withCommand(parseDockerCommand(containerTemplate.getCommand())) .withArgs(arguments) .withLivenessProbe(livenessProbe) .withTty(containerTemplate.isTtyEnabled()) .withNewResources()
public ContainerBuilder( Container instance ){ this.fluent = this; this.withArgs(instance.getArgs()); this.withCommand(instance.getCommand()); this.withEnv(instance.getEnv()); this.withImage(instance.getImage()); this.withImagePullPolicy(instance.getImagePullPolicy()); this.withLifecycle(instance.getLifecycle()); this.withLivenessProbe(instance.getLivenessProbe()); this.withName(instance.getName()); this.withPorts(instance.getPorts()); this.withReadinessProbe(instance.getReadinessProbe()); this.withResources(instance.getResources()); this.withSecurityContext(instance.getSecurityContext()); this.withTerminationMessagePath(instance.getTerminationMessagePath()); this.withVolumeMounts(instance.getVolumeMounts()); this.withWorkingDir(instance.getWorkingDir()); }
public ContainerBuilder( Container instance ){ this.fluent = this; this.withArgs(instance.getArgs()); this.withCapabilities(instance.getCapabilities()); this.withCommand(instance.getCommand()); this.withEnv(instance.getEnv()); this.withImage(instance.getImage()); this.withImagePullPolicy(instance.getImagePullPolicy()); this.withLifecycle(instance.getLifecycle()); this.withLivenessProbe(instance.getLivenessProbe()); this.withName(instance.getName()); this.withPorts(instance.getPorts()); this.withPrivileged(instance.getPrivileged()); this.withReadinessProbe(instance.getReadinessProbe()); this.withResources(instance.getResources()); this.withSecurityContext(instance.getSecurityContext()); this.withTerminationMessagePath(instance.getTerminationMessagePath()); this.withVolumeMounts(instance.getVolumeMounts()); this.withWorkingDir(instance.getWorkingDir()); }
public ContainerBuilder(Container instance,Boolean validationEnabled){ this.fluent = this; this.withArgs(instance.getArgs()); this.withCommand(instance.getCommand()); this.withEnv(instance.getEnv()); this.withImage(instance.getImage()); this.withImagePullPolicy(instance.getImagePullPolicy()); this.withLifecycle(instance.getLifecycle()); this.withLivenessProbe(instance.getLivenessProbe()); this.withName(instance.getName()); this.withPorts(instance.getPorts()); this.withReadinessProbe(instance.getReadinessProbe()); this.withResources(instance.getResources()); this.withSecurityContext(instance.getSecurityContext()); this.withStdin(instance.getStdin()); this.withStdinOnce(instance.getStdinOnce()); this.withTerminationMessagePath(instance.getTerminationMessagePath()); this.withTty(instance.getTty()); this.withVolumeMounts(instance.getVolumeMounts()); this.withWorkingDir(instance.getWorkingDir()); this.validationEnabled = validationEnabled; }
.withEnv(getEnvVars()) .withPorts(getContainerPortList()) .withLivenessProbe(createHttpProbe(livenessPath, REST_API_PORT_NAME, livenessInitialDelay, livenessTimeout)) .withReadinessProbe(createHttpProbe(readinessPath, REST_API_PORT_NAME, readinessInitialDelay, readinessTimeout)) .withVolumeMounts(getVolumeMounts())