Search in sources :

Example 1 with DeploymentEnvironment

use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment 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>>() {
    });
}
Also used : DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) DeployKubernetesAtomicOperationDescription(com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.DeployKubernetesAtomicOperationDescription) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) ArrayList(java.util.ArrayList) KubernetesVolumeSource(com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesVolumeSource) Names(com.netflix.frigga.Names) ConfigSource(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ConfigSource) KubernetesContainerDescription(com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesContainerDescription) KubernetesSecretVolumeSource(com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesSecretVolumeSource) SpinnakerMonitoringDaemonService(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerMonitoringDaemonService) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with DeploymentEnvironment

use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment in project halyard by spinnaker.

the class DeployService method getDeploymentDetails.

private DeploymentDetails getDeploymentDetails(DeploymentConfiguration deploymentConfiguration) {
    String deploymentName = deploymentConfiguration.getName();
    BillOfMaterials billOfMaterials = artifactService.getBillOfMaterials(deploymentName);
    DeploymentEnvironment.DeploymentType type = deploymentConfiguration.getDeploymentEnvironment().getType();
    switch(type) {
        case BakeDebian:
        case LocalDebian:
        case LocalGit:
            return new DeploymentDetails().setDeploymentConfiguration(deploymentConfiguration).setDeploymentName(deploymentName).setBillOfMaterials(billOfMaterials);
        case Distributed:
            DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
            String accountName = deploymentEnvironment.getAccountName();
            if (accountName == null || accountName.isEmpty()) {
                throw new HalException(FATAL, "An account name must be " + "specified as the desired place to deploy your simple clustered deployment.");
            }
            Account account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), accountName);
            return new AccountDeploymentDetails().setAccount(account).setDeploymentConfiguration(deploymentConfiguration).setDeploymentName(deploymentName).setBillOfMaterials(billOfMaterials);
        default:
            throw new IllegalArgumentException("Unrecognized deployment type " + type);
    }
}
Also used : AccountDeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails) DeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) AccountDeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) BillOfMaterials(com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials)

Example 3 with DeploymentEnvironment

use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment in project halyard by spinnaker.

the class DeployService method getDeployer.

private Deployer getDeployer(DeploymentConfiguration deploymentConfiguration) {
    DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
    DeploymentEnvironment.DeploymentType type = deploymentEnvironment.getType();
    String accountName = deploymentEnvironment.getAccountName();
    switch(type) {
        case BakeDebian:
            return bakeDeployer;
        case LocalGit:
            return localGitDeployer;
        case LocalDebian:
            return localDeployer;
        case Distributed:
            if (StringUtils.isEmpty(accountName)) {
                throw new HalException(Problem.Severity.FATAL, "An account name must be " + "specified as the desired place to run your distributed deployment.");
            }
            Account account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), accountName);
            Provider.ProviderType providerType = ((Provider) account.getParent()).providerType();
            if (providerType == Provider.ProviderType.KUBERNETES && account.getProviderVersion() == V2) {
                return kubectlDeployer;
            } else {
                return distributedDeployer;
            }
        default:
            throw new IllegalArgumentException("Unrecognized deployment type " + type);
    }
}
Also used : Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) SpinnakerServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerServiceProvider)

Example 4 with DeploymentEnvironment

use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment in project halyard by spinnaker.

the class ServiceProviderFactory method createDeployableServiceProvider.

private SpinnakerServiceProvider createDeployableServiceProvider(DeploymentConfiguration deploymentConfiguration) {
    DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
    String accountName = deploymentEnvironment.getAccountName();
    if (accountName == null || accountName.isEmpty()) {
        throw new HalException(new ConfigProblemBuilder(Problem.Severity.FATAL, "An account name must be " + "specified as the desired place to run your simple clustered deployment.").build());
    }
    Account account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), accountName);
    Provider.ProviderType providerType = ((Provider) account.getParent()).providerType();
    switch(providerType) {
        case KUBERNETES:
            switch(account.getProviderVersion()) {
                case V1:
                    return kubernetesV1DistributedServiceProvider;
                case V2:
                    return kubectlServiceProvider;
                default:
                    return kubernetesV1DistributedServiceProvider;
            }
        case GOOGLE:
            return googleDistributedServiceProvider;
        default:
            throw new IllegalArgumentException("No Clustered Simple Deployment for " + providerType.getName());
    }
}
Also used : Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) LocalDebianServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.debian.LocalDebianServiceProvider) LocalGitServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.git.LocalGitServiceProvider) GoogleDistributedServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.google.GoogleDistributedServiceProvider) KubectlServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubectlServiceProvider) BakeDebianServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.bake.debian.BakeDebianServiceProvider) SpinnakerServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerServiceProvider) Provider(com.netflix.spinnaker.halyard.config.model.v1.node.Provider) KubernetesV1DistributedServiceProvider(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v1.KubernetesV1DistributedServiceProvider)

Example 5 with DeploymentEnvironment

use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment in project halyard by spinnaker.

the class DeploymentEnvironmentController method setDeploymentEnvironment.

@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setDeploymentEnvironment(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawDeploymentEnvironment) {
    DeploymentEnvironment deploymentEnvironment = objectMapper.convertValue(rawDeploymentEnvironment, DeploymentEnvironment.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> deploymentEnvironment.stageLocalFiles(configPath));
    builder.setUpdate(() -> deploymentEnvironmentService.setDeploymentEnvironment(deploymentName, deploymentEnvironment));
    builder.setSeverity(severity);
    if (validate) {
        builder.setValidate(() -> deploymentEnvironmentService.validateDeploymentEnvironment(deploymentName));
    } else {
        builder.setValidate(ProblemSet::new);
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit the deployment environment");
}
Also used : Path(java.nio.file.Path) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)12 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)5 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)4 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)3 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)3 ConfigSource (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ConfigSource)3 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Names (com.netflix.frigga.Names)2 DeployKubernetesAtomicOperationDescription (com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.DeployKubernetesAtomicOperationDescription)2 KubernetesContainerDescription (com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesContainerDescription)2 KubernetesSecretVolumeSource (com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesSecretVolumeSource)2 KubernetesVolumeSource (com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesVolumeSource)2 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)2 CustomSizing (com.netflix.spinnaker.halyard.config.model.v1.node.CustomSizing)2 Providers (com.netflix.spinnaker.halyard.config.model.v1.node.Providers)2 KubernetesAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount)2 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)2