Search in sources :

Example 6 with ServiceSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.

the class KubernetesV2Service method getNamespaceYaml.

default String getNamespaceYaml(GenerateService.ResolvedConfiguration resolvedConfiguration) {
    ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService());
    String name = getNamespace(settings);
    TemplatedResource namespace = new JinjaJarResource("/kubernetes/manifests/namespace.yml");
    namespace.addBinding("name", name);
    return namespace.toString();
}
Also used : JinjaJarResource(com.netflix.spinnaker.halyard.core.resource.v1.JinjaJarResource) HasServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings) KubernetesSharedServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource)

Example 7 with ServiceSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.

the class KubernetesV2Service method buildServiceSettings.

default ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) {
    KubernetesSharedServiceSettings kubernetesSharedServiceSettings = new KubernetesSharedServiceSettings(deploymentConfiguration);
    ServiceSettings settings = defaultServiceSettings();
    String location = kubernetesSharedServiceSettings.getDeployLocation();
    settings.setAddress(buildAddress(location)).setArtifactId(getArtifactId(deploymentConfiguration.getName())).setLocation(location).setEnabled(isEnabled(deploymentConfiguration));
    return settings;
}
Also used : KubernetesSharedServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings) HasServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings) KubernetesSharedServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)

Example 8 with ServiceSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.

the class KubernetesV1RedisService method connectToPrimaryService.

@Override
public Jedis connectToPrimaryService(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings) {
    ServiceSettings settings = runtimeSettings.getServiceSettings(this);
    List<String> command = Arrays.stream(connectCommand(details, runtimeSettings).split(" ")).collect(Collectors.toList());
    JobRequest request = new JobRequest().setTokenizedCommand(command);
    String jobId = getJobExecutor().startJob(request);
    // Wait for the proxy to spin up.
    DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5));
    JobStatus status = getJobExecutor().updateJob(jobId);
    // This should be a long-running job.
    if (status.getState() == JobStatus.State.COMPLETED) {
        throw new HalException(Problem.Severity.FATAL, "Unable to establish a proxy against Redis:\n" + status.getStdOut() + "\n" + status.getStdErr());
    }
    return new Jedis("localhost", settings.getPort());
}
Also used : JobStatus(com.netflix.spinnaker.halyard.core.job.v1.JobStatus) Jedis(redis.clients.jedis.Jedis) JobRequest(com.netflix.spinnaker.halyard.core.job.v1.JobRequest) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) HasServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings) KubernetesSharedServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)

Example 9 with ServiceSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.

the class DistributedDeployer method reapOrcaServerGroups.

private <T extends Account> Set<Integer> reapOrcaServerGroups(AccountDeploymentDetails<T> details, SpinnakerRuntimeSettings runtimeSettings, DistributedService<Orca, T> orcaService) {
    if (runtimeSettings.getServiceSettings(orcaService.getService()).getSkipLifeCycleManagement()) {
        return Collections.emptySet();
    }
    RunningServiceDetails runningOrcaDetails = orcaService.getRunningServiceDetails(details, runtimeSettings);
    Map<Integer, List<RunningServiceDetails.Instance>> instances = runningOrcaDetails.getInstances();
    List<Integer> versions = new ArrayList<>(instances.keySet());
    versions.sort(Integer::compareTo);
    Set<Integer> unknownVersions = disableOrcaServerGroups(details, runtimeSettings, orcaService, runningOrcaDetails);
    Map<Integer, Integer> executionsByServerGroupVersion = new HashMap<>();
    for (Integer version : versions) {
        if (unknownVersions.contains(version)) {
            executionsByServerGroupVersion.put(version, // we make the assumption that there is non-0 work for the unknown versions
            1);
        } else {
            executionsByServerGroupVersion.put(version, 0);
        }
    }
    ServiceSettings orcaSettings = runtimeSettings.getServiceSettings(orcaService.getService());
    cleanupServerGroups(details, orcaService, orcaSettings, executionsByServerGroupVersion, versions);
    return unknownVersions;
}
Also used : HashMap(java.util.HashMap) RunningServiceDetails(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails) ArrayList(java.util.ArrayList) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with ServiceSettings

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings in project halyard by spinnaker.

the class GenerateService method generateConfig.

/**
 * Generate config for a given deployment.
 *
 * This involves a few steps:
 *
 *   1. Clear out old config generated in a prior run.
 *   2. Generate configuration using the halconfig as the source of truth, while collecting files needed by
 *      the deployment.
 *
 * @param deploymentName is the deployment whose config to generate
 * @param services is the list of services to generate configs for
 * @return a mapping from components to the profile's required local files.
 */
