Search in sources :

Example 1 with KubernetesV2Service

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

Aggregations

KubernetesAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount)1 RemoteAction (com.netflix.spinnaker.halyard.core.RemoteAction)1 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)1 KubernetesV2Service (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubernetesV2Service)1