use of com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesVolumeSource in project halyard by spinnaker.
the class KubernetesV1DistributedService method getServerGroupDescription.
default Map<String, Object> getServerGroupDescription(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings, List<ConfigSource> configSources) {
DeployKubernetesAtomicOperationDescription description = new DeployKubernetesAtomicOperationDescription();
SpinnakerMonitoringDaemonService monitoringService = getMonitoringDaemonService();
ServiceSettings settings = runtimeSettings.getServiceSettings(getService());
DeploymentEnvironment deploymentEnvironment = details.getDeploymentConfiguration().getDeploymentEnvironment();
String accountName = details.getAccount().getName();
String namespace = getNamespace(settings);
String name = getServiceName();
Names parsedName = Names.parseName(name);
description.setNamespace(namespace);
description.setAccount(accountName);
description.setApplication(parsedName.getApp());
description.setStack(parsedName.getStack());
description.setFreeFormDetails(parsedName.getDetail());
List<KubernetesVolumeSource> volumeSources = new ArrayList<>();
for (ConfigSource configSource : configSources) {
KubernetesVolumeSource volumeSource = new KubernetesVolumeSource();
volumeSource.setName(configSource.getId());
volumeSource.setType(KubernetesVolumeSourceType.Secret);
KubernetesSecretVolumeSource secretVolumeSource = new KubernetesSecretVolumeSource();
secretVolumeSource.setSecretName(configSource.getId());
volumeSource.setSecret(secretVolumeSource);
volumeSources.add(volumeSource);
}
description.setVolumeSources(volumeSources);
description.setPodAnnotations(settings.getKubernetes().getPodAnnotations());
List<String> loadBalancers = new ArrayList<>();
loadBalancers.add(name);
description.setLoadBalancers(loadBalancers);
List<KubernetesContainerDescription> containers = new ArrayList<>();
ServiceSettings serviceSettings = runtimeSettings.getServiceSettings(getService());
KubernetesContainerDescription container = buildContainer(name, serviceSettings, configSources, deploymentEnvironment, description);
containers.add(container);
ServiceSettings monitoringSettings = runtimeSettings.getServiceSettings(monitoringService);
if (monitoringSettings.getEnabled() && serviceSettings.getMonitored()) {
serviceSettings = runtimeSettings.getServiceSettings(monitoringService);
container = buildContainer(monitoringService.getServiceName(), serviceSettings, configSources, deploymentEnvironment, description);
containers.add(container);
}
description.setContainers(containers);
return getObjectMapper().convertValue(description, new TypeReference<Map<String, Object>>() {
});
}
Aggregations