use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource in project halyard by spinnaker.
the class LocalGitService method installArtifactCommand.
default String installArtifactCommand(DeploymentDetails deploymentDetails) {
Map<String, Object> bindings = new HashMap<>();
bindings.put("scripts-dir", getScriptsDir());
bindings.put("artifact", getArtifact().getName());
TemplatedResource installResource = new StringReplaceJarResource("/git/install-component.sh");
installResource.setBindings(bindings);
return installResource.toString();
}
use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource 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.core.resource.v1.TemplatedResource 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.core.resource.v1.TemplatedResource in project halyard by spinnaker.
the class BakeDebianServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands, String startupCommand) {
Map<String, Object> bindings = new HashMap<>();
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> upstartNames = getPrioritizedBakeableServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).map(i -> ((BakeDebianService) i).getUpstartServiceName()).filter(Objects::nonNull).collect(Collectors.toList());
List<String> systemdServiceConfigs = upstartNames.stream().map(n -> n + ".service").collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/debian/init.sh");
bindings.put("services", Strings.join(upstartNames, " "));
bindings.put("systemd-service-configs", Strings.join(systemdServiceConfigs, " "));
String upstartInit = resource.setBindings(bindings).toString();
BillOfMaterials.ArtifactSources artifactSources = artifactService.getArtifactSources(deploymentDetails.getDeploymentName());
resource = new StringReplaceJarResource("/debian/pre-bake.sh");
bindings = new HashMap<>();
bindings.put("debian-repository", artifactSourcesConfig.mergeWithBomSources(artifactSources).getDebianRepository());
bindings.put("install-commands", String.join("\n", serviceInstalls));
bindings.put("upstart-init", upstartInit);
bindings.put("startup-file", Paths.get(startupScriptPath, "startup.sh").toString());
bindings.put("startup-command", startupCommand);
return resource.setBindings(bindings).toString();
}
use of com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource in project halyard by spinnaker.
the class LocalDebianServiceProvider method clean.
@Override
public RemoteAction clean(DeploymentDetails details, SpinnakerRuntimeSettings runtimeSettings) {
String uninstallArtifacts = String.join("\n", getServices().stream().filter(s -> s != null && runtimeSettings.getServiceSettings(s).getEnabled()).map(s -> ((LocalDebianService) s).uninstallArtifactCommand()).collect(Collectors.toList()));
Map<String, Object> bindings = new HashMap<>();
TemplatedResource resource = new StringReplaceJarResource("/debian/uninstall.sh");
bindings.put("uninstall-artifacts", uninstallArtifacts);
return new RemoteAction().setScript(resource.setBindings(bindings).toString()).setAutoRun(true).setScriptDescription("This script apt-get purges all spinnaker components & deletes their config");
}
Aggregations