use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.
the class KubernetesV2Service method connectCommand.
default String connectCommand(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) {
ServiceSettings settings = runtimeSettings.getServiceSettings(getService());
KubernetesAccount account = details.getAccount();
String namespace = settings.getLocation();
String name = getServiceName();
int port = settings.getPort();
String podNameCommand = String.join(" ", KubernetesV2Utils.kubectlPodServiceCommand(account, namespace, name));
return String.join(" ", KubernetesV2Utils.kubectlConnectPodCommand(account, namespace, "$(" + podNameCommand + ")", port));
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.
the class KubernetesV2Service method getResourceYaml.
default String getResourceYaml(AccountDeploymentDetails<KubernetesAccount> details, GenerateService.ResolvedConfiguration resolvedConfiguration) {
ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService());
String namespace = getNamespace(settings);
List<ConfigSource> configSources = stageConfig(details, resolvedConfiguration);
Map<String, String> env = configSources.stream().map(ConfigSource::getEnv).map(Map::entrySet).flatMap(Collection::stream).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
env.putAll(settings.getEnv());
List<String> volumes = configSources.stream().map(c -> {
TemplatedResource volume = new JinjaJarResource("/kubernetes/manifests/volume.yml");
volume.addBinding("name", c.getId());
return volume.toString();
}).collect(Collectors.toList());
List<String> volumeMounts = configSources.stream().map(c -> {
TemplatedResource volume = new JinjaJarResource("/kubernetes/manifests/volumeMount.yml");
volume.addBinding("name", c.getId());
volume.addBinding("mountPath", c.getMountPath());
return volume.toString();
}).collect(Collectors.toList());
TemplatedResource probe;
if (StringUtils.isNotEmpty(settings.getHealthEndpoint())) {
probe = new JinjaJarResource("/kubernetes/manifests/execReadinessProbe.yml");
probe.addBinding("command", getReadinessExecCommand(settings));
} else {
probe = new JinjaJarResource("/kubernetes/manifests/tcpSocketReadinessProbe.yml");
probe.addBinding("port", settings.getPort());
}
TemplatedResource container = new JinjaJarResource("/kubernetes/manifests/container.yml");
container.addBinding("name", getService().getCanonicalName());
container.addBinding("imageId", settings.getArtifactId());
container.addBinding("port", settings.getPort());
container.addBinding("volumeMounts", volumeMounts);
container.addBinding("probe", probe.toString());
container.addBinding("env", env);
List<String> containers = Collections.singletonList(container.toString());
TemplatedResource podSpec = new JinjaJarResource("/kubernetes/manifests/podSpec.yml").addBinding("containers", containers).addBinding("volumes", volumes);
return new JinjaJarResource("/kubernetes/manifests/deployment.yml").addBinding("name", getService().getCanonicalName()).addBinding("namespace", namespace).addBinding("replicas", settings.getTargetSize()).addBinding("podAnnotations", settings.getKubernetes().getPodAnnotations()).addBinding("podSpec", podSpec.toString()).toString();
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.
the class KubernetesV2Service method getServiceYaml.
default String getServiceYaml(GenerateService.ResolvedConfiguration resolvedConfiguration) {
ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService());
String namespace = getNamespace(settings);
TemplatedResource service = new JinjaJarResource("/kubernetes/manifests/service.yml");
service.addBinding("name", getService().getCanonicalName());
service.addBinding("namespace", namespace);
service.addBinding("port", settings.getPort());
return service.toString();
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.
the class ResourceBuilder method buildContainer.
static Container buildContainer(String name, ServiceSettings settings, List<ConfigSource> configSources, DeploymentEnvironment deploymentEnvironment) {
int port = settings.getPort();
List<EnvVar> envVars = settings.getEnv().entrySet().stream().map(e -> {
EnvVarBuilder envVarBuilder = new EnvVarBuilder();
return envVarBuilder.withName(e.getKey()).withValue(e.getValue()).build();
}).collect(Collectors.toList());
configSources.forEach(c -> {
c.getEnv().entrySet().forEach(envEntry -> {
EnvVarBuilder envVarBuilder = new EnvVarBuilder();
envVars.add(envVarBuilder.withName(envEntry.getKey()).withValue(envEntry.getValue()).build());
});
});
ProbeBuilder probeBuilder = new ProbeBuilder();
if (settings.getHealthEndpoint() != null) {
probeBuilder = probeBuilder.withNewHttpGet().withNewPort(port).withPath(settings.getHealthEndpoint()).endHttpGet();
} else {
probeBuilder = probeBuilder.withNewTcpSocket().withNewPort().withIntVal(port).endPort().endTcpSocket();
}
List<VolumeMount> volumeMounts = configSources.stream().map(c -> {
return new VolumeMountBuilder().withMountPath(c.getMountPath()).withName(c.getId()).build();
}).collect(Collectors.toList());
ContainerBuilder containerBuilder = new ContainerBuilder();
containerBuilder = containerBuilder.withName(name).withImage(settings.getArtifactId()).withPorts(new ContainerPortBuilder().withContainerPort(port).build()).withVolumeMounts(volumeMounts).withEnv(envVars).withReadinessProbe(probeBuilder.build()).withResources(buildResourceRequirements(name, deploymentEnvironment));
return containerBuilder.build();
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.
the class DistributedService method getSidecars.
default List<SidecarService> getSidecars(SpinnakerRuntimeSettings runtimeSettings) {
SpinnakerMonitoringDaemonService monitoringService = getMonitoringDaemonService();
ServiceSettings monitoringSettings = runtimeSettings.getServiceSettings(monitoringService);
ServiceSettings thisSettings = runtimeSettings.getServiceSettings(getService());
List<SidecarService> result = new ArrayList<>();
if (monitoringSettings.getEnabled() && thisSettings.getMonitored()) {
result.add(monitoringService);
}
return result;
}
Aggregations