This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 522
/
params.go
163 lines (142 loc) · 7.95 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package engine
import (
"fmt"
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/aks-engine/pkg/helpers"
)
func getParameters(cs *api.ContainerService, generatorCode string, aksEngineVersion string) paramsMap {
properties := cs.Properties
location := cs.Location
parametersMap := paramsMap{}
cloudSpecConfig := cs.GetCloudSpecConfig()
// aksengine Parameters
addValue(parametersMap, "aksEngineVersion", aksEngineVersion)
// Master Parameters
addValue(parametersMap, "location", location)
// Identify Master distro
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)
}
}
addValue(parametersMap, "fqdnEndpointSuffix", cloudSpecConfig.EndpointConfig.ResourceManagerVMDNSSuffix)
addValue(parametersMap, "targetEnvironment", helpers.GetTargetEnv(cs.Location, cs.Properties.GetCustomCloudName()))
linuxProfile := properties.LinuxProfile
if linuxProfile != nil {
addValue(parametersMap, "linuxAdminUsername", linuxProfile.AdminUsername)
if linuxProfile.CustomNodesDNS != nil {
addValue(parametersMap, "dnsServer", linuxProfile.CustomNodesDNS.DNSServer)
}
}
if properties.MasterProfile != nil {
// masterEndpointDNSNamePrefix is the basis for storage account creation for k8s
addValue(parametersMap, "masterEndpointDNSNamePrefix", properties.MasterProfile.DNSPrefix)
if properties.MasterProfile.IsCustomVNET() {
addValue(parametersMap, "masterVnetSubnetID", properties.MasterProfile.VnetSubnetID)
if properties.MasterProfile.IsVirtualMachineScaleSets() {
addValue(parametersMap, "agentVnetSubnetID", properties.MasterProfile.AgentVnetSubnetID)
}
if properties.MasterProfile.VnetCidr != "" {
addValue(parametersMap, "vnetCidr", properties.MasterProfile.VnetCidr)
}
} else {
addValue(parametersMap, "masterSubnet", properties.MasterProfile.Subnet)
addValue(parametersMap, "agentSubnet", properties.MasterProfile.AgentSubnet)
if cs.Properties.FeatureFlags.IsFeatureEnabled("EnableIPv6DualStack") {
addValue(parametersMap, "masterSubnetIPv6", properties.MasterProfile.SubnetIPv6)
}
}
addValue(parametersMap, "firstConsecutiveStaticIP", properties.MasterProfile.FirstConsecutiveStaticIP)
addValue(parametersMap, "masterVMSize", properties.MasterProfile.VMSize)
if properties.MasterProfile.HasAvailabilityZones() {
addValue(parametersMap, "availabilityZones", properties.MasterProfile.AvailabilityZones)
}
}
if linuxProfile != nil {
addValue(parametersMap, "sshRSAPublicKey", linuxProfile.SSH.PublicKeys[0].KeyData)
for i, s := range 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)
}
}
}
// Kubernetes Parameters
assignKubernetesParameters(properties, parametersMap, cloudSpecConfig, generatorCode)
// 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)
if agentProfile.HasAvailabilityZones() {
addValue(parametersMap, fmt.Sprintf("%sAvailabilityZones", agentProfile.Name), agentProfile.AvailabilityZones)
}
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)
}
if !agentProfile.IsAvailabilitySets() && agentProfile.IsSpotScaleSet() {
addValue(parametersMap, fmt.Sprintf("%sScaleSetPriority", agentProfile.Name), agentProfile.ScaleSetPriority)
addValue(parametersMap, fmt.Sprintf("%sScaleSetEvictionPolicy", agentProfile.Name), agentProfile.ScaleSetEvictionPolicy)
}
// Unless distro is defined, default distro is configured by defaults#setAgentProfileDefaults
// 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.HasCustomImage() {
addValue(parametersMap, "agentWindowsSourceUrl", properties.WindowsProfile.WindowsImageSourceURL)
} else if properties.WindowsProfile.HasImageRef() {
addValue(parametersMap, "agentWindowsImageResourceGroup", properties.WindowsProfile.ImageRef.ResourceGroup)
addValue(parametersMap, "agentWindowsImageName", properties.WindowsProfile.ImageRef.Name)
} else {
addValue(parametersMap, "agentWindowsPublisher", properties.WindowsProfile.WindowsPublisher)
addValue(parametersMap, "agentWindowsOffer", properties.WindowsProfile.WindowsOffer)
addValue(parametersMap, "agentWindowsSku", properties.WindowsProfile.GetWindowsSku())
addValue(parametersMap, "agentWindowsVersion", properties.WindowsProfile.ImageVersion)
}
addValue(parametersMap, "windowsDockerVersion", properties.WindowsProfile.GetWindowsDockerVersion())
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)
}
}
addValue(parametersMap, "defaultContainerdRuntimeHandler", properties.WindowsProfile.GetWindowsDefaultRuntimeHandler())
addValue(parametersMap, "hypervRuntimeHandlers", properties.WindowsProfile.GetWindowsHypervRuntimeHandlers())
}
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
}