2018-12-03 22:19:18 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
2018-12-03 23:01:25 +03:00
|
|
|
package engine
|
2018-06-01 23:28:56 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/base64"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2018-12-03 23:01:25 +03:00
|
|
|
"github.com/Azure/aks-engine/pkg/api"
|
|
|
|
"github.com/Azure/aks-engine/pkg/api/common"
|
|
|
|
"github.com/Azure/aks-engine/pkg/helpers"
|
2018-06-01 23:28:56 +03:00
|
|
|
)
|
|
|
|
|
2019-01-10 19:12:26 +03:00
|
|
|
func getParameters(cs *api.ContainerService, generatorCode string, aksEngineVersion string) (paramsMap, error) {
|
2018-06-01 23:28:56 +03:00
|
|
|
properties := cs.Properties
|
|
|
|
location := cs.Location
|
|
|
|
parametersMap := paramsMap{}
|
2018-10-05 20:26:31 +03:00
|
|
|
cloudSpecConfig := cs.GetCloudSpecConfig()
|
2018-06-01 23:28:56 +03:00
|
|
|
|
2019-01-11 22:22:33 +03:00
|
|
|
// aksengine Parameters
|
2019-01-10 19:12:26 +03:00
|
|
|
addValue(parametersMap, "aksEngineVersion", aksEngineVersion)
|
2018-06-01 23:28:56 +03:00
|
|
|
|
|
|
|
// Master Parameters
|
|
|
|
addValue(parametersMap, "location", location)
|
|
|
|
|
|
|
|
// Identify Master distro
|
2018-08-24 02:27:00 +03:00
|
|
|
if properties.MasterProfile != nil {
|
|
|
|
addValue(parametersMap, "osImageOffer", cloudSpecConfig.OSImageConfig[properties.MasterProfile.Distro].ImageOffer)
|
|
|
|
addValue(parametersMap, "osImageSKU", cloudSpecConfig.OSImageConfig[properties.MasterProfile.Distro].ImageSku)
|
|
|
|
addValue(parametersMap, "osImagePublisher", cloudSpecConfig.OSImageConfig[properties.MasterProfile.Distro].ImagePublisher)
|
|
|
|
addValue(parametersMap, "osImageVersion", cloudSpecConfig.OSImageConfig[properties.MasterProfile.Distro].ImageVersion)
|
|
|
|
if properties.MasterProfile.ImageRef != nil {
|
|
|
|
addValue(parametersMap, "osImageName", properties.MasterProfile.ImageRef.Name)
|
|
|
|
addValue(parametersMap, "osImageResourceGroup", properties.MasterProfile.ImageRef.ResourceGroup)
|
|
|
|
}
|
2018-06-01 23:28:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
addValue(parametersMap, "fqdnEndpointSuffix", cloudSpecConfig.EndpointConfig.ResourceManagerVMDNSSuffix)
|
2019-02-12 19:35:15 +03:00
|
|
|
addValue(parametersMap, "targetEnvironment", helpers.GetTargetEnv(cs.Location, cs.Properties.GetCustomCloudName()))
|
2018-06-01 23:28:56 +03:00
|
|
|
addValue(parametersMap, "linuxAdminUsername", properties.LinuxProfile.AdminUsername)
|
|
|
|
if properties.LinuxProfile.CustomSearchDomain != nil {
|
|
|
|
addValue(parametersMap, "searchDomainName", properties.LinuxProfile.CustomSearchDomain.Name)
|
|
|
|
addValue(parametersMap, "searchDomainRealmUser", properties.LinuxProfile.CustomSearchDomain.RealmUser)
|
|
|
|
addValue(parametersMap, "searchDomainRealmPassword", properties.LinuxProfile.CustomSearchDomain.RealmPassword)
|
|
|
|
}
|
2018-06-02 03:28:50 +03:00
|
|
|
if properties.LinuxProfile.CustomNodesDNS != nil {
|
|
|
|
addValue(parametersMap, "dnsServer", properties.LinuxProfile.CustomNodesDNS.DNSServer)
|
|
|
|
}
|
2018-06-01 23:28:56 +03:00
|
|
|
// masterEndpointDNSNamePrefix is the basis for storage account creation across dcos, swarm, and k8s
|
|
|
|
if properties.MasterProfile != nil {
|
|
|
|
// MasterProfile exists, uses master DNS prefix
|
|
|
|
addValue(parametersMap, "masterEndpointDNSNamePrefix", properties.MasterProfile.DNSPrefix)
|
|
|
|
} else if properties.HostedMasterProfile != nil {
|
|
|
|
// Agents only, use cluster DNS prefix
|
|
|
|
addValue(parametersMap, "masterEndpointDNSNamePrefix", properties.HostedMasterProfile.DNSPrefix)
|
|
|
|
}
|
|
|
|
if properties.MasterProfile != nil {
|
|
|
|
if properties.MasterProfile.IsCustomVNET() {
|
|
|
|
addValue(parametersMap, "masterVnetSubnetID", properties.MasterProfile.VnetSubnetID)
|
2018-09-15 03:21:55 +03:00
|
|
|
if properties.MasterProfile.IsVirtualMachineScaleSets() {
|
|
|
|
addValue(parametersMap, "agentVnetSubnetID", properties.MasterProfile.AgentVnetSubnetID)
|
|
|
|
}
|
2018-12-05 18:53:58 +03:00
|
|
|
if properties.OrchestratorProfile.IsKubernetes() {
|
2018-06-01 23:28:56 +03:00
|
|
|
addValue(parametersMap, "vnetCidr", properties.MasterProfile.VnetCidr)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
addValue(parametersMap, "masterSubnet", properties.MasterProfile.Subnet)
|
2018-09-15 03:21:55 +03:00
|
|
|
addValue(parametersMap, "agentSubnet", properties.MasterProfile.AgentSubnet)
|
2018-06-01 23:28:56 +03:00
|
|
|
}
|
|
|
|
addValue(parametersMap, "firstConsecutiveStaticIP", properties.MasterProfile.FirstConsecutiveStaticIP)
|
|
|
|
addValue(parametersMap, "masterVMSize", properties.MasterProfile.VMSize)
|
2018-09-21 00:35:38 +03:00
|
|
|
if properties.MasterProfile.HasAvailabilityZones() {
|
|
|
|
addValue(parametersMap, "availabilityZones", properties.MasterProfile.AvailabilityZones)
|
|
|
|
}
|
2018-06-01 23:28:56 +03:00
|
|
|
}
|
|
|
|
if properties.HostedMasterProfile != nil {
|
|
|
|
addValue(parametersMap, "masterSubnet", properties.HostedMasterProfile.Subnet)
|
|
|
|
}
|
|
|
|
addValue(parametersMap, "sshRSAPublicKey", properties.LinuxProfile.SSH.PublicKeys[0].KeyData)
|
|
|
|
for i, s := range properties.LinuxProfile.Secrets {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("linuxKeyVaultID%d", i), s.SourceVault.ID)
|
|
|
|
for j, c := range s.VaultCertificates {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("linuxKeyVaultID%dCertificateURL%d", i, j), c.CertificateURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Swarm and SwarmMode Parameters
|
|
|
|
if properties.OrchestratorProfile.OrchestratorType == api.Swarm || properties.OrchestratorProfile.OrchestratorType == api.SwarmMode {
|
|
|
|
var dockerEngineRepo, dockerComposeDownloadURL string
|
|
|
|
if cloudSpecConfig.DockerSpecConfig.DockerEngineRepo == "" {
|
|
|
|
dockerEngineRepo = DefaultDockerEngineRepo
|
|
|
|
} else {
|
|
|
|
dockerEngineRepo = cloudSpecConfig.DockerSpecConfig.DockerEngineRepo
|
|
|
|
}
|
|
|
|
if cloudSpecConfig.DockerSpecConfig.DockerComposeDownloadURL == "" {
|
|
|
|
dockerComposeDownloadURL = DefaultDockerComposeURL
|
|
|
|
} else {
|
|
|
|
dockerComposeDownloadURL = cloudSpecConfig.DockerSpecConfig.DockerComposeDownloadURL
|
|
|
|
}
|
|
|
|
addValue(parametersMap, "dockerEngineDownloadRepo", dockerEngineRepo)
|
|
|
|
addValue(parametersMap, "dockerComposeDownloadURL", dockerComposeDownloadURL)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Kubernetes Parameters
|
2018-12-05 18:53:58 +03:00
|
|
|
if properties.OrchestratorProfile.IsKubernetes() {
|
2018-06-01 23:28:56 +03:00
|
|
|
assignKubernetesParameters(properties, parametersMap, cloudSpecConfig, generatorCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.HasPrefix(properties.OrchestratorProfile.OrchestratorType, api.DCOS) {
|
|
|
|
dcosBootstrapURL := cloudSpecConfig.DCOSSpecConfig.DCOS188BootstrapDownloadURL
|
|
|
|
dcosWindowsBootstrapURL := cloudSpecConfig.DCOSSpecConfig.DCOSWindowsBootstrapDownloadURL
|
|
|
|
dcosRepositoryURL := cloudSpecConfig.DCOSSpecConfig.DcosRepositoryURL
|
|
|
|
dcosClusterPackageListID := cloudSpecConfig.DCOSSpecConfig.DcosClusterPackageListID
|
|
|
|
dcosProviderPackageID := cloudSpecConfig.DCOSSpecConfig.DcosProviderPackageID
|
|
|
|
|
2019-03-20 18:44:24 +03:00
|
|
|
if properties.OrchestratorProfile.OrchestratorType == api.DCOS {
|
2018-06-01 23:28:56 +03:00
|
|
|
switch properties.OrchestratorProfile.OrchestratorVersion {
|
|
|
|
case common.DCOSVersion1Dot8Dot8:
|
|
|
|
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS188BootstrapDownloadURL
|
|
|
|
case common.DCOSVersion1Dot9Dot0:
|
|
|
|
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS190BootstrapDownloadURL
|
|
|
|
case common.DCOSVersion1Dot9Dot8:
|
|
|
|
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS198BootstrapDownloadURL
|
|
|
|
case common.DCOSVersion1Dot10Dot0:
|
|
|
|
dcosBootstrapURL = cloudSpecConfig.DCOSSpecConfig.DCOS110BootstrapDownloadURL
|
|
|
|
default:
|
|
|
|
dcosBootstrapURL = getDCOSDefaultBootstrapInstallerURL(properties.OrchestratorProfile)
|
2018-06-13 00:33:30 +03:00
|
|
|
dcosWindowsBootstrapURL = getDCOSDefaultWindowsBootstrapInstallerURL(properties.OrchestratorProfile)
|
2018-06-01 23:28:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if properties.OrchestratorProfile.DcosConfig != nil {
|
|
|
|
if properties.OrchestratorProfile.DcosConfig.DcosWindowsBootstrapURL != "" {
|
|
|
|
dcosWindowsBootstrapURL = properties.OrchestratorProfile.DcosConfig.DcosWindowsBootstrapURL
|
|
|
|
}
|
|
|
|
if properties.OrchestratorProfile.DcosConfig.DcosBootstrapURL != "" {
|
|
|
|
dcosBootstrapURL = properties.OrchestratorProfile.DcosConfig.DcosBootstrapURL
|
|
|
|
}
|
|
|
|
if len(properties.OrchestratorProfile.DcosConfig.Registry) > 0 {
|
|
|
|
addValue(parametersMap, "registry", properties.OrchestratorProfile.DcosConfig.Registry)
|
|
|
|
addValue(parametersMap, "registryKey", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", properties.OrchestratorProfile.DcosConfig.RegistryUser, properties.OrchestratorProfile.DcosConfig.RegistryPass))))
|
|
|
|
}
|
|
|
|
if properties.OrchestratorProfile.DcosConfig.DcosRepositoryURL != "" {
|
|
|
|
dcosRepositoryURL = properties.OrchestratorProfile.DcosConfig.DcosRepositoryURL
|
|
|
|
} else {
|
|
|
|
dcosRepositoryURL = getDCOSDefaultRepositoryURL(
|
|
|
|
properties.OrchestratorProfile.OrchestratorType,
|
|
|
|
properties.OrchestratorProfile.OrchestratorVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
if properties.OrchestratorProfile.DcosConfig.DcosClusterPackageListID != "" {
|
|
|
|
dcosClusterPackageListID = properties.OrchestratorProfile.DcosConfig.DcosClusterPackageListID
|
|
|
|
}
|
|
|
|
|
|
|
|
if properties.OrchestratorProfile.DcosConfig.DcosProviderPackageID != "" {
|
|
|
|
dcosProviderPackageID = properties.OrchestratorProfile.DcosConfig.DcosProviderPackageID
|
|
|
|
} else {
|
|
|
|
dcosProviderPackageID = getDCOSDefaultProviderPackageGUID(
|
|
|
|
properties.OrchestratorProfile.OrchestratorType,
|
|
|
|
properties.OrchestratorProfile.OrchestratorVersion,
|
|
|
|
properties.MasterProfile.Count)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addValue(parametersMap, "dcosBootstrapURL", dcosBootstrapURL)
|
|
|
|
addValue(parametersMap, "dcosWindowsBootstrapURL", dcosWindowsBootstrapURL)
|
|
|
|
addValue(parametersMap, "dcosRepositoryURL", dcosRepositoryURL)
|
|
|
|
addValue(parametersMap, "dcosClusterPackageListID", dcosClusterPackageListID)
|
|
|
|
addValue(parametersMap, "dcosProviderPackageID", dcosProviderPackageID)
|
|
|
|
|
2018-11-01 00:33:27 +03:00
|
|
|
if properties.OrchestratorProfile.DcosConfig != nil && properties.OrchestratorProfile.DcosConfig.BootstrapProfile != nil {
|
2018-06-01 23:28:56 +03:00
|
|
|
addValue(parametersMap, "bootstrapStaticIP", properties.OrchestratorProfile.DcosConfig.BootstrapProfile.StaticIP)
|
|
|
|
addValue(parametersMap, "bootstrapVMSize", properties.OrchestratorProfile.DcosConfig.BootstrapProfile.VMSize)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Agent parameters
|
|
|
|
for _, agentProfile := range properties.AgentPoolProfiles {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sCount", agentProfile.Name), agentProfile.Count)
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sVMSize", agentProfile.Name), agentProfile.VMSize)
|
2018-08-30 23:46:49 +03:00
|
|
|
if agentProfile.HasAvailabilityZones() {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sAvailabilityZones", agentProfile.Name), agentProfile.AvailabilityZones)
|
|
|
|
}
|
2018-06-01 23:28:56 +03:00
|
|
|
if agentProfile.IsCustomVNET() {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sVnetSubnetID", agentProfile.Name), agentProfile.VnetSubnetID)
|
|
|
|
} else {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sSubnet", agentProfile.Name), agentProfile.Subnet)
|
|
|
|
}
|
|
|
|
if len(agentProfile.Ports) > 0 {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sEndpointDNSNamePrefix", agentProfile.Name), agentProfile.DNSPrefix)
|
|
|
|
}
|
|
|
|
|
2018-09-08 02:54:38 +03:00
|
|
|
// Unless distro is defined, default distro is configured by defaults#setAgentProfileDefaults
|
2018-06-01 23:28:56 +03:00
|
|
|
// Ignores Windows OS
|
|
|
|
if !(agentProfile.OSType == api.Windows) {
|
|
|
|
if agentProfile.ImageRef != nil {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sosImageName", agentProfile.Name), agentProfile.ImageRef.Name)
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sosImageResourceGroup", agentProfile.Name), agentProfile.ImageRef.ResourceGroup)
|
|
|
|
}
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sosImageOffer", agentProfile.Name), cloudSpecConfig.OSImageConfig[agentProfile.Distro].ImageOffer)
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sosImageSKU", agentProfile.Name), cloudSpecConfig.OSImageConfig[agentProfile.Distro].ImageSku)
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sosImagePublisher", agentProfile.Name), cloudSpecConfig.OSImageConfig[agentProfile.Distro].ImagePublisher)
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sosImageVersion", agentProfile.Name), cloudSpecConfig.OSImageConfig[agentProfile.Distro].ImageVersion)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Windows parameters
|
|
|
|
if properties.HasWindows() {
|
|
|
|
addValue(parametersMap, "windowsAdminUsername", properties.WindowsProfile.AdminUsername)
|
|
|
|
addSecret(parametersMap, "windowsAdminPassword", properties.WindowsProfile.AdminPassword, false)
|
|
|
|
if properties.WindowsProfile.ImageVersion != "" {
|
|
|
|
addValue(parametersMap, "agentWindowsVersion", properties.WindowsProfile.ImageVersion)
|
|
|
|
}
|
|
|
|
if properties.WindowsProfile.WindowsImageSourceURL != "" {
|
|
|
|
addValue(parametersMap, "agentWindowsSourceUrl", properties.WindowsProfile.WindowsImageSourceURL)
|
|
|
|
}
|
|
|
|
if properties.WindowsProfile.WindowsPublisher != "" {
|
|
|
|
addValue(parametersMap, "agentWindowsPublisher", properties.WindowsProfile.WindowsPublisher)
|
|
|
|
}
|
|
|
|
if properties.WindowsProfile.WindowsOffer != "" {
|
|
|
|
addValue(parametersMap, "agentWindowsOffer", properties.WindowsProfile.WindowsOffer)
|
|
|
|
}
|
2018-10-25 21:37:19 +03:00
|
|
|
|
2018-11-30 00:07:51 +03:00
|
|
|
addValue(parametersMap, "agentWindowsSku", properties.WindowsProfile.GetWindowsSku())
|
2018-10-25 21:37:19 +03:00
|
|
|
addValue(parametersMap, "windowsDockerVersion", properties.WindowsProfile.GetWindowsDockerVersion())
|
|
|
|
|
2018-06-01 23:28:56 +03:00
|
|
|
for i, s := range properties.WindowsProfile.Secrets {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("windowsKeyVaultID%d", i), s.SourceVault.ID)
|
|
|
|
for j, c := range s.VaultCertificates {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("windowsKeyVaultID%dCertificateURL%d", i, j), c.CertificateURL)
|
|
|
|
addValue(parametersMap, fmt.Sprintf("windowsKeyVaultID%dCertificateStore%d", i, j), c.CertificateStore)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, extension := range properties.ExtensionProfiles {
|
|
|
|
if extension.ExtensionParametersKeyVaultRef != nil {
|
|
|
|
addKeyvaultReference(parametersMap, fmt.Sprintf("%sParameters", extension.Name),
|
|
|
|
extension.ExtensionParametersKeyVaultRef.VaultID,
|
|
|
|
extension.ExtensionParametersKeyVaultRef.SecretName,
|
|
|
|
extension.ExtensionParametersKeyVaultRef.SecretVersion)
|
|
|
|
} else {
|
|
|
|
addValue(parametersMap, fmt.Sprintf("%sParameters", extension.Name), extension.ExtensionParameters)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parametersMap, nil
|
|
|
|
}
|