Search in sources :

Example 1 with KubectlServiceProvider

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubectlServiceProvider in project halyard by spinnaker.

the class KubectlDeployer method deploy.

@Override
public RemoteAction deploy(KubectlServiceProvider serviceProvider, AccountDeploymentDetails<KubernetesAccount> deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, List<SpinnakerService.Type> serviceTypes) {
    List<KubernetesV2Service> services = serviceProvider.getServicesByPriority(serviceTypes);
    services.stream().forEach((service) -> {
        ServiceSettings settings = resolvedConfiguration.getServiceSettings((SpinnakerService) service);
        if (settings.getEnabled() != null && !settings.getEnabled()) {
            return;
        }
        if (settings.getSkipLifeCycleManagement() != null && settings.getSkipLifeCycleManagement()) {
            return;
        }
        DaemonTaskHandler.newStage("Deploying " + service.getServiceName() + " with kubectl");
        KubernetesAccount account = deploymentDetails.getAccount();
        String namespaceDefinition = service.getNamespaceYaml(resolvedConfiguration);
        String serviceDefinition = service.getServiceYaml(resolvedConfiguration);
        if (!KubernetesV2Utils.exists(account, namespaceDefinition)) {
            KubernetesV2Utils.apply(account, namespaceDefinition);
        }
        if (!KubernetesV2Utils.exists(account, serviceDefinition)) {
            KubernetesV2Utils.apply(account, serviceDefinition);
        }
        String resourceDefinition = service.getResourceYaml(deploymentDetails, resolvedConfiguration);
        DaemonTaskHandler.message("Running kubectl apply on the resource definition...");
        KubernetesV2Utils.apply(account, resourceDefinition);
    });
    return new RemoteAction();
}
Also used : KubernetesAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) RemoteAction(com.netflix.spinnaker.halyard.core.RemoteAction) KubernetesV2Service(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubernetesV2Service)

Example 2 with KubectlServiceProvider

use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubectlServiceProvider 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)

Aggregations

Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)1 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)1 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)1 KubernetesAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount)1 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)1 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)1 SpinnakerServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerServiceProvider)1 BakeDebianServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.bake.debian.BakeDebianServiceProvider)1 GoogleDistributedServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.google.GoogleDistributedServiceProvider)1 KubernetesV1DistributedServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v1.KubernetesV1DistributedServiceProvider)1 KubectlServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubectlServiceProvider)1 KubernetesV2Service (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubernetesV2Service)1 LocalDebianServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.debian.LocalDebianServiceProvider)1 LocalGitServiceProvider (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.git.LocalGitServiceProvider)1