public ResolvedConfiguration generateConfig(String deploymentName, List<SpinnakerService.Type> services) {
    DaemonTaskHandler.newStage("Generating all Spinnaker profile files and endpoints");
    log.info("Generating config from \"" + halconfigPath + "\" with deploymentName \"" + deploymentName + "\"");
    File spinnakerStaging = halconfigDirectoryStructure.getStagingPath(deploymentName).toFile();
    DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
    DaemonTaskHandler.message("Building service endpoints");
    SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration);
    SpinnakerRuntimeSettings runtimeSettings = serviceProvider.buildRuntimeSettings(deploymentConfiguration);
    // Step 1.
    try {
        FileUtils.deleteDirectory(spinnakerStaging);
    } catch (IOException e) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Unable to clear old spinnaker config: " + e.getMessage() + ".").build());
    }
    Path userProfilePath = halconfigDirectoryStructure.getUserProfilePath(deploymentName);
    List<String> userProfileNames = aggregateProfilesInPath(userProfilePath.toString(), "");
    // Step 2.
    Map<SpinnakerService.Type, Map<String, Profile>> serviceProfiles = new HashMap<>();
    for (SpinnakerService service : serviceProvider.getServices()) {
        boolean isDesiredService = services.stream().filter(s -> s.equals(service.getType())).count() > 0;
        if (!isDesiredService) {
            continue;
        }
        ServiceSettings settings = runtimeSettings.getServiceSettings(service);
        if (settings == null || !settings.getEnabled()) {
            continue;
        }
        List<Profile> profiles = service.getProfiles(deploymentConfiguration, runtimeSettings);
        String pluralModifier = profiles.size() == 1 ? "" : "s";
        String profileMessage = "Generated " + profiles.size() + " profile" + pluralModifier;
        Map<String, Profile> outputProfiles = processProfiles(spinnakerStaging, profiles);
        List<Profile> customProfiles = userProfileNames.stream().map(s -> (Optional<Profile>) service.customProfile(deploymentConfiguration, runtimeSettings, Paths.get(userProfilePath.toString(), s), s)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
        pluralModifier = customProfiles.size() == 1 ? "" : "s";
        profileMessage += " and discovered " + customProfiles.size() + " custom profile" + pluralModifier + " for " + service.getCanonicalName();
        DaemonTaskHandler.message(profileMessage);
        mergeProfilesAndPreserveProperties(outputProfiles, processProfiles(spinnakerStaging, customProfiles));
        serviceProfiles.put(service.getType(), outputProfiles);
    }
    return new ResolvedConfiguration().setServiceProfiles(serviceProfiles).setRuntimeSettings(runtimeSettings);
}
Also used : DeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails) Path(java.nio.file.Path) Arrays(java.util.Arrays) Autowired(org.springframework.beans.factory.annotation.Autowired) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) HashMap(java.util.HashMap) ServiceProviderFactory(com.netflix.spinnaker.halyard.deploy.deployment.v1.ServiceProviderFactory) DaemonTaskHandler(com.netflix.spinnaker.halyard.core.tasks.v1.DaemonTaskHandler) ArrayList(java.util.ArrayList) Map(java.util.Map) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) Severity(com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) Path(java.nio.file.Path) DeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) ConfigParser(com.netflix.spinnaker.halyard.deploy.config.v1.ConfigParser) Collectors(java.util.stream.Collectors) HalconfigDirectoryStructure(com.netflix.spinnaker.halyard.config.config.v1.HalconfigDirectoryStructure) File(java.io.File) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) Slf4j(lombok.extern.slf4j.Slf4j) Component(org.springframework.stereotype.Component) List(java.util.List) DeploymentService(com.netflix.spinnaker.halyard.config.services.v1.DeploymentService) Profile(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.Profile) Paths(java.nio.file.Paths) Data(lombok.Data) Optional(java.util.Optional) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) SpinnakerServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerServiceProvider) Collections(java.util.Collections) Optional(java.util.Optional) HashMap(java.util.HashMap) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) IOException(java.io.IOException) SpinnakerService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService) Profile(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.Profile) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Aggregations

ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)35 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)18 ArrayList (java.util.ArrayList)18 RunningServiceDetails (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.RunningServiceDetails)14 HashMap (java.util.HashMap)14 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)12 Map (java.util.Map)12 List (java.util.List)10 Profile (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.Profile)9 ConfigSource (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ConfigSource)9 HasServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings)8 SpinnakerService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService)8 HashSet (java.util.HashSet)7 Names (com.netflix.frigga.Names)6 DistributedService (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.DistributedService)6 Collectors (java.util.stream.Collectors)6 KubernetesImageDescription (com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesImageDescription)5 KubernetesAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount)5 AccountDeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails)5 ArtifactService (com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService)5