public SpinnakerRuntimeSettings buildRuntimeSettings(DeploymentConfiguration deploymentConfiguration) { SpinnakerRuntimeSettings endpoints = new SpinnakerRuntimeSettings(); for (SpinnakerService service : getServices()) { if (service != null && service.isInBillOfMaterials(deploymentConfiguration)) { log.info("Building service settings entry for " + service.getServiceName()); ServiceSettings settings = service.getDefaultServiceSettings(deploymentConfiguration); settings.mergePreferThis(service.buildServiceSettings(deploymentConfiguration)); endpoints.setServiceSettings(service.getType(), settings); } } return endpoints; }
public Optional<Profile> customProfile(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings runtimeSettings, Path profilePath, String profileName) { return customProfileOutputPath(profileName).flatMap(outputPath -> { SpinnakerArtifact artifact = getArtifact(); ProfileFactory factory = new CustomProfileFactory() { @Override public SpinnakerArtifact getArtifact() { return artifact; } protected ArtifactService getArtifactService() { return artifactService; } @Override protected Path getUserProfilePath() { return profilePath; } }; return Optional.of(factory.getProfile(profileName, outputPath, deploymentConfiguration, runtimeSettings)); }); }
public boolean isInBillOfMaterials(DeploymentConfiguration deployment) { String version = getArtifactService().getArtifactVersion(deployment.getName(), getArtifact()); return (version != null); }
boolean isDesiredService = services .stream() .filter(s -> s.equals(service.getType())) .count() > 0; List<Profile> profiles = service.getProfiles(deploymentConfiguration, runtimeSettings); .map(s -> (Optional<Profile>) service.customProfile(deploymentConfiguration, runtimeSettings, Paths.get(userProfilePath.toString(), s), s)) .filter(Optional::isPresent) .map(Optional::get) profileMessage += " and discovered " + customProfiles.size() + " custom profile" + pluralModifier + " for " + service.getCanonicalName(); DaemonTaskHandler.message(profileMessage); mergeProfilesAndPreserveProperties(outputProfiles, processProfiles(spinnakerStaging, customProfiles)); serviceProfiles.put(service.getType(), outputProfiles);
default List<ConfigSource> stageConfig(KubernetesV2Executor executor, AccountDeploymentDetails<KubernetesAccount> details, GenerateService.ResolvedConfiguration resolvedConfiguration) { Map<String, Profile> profiles = resolvedConfiguration.getProfilesForService(getService().getType()); String stagingPath = getSpinnakerStagingPath(details.getDeploymentName()); SpinnakerRuntimeSettings runtimeSettings = resolvedConfiguration.getRuntimeSettings(); for (Profile profile : sidecarService.getSidecarProfiles(resolvedConfiguration, getService())) { if (profile == null) { throw new HalException(Problem.Severity.FATAL, "Service " + sidecarService.getService().getCanonicalName() + " is required but was not supplied for deployment."); )); KubernetesV2Utils.SecretSpec spec = KubernetesV2Utils.createSecretSpec(namespace, getService().getCanonicalName(), secretNamePrefix, files); executor.apply(spec.resource.toString()); configSources.add(new ConfigSource() .collect(Collectors.toList()); KubernetesV2Utils.SecretSpec spec = KubernetesV2Utils.createSecretSpec(namespace, getService().getCanonicalName(), secretNamePrefix, files); executor.apply(spec.resource.toString()); configSources.add(new ConfigSource()
LocalLogCollector(HasServiceSettings<T> service) { super(service); this.logPaths = new ArrayList<>(); this.logPaths.add(Paths.get("/var/log/spinnaker/", getService().getCanonicalName())); this.logPaths.add(Paths.get("/var/log/upstart/", getService().getCanonicalName() + ".log")); }
.anyMatch(s -> s.getService().getType().equals(SpinnakerService.Type.CONSUL_CLIENT)); .serviceHealth(getService().getCanonicalName(), true).stream() .map(s -> s != null && s.getNode() != null ? s.getNode().getNodeName() : null) .filter(Objects::nonNull) new HashSet<>(); String serviceName = getService().getServiceName();
CustomSizing customSizing = details.getDeploymentConfiguration().getDeploymentEnvironment().getCustomSizing(); if (customSizing != null) { Map componentSizing = customSizing.getOrDefault(getService().getServiceName(), new HashMap()); targetSize = (Integer) componentSizing.getOrDefault("replicas", targetSize); String primaryContainer = buildContainer(getService().getCanonicalName(), details, settings, configSources, env); List<String> sidecarContainers = getSidecars(runtimeSettings).stream() .map(SidecarService::getService) .map(s -> buildContainer(s.getCanonicalName(), details, runtimeSettings.getServiceSettings(s), configSources, env)) .collect(Collectors.toList()); .addBinding("name", getService().getCanonicalName()) .addBinding("namespace", namespace) .addBinding("replicas", targetSize)
default List<SidecarConfig> getSidecarConfigs(AccountDeploymentDetails<KubernetesAccount> details) { //attempt to get the service name specific sidecars first List<SidecarConfig> sidecarConfigs = details.getDeploymentConfiguration() .getDeploymentEnvironment() .getSidecars() .getOrDefault(getService().getServiceName(), new ArrayList<>()); if (sidecarConfigs.isEmpty()) { sidecarConfigs = details.getDeploymentConfiguration() .getDeploymentEnvironment() .getSidecars() .getOrDefault(getService().getBaseCanonicalName(), new ArrayList<>()); } return sidecarConfigs; }
customSizing.getOrDefault(getService().getServiceName(), new HashMap())); resources.addBinding("requests", componentSizing.getOrDefault("requests", new HashMap())); resources.addBinding("limits", componentSizing.getOrDefault("limits", new HashMap()));
public <T> T createService(String endpoint, SpinnakerService<T> service) { Class<T> clazz = service.getEndpointClass(); return new RestAdapter.Builder() .setClient(okClient) .setLogLevel(retrofitLogLevel) .setEndpoint(endpoint) .build() .create(clazz); } }
boolean isDesiredService = services .stream() .filter(s -> s.equals(service.getType())) .count() > 0; List<Profile> profiles = service.getProfiles(deploymentConfiguration, runtimeSettings); .map(s -> (Optional<Profile>) service.customProfile(deploymentConfiguration, runtimeSettings, Paths.get(userProfilePath.toString(), s), s)) .filter(Optional::isPresent) .map(Optional::get) profileMessage += " and discovered " + customProfiles.size() + " custom profile" + pluralModifier + " for " + service.getCanonicalName(); DaemonTaskHandler.message(profileMessage); mergeProfilesAndPreserveProperties(outputProfiles, processProfiles(spinnakerStaging, customProfiles)); serviceProfiles.put(service.getType(), outputProfiles);
default List<ConfigSource> stageConfig(AccountDeploymentDetails<KubernetesAccount> details, GenerateService.ResolvedConfiguration resolvedConfiguration) { Map<String, Profile> profiles = resolvedConfiguration.getProfilesForService(getService().getType()); String stagingPath = getSpinnakerStagingPath(details.getDeploymentName()); SpinnakerRuntimeSettings runtimeSettings = resolvedConfiguration.getRuntimeSettings(); for (Profile profile : sidecarService.getSidecarProfiles(resolvedConfiguration, getService())) { if (profile == null) { throw new HalException(Problem.Severity.FATAL, "Service " + sidecarService.getService().getCanonicalName() + " is required but was not supplied for deployment.");
LocalLogCollector(HasServiceSettings<T> service) { super(service); this.logPaths = new ArrayList<>(); this.logPaths.add(Paths.get("/var/log/spinnaker/", getService().getCanonicalName())); this.logPaths.add(Paths.get("/var/log/upstart/", getService().getCanonicalName() + ".log")); }
.anyMatch(s -> s.getService().getType().equals(SpinnakerService.Type.CONSUL_CLIENT)); .serviceHealth(getService().getCanonicalName(), true).stream() .map(s -> s != null && s.getNode() != null ? s.getNode().getNodeName() : null) .filter(Objects::nonNull) new HashSet<>(); String serviceName = getService().getServiceName();
default String getResourceYaml(KubernetesV2Executor executor, AccountDeploymentDetails<KubernetesAccount> details, GenerateService.ResolvedConfiguration resolvedConfiguration) { ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService()); Integer targetSize = settings.getTargetSize(); CustomSizing customSizing = details.getDeploymentConfiguration().getDeploymentEnvironment().getCustomSizing(); if (customSizing != null) { Map componentSizing = customSizing.getOrDefault(getService().getServiceName(), new HashMap()); targetSize = (Integer) componentSizing.getOrDefault("replicas", targetSize); } String version = makeValidLabel(details.getDeploymentConfiguration().getVersion()); if (version.isEmpty()) { version = "unknown"; } return new JinjaJarResource("/kubernetes/manifests/deployment.yml") .addBinding("name", getService().getCanonicalName()) .addBinding("namespace", getNamespace(settings)) .addBinding("replicas", targetSize) .addBinding("version", version) .addBinding("podAnnotations", settings.getKubernetes().getPodAnnotations()) .addBinding("podSpec", getPodSpecYaml(executor, details, resolvedConfiguration)) .toString(); }
default List<String> getInitContainers(AccountDeploymentDetails<KubernetesAccount> details) { List<Map> initContainersConfig = details.getDeploymentConfiguration() .getDeploymentEnvironment() .getInitContainers() .getOrDefault(getService().getServiceName(), new ArrayList<>()); if (initContainersConfig.isEmpty()) { initContainersConfig = details.getDeploymentConfiguration() .getDeploymentEnvironment() .getInitContainers() .getOrDefault(getService().getBaseCanonicalName(), new ArrayList<>()); } List<String> initContainers = initContainersConfig .stream() .map(o -> { try { return getObjectMapper().writeValueAsString(o); } catch (JsonProcessingException e) { throw new HalException(Problem.Severity.FATAL, "Invalid init container format: " + e.getMessage(), e); } }).collect(Collectors.toList()); return initContainers; }
customSizing.getOrDefault(getService().getServiceName(), new HashMap())); resources.addBinding("requests", componentSizing.getOrDefault("requests", new HashMap())); resources.addBinding("limits", componentSizing.getOrDefault("limits", new HashMap()));
public <T> T createService(String endpoint, SpinnakerService<T> service) { Class<T> clazz = service.getEndpointClass(); return new RestAdapter.Builder() .setClient(okClient) .setLogLevel(retrofitLogLevel) .setEndpoint(endpoint) .build() .create(clazz); } }
public SpinnakerRuntimeSettings buildRuntimeSettings(DeploymentConfiguration deploymentConfiguration) { SpinnakerRuntimeSettings endpoints = new SpinnakerRuntimeSettings(); for (SpinnakerService service : getServices()) { if (service != null && service.isInBillOfMaterials(deploymentConfiguration)) { log.info("Building service settings entry for " + service.getServiceName()); ServiceSettings settings = service.getDefaultServiceSettings(deploymentConfiguration); settings.mergePreferThis(service.buildServiceSettings(deploymentConfiguration)); endpoints.setServiceSettings(service.getType(), settings); } } return endpoints; }