use of com.netflix.spinnaker.halyard.config.model.v1.node.Account 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);
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account 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);
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account 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();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account 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());
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.Account in project halyard by spinnaker.
the class ArtifactAccountController method setArtifactAccount.
@RequestMapping(value = "/account/{accountName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setArtifactAccount(@PathVariable String deploymentName, @PathVariable String providerName, @PathVariable String accountName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawArtifactAccount) {
ArtifactAccount account = objectMapper.convertValue(rawArtifactAccount, Artifacts.translateArtifactAccountType(providerName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> account.stageLocalFiles(configPath));
builder.setUpdate(() -> accountService.setArtifactAccount(deploymentName, providerName, accountName, account));
builder.setSeverity(severity);
Supplier<ProblemSet> doValidate = ProblemSet::new;
if (validate) {
doValidate = () -> accountService.validateArtifactAccount(deploymentName, providerName, account.getName());
}
builder.setValidate(doValidate);
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit the " + accountName + " artifact account");
}
Aggregations