use of com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesProbe in project halyard by spinnaker.
the class KubernetesV1DistributedService method buildContainer.
default KubernetesContainerDescription buildContainer(String name, ServiceSettings settings, List<ConfigSource> configSources, DeploymentEnvironment deploymentEnvironment, DeployKubernetesAtomicOperationDescription description) {
KubernetesContainerDescription container = new KubernetesContainerDescription();
KubernetesProbe readinessProbe = new KubernetesProbe();
KubernetesHandler handler = new KubernetesHandler();
int port = settings.getPort();
String healthEndpoint = settings.getHealthEndpoint();
if (healthEndpoint != null) {
handler.setType(KubernetesHandlerType.HTTP);
KubernetesHttpGetAction action = new KubernetesHttpGetAction();
action.setPath(healthEndpoint);
action.setPort(port);
handler.setHttpGetAction(action);
} else {
handler.setType(KubernetesHandlerType.TCP);
KubernetesTcpSocketAction action = new KubernetesTcpSocketAction();
action.setPort(port);
handler.setTcpSocketAction(action);
}
readinessProbe.setHandler(handler);
container.setReadinessProbe(readinessProbe);
applyCustomSize(container, deploymentEnvironment, name, description);
KubernetesImageDescription imageDescription = KubernetesUtil.buildImageDescription(settings.getArtifactId());
container.setImageDescription(imageDescription);
container.setName(name);
List<KubernetesContainerPort> ports = new ArrayList<>();
KubernetesContainerPort containerPort = new KubernetesContainerPort();
containerPort.setContainerPort(port);
ports.add(containerPort);
container.setPorts(ports);
List<KubernetesVolumeMount> volumeMounts = new ArrayList<>();
for (ConfigSource configSource : configSources) {
KubernetesVolumeMount volumeMount = new KubernetesVolumeMount();
volumeMount.setName(configSource.getId());
volumeMount.setMountPath(configSource.getMountPath());
volumeMounts.add(volumeMount);
}
container.setVolumeMounts(volumeMounts);
List<KubernetesEnvVar> envVars = new ArrayList<>();
settings.getEnv().forEach((k, v) -> {
KubernetesEnvVar envVar = new KubernetesEnvVar();
envVar.setName(k);
envVar.setValue(v);
envVars.add(envVar);
});
configSources.forEach(c -> {
c.getEnv().entrySet().forEach(envEntry -> {
KubernetesEnvVar envVar = new KubernetesEnvVar();
envVar.setName(envEntry.getKey());
envVar.setValue(envEntry.getValue());
envVars.add(envVar);
});
});
container.setEnvVars(envVars);
return container;
}
Aggregations