зеркало из https://github.com/Azure/acs-engine.git
Refactor: Moving set defaults logic from package acsengine to package api (#3974)
This commit is contained in:
Родитель
168af82dec
Коммит
6579278de9
|
@ -431,7 +431,13 @@ func (dc *deployCmd) run() error {
|
|||
log.Fatalf("failed to initialize template generator: %s", err.Error())
|
||||
}
|
||||
|
||||
template, parameters, certsgenerated, err := templateGenerator.GenerateTemplate(dc.containerService, acsengine.DefaultGeneratorCode, false, false, BuildTag)
|
||||
certsgenerated, err := dc.containerService.SetPropertiesDefaults(false, false)
|
||||
if err != nil {
|
||||
log.Fatalf("error in SetPropertiesDefaults template %s: %s", dc.apimodelPath, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
template, parameters, err := templateGenerator.GenerateTemplate(dc.containerService, acsengine.DefaultGeneratorCode, BuildTag)
|
||||
if err != nil {
|
||||
log.Fatalf("error generating template %s: %s", dc.apimodelPath, err.Error())
|
||||
os.Exit(1)
|
||||
|
|
|
@ -179,7 +179,12 @@ func (gc *generateCmd) run() error {
|
|||
log.Fatalf("failed to initialize template generator: %s", err.Error())
|
||||
}
|
||||
|
||||
template, parameters, certsGenerated, err := templateGenerator.GenerateTemplate(gc.containerService, acsengine.DefaultGeneratorCode, false, false, BuildTag)
|
||||
certsGenerated, err := gc.containerService.SetPropertiesDefaults(false, false)
|
||||
if err != nil {
|
||||
log.Fatalf("error in SetPropertiesDefaults template %s: %s", gc.apimodelPath, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
template, parameters, err := templateGenerator.GenerateTemplate(gc.containerService, acsengine.DefaultGeneratorCode, BuildTag)
|
||||
if err != nil {
|
||||
log.Fatalf("error generating template %s: %s", gc.apimodelPath, err.Error())
|
||||
os.Exit(1)
|
||||
|
|
|
@ -351,7 +351,12 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
|
|||
|
||||
sc.containerService.Properties.AgentPoolProfiles = []*api.AgentPoolProfile{sc.agentPool}
|
||||
|
||||
template, parameters, _, err := templateGenerator.GenerateTemplate(sc.containerService, acsengine.DefaultGeneratorCode, false, true, BuildTag)
|
||||
_, err = sc.containerService.SetPropertiesDefaults(false, true)
|
||||
if err != nil {
|
||||
log.Fatalf("error in SetPropertiesDefaults template %s: %s", sc.apiModelPath, err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
template, parameters, err := templateGenerator.GenerateTemplate(sc.containerService, acsengine.DefaultGeneratorCode, BuildTag)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error generating template %s", sc.apiModelPath)
|
||||
}
|
||||
|
|
|
@ -1,44 +1,8 @@
|
|||
package acsengine
|
||||
|
||||
const (
|
||||
// DefaultOpenShiftMasterSubnet is the default value for master subnet for Openshift.
|
||||
DefaultOpenShiftMasterSubnet = "10.0.0.0/24"
|
||||
// DefaultOpenShiftFirstConsecutiveStaticIP is the default static ip address for master 0 for Openshift.
|
||||
DefaultOpenShiftFirstConsecutiveStaticIP = "10.0.0.11"
|
||||
// DefaultMasterSubnet specifies the default master subnet for DCOS or Swarm
|
||||
DefaultMasterSubnet = "172.16.0.0/24"
|
||||
// DefaultFirstConsecutiveStaticIP specifies the static IP address on master 0 for DCOS or Swarm
|
||||
DefaultFirstConsecutiveStaticIP = "172.16.0.5"
|
||||
// DefaultSwarmWindowsMasterSubnet specifies the default master subnet for a Swarm Windows cluster
|
||||
DefaultSwarmWindowsMasterSubnet = "192.168.255.0/24"
|
||||
// DefaultSwarmWindowsFirstConsecutiveStaticIP specifies the static IP address on master 0 for a Swarm WIndows cluster
|
||||
DefaultSwarmWindowsFirstConsecutiveStaticIP = "192.168.255.5"
|
||||
// DefaultDCOSMasterSubnet specifies the default master subnet for a DCOS cluster
|
||||
DefaultDCOSMasterSubnet = "192.168.255.0/24"
|
||||
// DefaultDCOSFirstConsecutiveStaticIP specifies the static IP address on master 0 for a DCOS cluster
|
||||
DefaultDCOSFirstConsecutiveStaticIP = "192.168.255.5"
|
||||
// DefaultDCOSBootstrapStaticIP specifies the static IP address on bootstrap for a DCOS cluster
|
||||
DefaultDCOSBootstrapStaticIP = "192.168.255.240"
|
||||
// DefaultKubernetesMasterSubnet specifies the default subnet for masters and agents.
|
||||
// Except when master VMSS is used, this specifies the default subnet for masters.
|
||||
DefaultKubernetesMasterSubnet = "10.240.0.0/16"
|
||||
// DefaultKubernetesClusterSubnet specifies the default subnet for pods.
|
||||
DefaultKubernetesClusterSubnet = "10.244.0.0/16"
|
||||
// DefaultDockerBridgeSubnet specifies the default subnet for the docker bridge network for masters and agents.
|
||||
DefaultDockerBridgeSubnet = "172.17.0.1/16"
|
||||
// DefaultAgentSubnetTemplate specifies a default agent subnet
|
||||
DefaultAgentSubnetTemplate = "10.%d.0.0/16"
|
||||
// DefaultKubernetesSubnet specifies the default subnet used for all masters, agents and pods
|
||||
// when VNET integration is enabled.
|
||||
DefaultKubernetesSubnet = "10.240.0.0/12"
|
||||
// DefaultVNETCIDR is the default CIDR block for the VNET
|
||||
DefaultVNETCIDR = "10.0.0.0/8"
|
||||
// DefaultKubernetesMaxPods is the maximum number of pods to run on a node.
|
||||
DefaultKubernetesMaxPods = 110
|
||||
// DefaultKubernetesMaxPodsVNETIntegrated is the maximum number of pods to run on a node when VNET integration is enabled.
|
||||
DefaultKubernetesMaxPodsVNETIntegrated = 30
|
||||
// DefaultKubernetesClusterDomain is the dns suffix used in the cluster (used as a SAN in the PKI generation)
|
||||
DefaultKubernetesClusterDomain = "cluster.local"
|
||||
// DefaultInternalLbStaticIPOffset specifies the offset of the internal LoadBalancer's IP
|
||||
// address relative to the first consecutive Kubernetes static IP
|
||||
DefaultInternalLbStaticIPOffset = 10
|
||||
|
@ -56,34 +20,6 @@ const (
|
|||
NetworkPluginKubenet = "kubenet"
|
||||
// NetworkPluginFlannel is the string expression for flannel network policy config option
|
||||
NetworkPluginFlannel = "flannel"
|
||||
// DefaultNetworkPlugin defines the network plugin to use by default
|
||||
DefaultNetworkPlugin = NetworkPluginKubenet
|
||||
// DefaultNetworkPolicy defines the network policy implementation to use by default
|
||||
DefaultNetworkPolicy = ""
|
||||
// DefaultNetworkPluginWindows defines the network plugin implementation to use by default for clusters with Windows agent pools
|
||||
DefaultNetworkPluginWindows = NetworkPluginKubenet
|
||||
// DefaultNetworkPolicyWindows defines the network policy implementation to use by default for clusters with Windows agent pools
|
||||
DefaultNetworkPolicyWindows = ""
|
||||
// DefaultContainerRuntime is docker
|
||||
DefaultContainerRuntime = "docker"
|
||||
// DefaultKubernetesNodeStatusUpdateFrequency is 10s, see --node-status-update-frequency at https://kubernetes.io/docs/admin/kubelet/
|
||||
DefaultKubernetesNodeStatusUpdateFrequency = "10s"
|
||||
// DefaultKubernetesHardEvictionThreshold is memory.available<100Mi,nodefs.available<10%,nodefs.inodesFree<5%, see --eviction-hard at https://kubernetes.io/docs/admin/kubelet/
|
||||
DefaultKubernetesHardEvictionThreshold = "memory.available<100Mi,nodefs.available<10%,nodefs.inodesFree<5%"
|
||||
// DefaultKubernetesCtrlMgrNodeMonitorGracePeriod is 40s, see --node-monitor-grace-period at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrNodeMonitorGracePeriod = "40s"
|
||||
// DefaultKubernetesCtrlMgrPodEvictionTimeout is 5m0s, see --pod-eviction-timeout at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrPodEvictionTimeout = "5m0s"
|
||||
// DefaultKubernetesCtrlMgrRouteReconciliationPeriod is 10s, see --route-reconciliation-period at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrRouteReconciliationPeriod = "10s"
|
||||
// DefaultKubernetesCtrlMgrTerminatedPodGcThreshold is set to 5000, see --terminated-pod-gc-threshold at https://kubernetes.io/docs/admin/kube-controller-manager/ and https://github.com/kubernetes/kubernetes/issues/22680
|
||||
DefaultKubernetesCtrlMgrTerminatedPodGcThreshold = "5000"
|
||||
// DefaultKubernetesCtrlMgrUseSvcAccountCreds is "true", see --use-service-account-credentials at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrUseSvcAccountCreds = "false"
|
||||
// DefaultKubernetesCloudProviderBackoff is false to disable cloudprovider backoff implementation for API calls
|
||||
DefaultKubernetesCloudProviderBackoff = true
|
||||
// DefaultKubernetesCloudProviderRateLimit is false to disable cloudprovider rate limiting implementation for API calls
|
||||
DefaultKubernetesCloudProviderRateLimit = true
|
||||
// DefaultKubeHeapsterDeploymentAddonName is the name of the kube-heapster-deployment addon
|
||||
DefaultKubeHeapsterDeploymentAddonName = "kube-heapster-deployment"
|
||||
// DefaultKubeDNSDeploymentAddonName is the name of the kube-dns-deployment addon
|
||||
|
@ -132,28 +68,8 @@ const (
|
|||
DefaultKeyVaultFlexVolumeAddonName = "keyvault-flexvolume"
|
||||
// DefaultELBSVCAddonName is the name of the elb service addon deployment
|
||||
DefaultELBSVCAddonName = "elb-svc"
|
||||
// DefaultKubernetesDNSServiceIP specifies the IP address that kube-dns
|
||||
// listens on by default. must by in the default Service CIDR range.
|
||||
DefaultKubernetesDNSServiceIP = "10.0.0.10"
|
||||
// DefaultKubernetesServiceCIDR specifies the IP subnet that kubernetes will
|
||||
// create Service IPs within.
|
||||
DefaultKubernetesServiceCIDR = "10.0.0.0/16"
|
||||
//DefaultKubernetesGCHighThreshold specifies the value for for the image-gc-high-threshold kubelet flag
|
||||
DefaultKubernetesGCHighThreshold = 85
|
||||
//DefaultKubernetesGCLowThreshold specifies the value for the image-gc-low-threshold kubelet flag
|
||||
DefaultKubernetesGCLowThreshold = 80
|
||||
// DefaultGeneratorCode specifies the source generator of the cluster template.
|
||||
DefaultGeneratorCode = "acsengine"
|
||||
// DefaultEtcdVersion specifies the default etcd version to install
|
||||
DefaultEtcdVersion = "3.2.23"
|
||||
// DefaultEtcdDiskSize specifies the default size for Kubernetes master etcd disk volumes in GB
|
||||
DefaultEtcdDiskSize = "256"
|
||||
// DefaultEtcdDiskSizeGT3Nodes = size for Kubernetes master etcd disk volumes in GB if > 3 nodes
|
||||
DefaultEtcdDiskSizeGT3Nodes = "512"
|
||||
// DefaultEtcdDiskSizeGT10Nodes = size for Kubernetes master etcd disk volumes in GB if > 10 nodes
|
||||
DefaultEtcdDiskSizeGT10Nodes = "1024"
|
||||
// DefaultEtcdDiskSizeGT20Nodes = size for Kubernetes master etcd disk volumes in GB if > 20 nodes
|
||||
DefaultEtcdDiskSizeGT20Nodes = "2048"
|
||||
// DefaultReschedulerAddonName is the name of the rescheduler addon deployment
|
||||
DefaultReschedulerAddonName = "rescheduler"
|
||||
// DefaultMetricsServerAddonName is the name of the kubernetes Metrics server addon deployment
|
||||
|
@ -174,31 +90,10 @@ const (
|
|||
DefaultMasterEtcdServerPort = 2380
|
||||
// DefaultMasterEtcdClientPort is the default etcd client port for Kubernetes master nodes
|
||||
DefaultMasterEtcdClientPort = 2379
|
||||
// DefaultKubeletEventQPS is 0, see --event-qps at https://kubernetes.io/docs/reference/generated/kubelet/
|
||||
DefaultKubeletEventQPS = "0"
|
||||
// DefaultKubeletCadvisorPort is 0, see --cadvisor-port at https://kubernetes.io/docs/reference/generated/kubelet/
|
||||
DefaultKubeletCadvisorPort = "0"
|
||||
// DefaultJumpboxDiskSize specifies the default size for private cluster jumpbox OS disk in GB
|
||||
DefaultJumpboxDiskSize = 30
|
||||
// DefaultJumpboxUsername specifies the default admin username for the private cluster jumpbox
|
||||
DefaultJumpboxUsername = "azureuser"
|
||||
// DefaultKubeletPodMaxPIDs specifies the default max pid authorized by pods
|
||||
DefaultKubeletPodMaxPIDs = 100
|
||||
// DefaultKubernetesAgentSubnetVMSS specifies the default subnet for agents when master is VMSS
|
||||
DefaultKubernetesAgentSubnetVMSS = "10.248.0.0/13"
|
||||
// DefaultUserAssignedID specifies the default name for the user assigned identity
|
||||
DefaultUserAssignedID = "acsenginetestid"
|
||||
)
|
||||
|
||||
const (
|
||||
// DCOSMaster represents the master node type
|
||||
DCOSMaster DCOSNodeType = "DCOSMaster"
|
||||
// DCOSPrivateAgent represents the private agent node type
|
||||
DCOSPrivateAgent DCOSNodeType = "DCOSPrivateAgent"
|
||||
// DCOSPublicAgent represents the public agent node type
|
||||
DCOSPublicAgent DCOSNodeType = "DCOSPublicAgent"
|
||||
)
|
||||
|
||||
const (
|
||||
//DefaultExtensionsRootURL Root URL for extensions
|
||||
DefaultExtensionsRootURL = "https://raw.githubusercontent.com/Azure/acs-engine/master/"
|
||||
|
@ -305,8 +200,5 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
azurePublicCloud = "AzurePublicCloud"
|
||||
azureChinaCloud = "AzureChinaCloud"
|
||||
azureGermanCloud = "AzureGermanCloud"
|
||||
azureUSGovernmentCloud = "AzureUSGovernmentCloud"
|
||||
azurePublicCloud = "AzurePublicCloud"
|
||||
)
|
||||
|
|
|
@ -76,7 +76,7 @@ func GenerateKubeConfig(properties *api.Properties, location string) (string, er
|
|||
kubeconfig = strings.Replace(kubeconfig, "{{WrapAsVerbatim \"reference(concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))).dnsSettings.fqdn\"}}", properties.MasterProfile.FirstConsecutiveStaticIP, -1)
|
||||
}
|
||||
} else {
|
||||
kubeconfig = strings.Replace(kubeconfig, "{{WrapAsVerbatim \"reference(concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))).dnsSettings.fqdn\"}}", FormatAzureProdFQDN(properties.MasterProfile.DNSPrefix, location), -1)
|
||||
kubeconfig = strings.Replace(kubeconfig, "{{WrapAsVerbatim \"reference(concat('Microsoft.Network/publicIPAddresses/', variables('masterPublicIPAddressName'))).dnsSettings.fqdn\"}}", api.FormatAzureProdFQDNByLocation(properties.MasterProfile.DNSPrefix, location), -1)
|
||||
}
|
||||
kubeconfig = strings.Replace(kubeconfig, "{{WrapAsVariable \"resourceGroup\"}}", properties.MasterProfile.DNSPrefix, -1)
|
||||
|
||||
|
@ -102,31 +102,6 @@ func GenerateKubeConfig(properties *api.Properties, location string) (string, er
|
|||
return kubeconfig, nil
|
||||
}
|
||||
|
||||
// formatAzureProdFQDNs constructs all possible Azure prod fqdn
|
||||
func formatAzureProdFQDNs(fqdnPrefix string) []string {
|
||||
var fqdns []string
|
||||
for _, location := range AzureLocations {
|
||||
fqdns = append(fqdns, FormatAzureProdFQDN(fqdnPrefix, location))
|
||||
}
|
||||
return fqdns
|
||||
}
|
||||
|
||||
// FormatAzureProdFQDN constructs an Azure prod fqdn
|
||||
func FormatAzureProdFQDN(fqdnPrefix string, location string) string {
|
||||
var FQDNFormat string
|
||||
switch helpers.GetCloudTargetEnv(location) {
|
||||
case azureChinaCloud:
|
||||
FQDNFormat = api.AzureChinaCloudSpec.EndpointConfig.ResourceManagerVMDNSSuffix
|
||||
case azureGermanCloud:
|
||||
FQDNFormat = api.AzureGermanCloudSpec.EndpointConfig.ResourceManagerVMDNSSuffix
|
||||
case azureUSGovernmentCloud:
|
||||
FQDNFormat = api.AzureUSGovernmentCloud.EndpointConfig.ResourceManagerVMDNSSuffix
|
||||
default:
|
||||
FQDNFormat = api.AzureCloudSpec.EndpointConfig.ResourceManagerVMDNSSuffix
|
||||
}
|
||||
return fmt.Sprintf("%s.%s."+FQDNFormat, fqdnPrefix, location)
|
||||
}
|
||||
|
||||
// validateDistro checks if the requested orchestrator type is supported on the requested Linux distro.
|
||||
func validateDistro(cs *api.ContainerService) bool {
|
||||
// Check Master distro
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"io/ioutil"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -73,7 +72,9 @@ func TestExpected(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
|
||||
armTemplate, params, certsGenerated, err := templateGenerator.GenerateTemplate(containerService, DefaultGeneratorCode, false, false, TestACSEngineVersion)
|
||||
certsGenerated, err := containerService.SetPropertiesDefaults(false, false)
|
||||
|
||||
armTemplate, params, err := templateGenerator.GenerateTemplate(containerService, DefaultGeneratorCode, TestACSEngineVersion)
|
||||
if err != nil {
|
||||
t.Error(errors.Errorf("error in file %s: %s", tuple.APIModelFilename, err.Error()))
|
||||
continue
|
||||
|
@ -97,7 +98,8 @@ func TestExpected(t *testing.T) {
|
|||
}
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
armTemplate, params, certsGenerated, err := templateGenerator.GenerateTemplate(containerService, DefaultGeneratorCode, false, false, TestACSEngineVersion)
|
||||
certsGenerated, err = containerService.SetPropertiesDefaults(false, false)
|
||||
armTemplate, params, err := templateGenerator.GenerateTemplate(containerService, DefaultGeneratorCode, TestACSEngineVersion)
|
||||
if err != nil {
|
||||
t.Error(errors.Errorf("error in file %s: %s", tuple.APIModelFilename, err.Error()))
|
||||
continue
|
||||
|
@ -290,7 +292,8 @@ func TestTemplateOutputPresence(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Failed to load container service from file: %v", err)
|
||||
}
|
||||
armTemplate, _, _, err := templateGenerator.GenerateTemplate(containerService, DefaultGeneratorCode, false, false, TestACSEngineVersion)
|
||||
containerService.SetPropertiesDefaults(false, false)
|
||||
armTemplate, _, err := templateGenerator.GenerateTemplate(containerService, DefaultGeneratorCode, TestACSEngineVersion)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to generate arm template: %v", err)
|
||||
}
|
||||
|
@ -557,64 +560,3 @@ func TestGenerateKubeConfig(t *testing.T) {
|
|||
t.Fatalf("Expected an error result from nil Properties child properties")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatAzureProdFQDN(t *testing.T) {
|
||||
dnsPrefix := "santest"
|
||||
|
||||
actual := formatAzureProdFQDNs(dnsPrefix)
|
||||
|
||||
expected := []string{
|
||||
"santest.australiacentral.cloudapp.azure.com",
|
||||
"santest.australiacentral2.cloudapp.azure.com",
|
||||
"santest.australiaeast.cloudapp.azure.com",
|
||||
"santest.australiasoutheast.cloudapp.azure.com",
|
||||
"santest.brazilsouth.cloudapp.azure.com",
|
||||
"santest.canadacentral.cloudapp.azure.com",
|
||||
"santest.canadaeast.cloudapp.azure.com",
|
||||
"santest.centralindia.cloudapp.azure.com",
|
||||
"santest.centralus.cloudapp.azure.com",
|
||||
"santest.centraluseuap.cloudapp.azure.com",
|
||||
"santest.chinaeast.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinaeast2.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth2.cloudapp.chinacloudapi.cn",
|
||||
"santest.eastasia.cloudapp.azure.com",
|
||||
"santest.eastus.cloudapp.azure.com",
|
||||
"santest.eastus2.cloudapp.azure.com",
|
||||
"santest.eastus2euap.cloudapp.azure.com",
|
||||
"santest.francecentral.cloudapp.azure.com",
|
||||
"santest.francesouth.cloudapp.azure.com",
|
||||
"santest.japaneast.cloudapp.azure.com",
|
||||
"santest.japanwest.cloudapp.azure.com",
|
||||
"santest.koreacentral.cloudapp.azure.com",
|
||||
"santest.koreasouth.cloudapp.azure.com",
|
||||
"santest.northcentralus.cloudapp.azure.com",
|
||||
"santest.northeurope.cloudapp.azure.com",
|
||||
"santest.southcentralus.cloudapp.azure.com",
|
||||
"santest.southeastasia.cloudapp.azure.com",
|
||||
"santest.southindia.cloudapp.azure.com",
|
||||
"santest.uksouth.cloudapp.azure.com",
|
||||
"santest.ukwest.cloudapp.azure.com",
|
||||
"santest.westcentralus.cloudapp.azure.com",
|
||||
"santest.westeurope.cloudapp.azure.com",
|
||||
"santest.westindia.cloudapp.azure.com",
|
||||
"santest.westus.cloudapp.azure.com",
|
||||
"santest.westus2.cloudapp.azure.com",
|
||||
"santest.chinaeast.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth2.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinaeast2.cloudapp.chinacloudapi.cn",
|
||||
"santest.germanycentral.cloudapp.microsoftazure.de",
|
||||
"santest.germanynortheast.cloudapp.microsoftazure.de",
|
||||
"santest.usgovvirginia.cloudapp.usgovcloudapi.net",
|
||||
"santest.usgoviowa.cloudapp.usgovcloudapi.net",
|
||||
"santest.usgovarizona.cloudapp.usgovcloudapi.net",
|
||||
"santest.usgovtexas.cloudapp.usgovcloudapi.net",
|
||||
"santest.francecentral.cloudapp.azure.com",
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("expected formatted fqdns %s, but got %s", expected, actual)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ func (w *ArtifactWriter) WriteTLSArtifacts(containerService *api.ContainerServic
|
|||
if containerService.Location != "" {
|
||||
locations = []string{containerService.Location}
|
||||
} else {
|
||||
locations = AzureLocations
|
||||
locations = helpers.GetAzureLocations()
|
||||
}
|
||||
|
||||
for _, location := range locations {
|
||||
|
|
|
@ -6,12 +6,14 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
"github.com/Azure/acs-engine/pkg/i18n"
|
||||
)
|
||||
|
||||
func TestWriteTLSArtifacts(t *testing.T) {
|
||||
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 1, 2, true)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.7.12", 1, 2, true)
|
||||
writer := &ArtifactWriter{
|
||||
Translator: &i18n.Translator{
|
||||
Locale: nil,
|
||||
|
@ -75,7 +77,7 @@ func TestWriteTLSArtifacts(t *testing.T) {
|
|||
t.Fatalf("unexpected error trying to write TLS artifacts: %s", err.Error())
|
||||
}
|
||||
|
||||
for _, region := range AzureLocations {
|
||||
for _, region := range helpers.GetAzureLocations() {
|
||||
if _, err := os.Stat(kubeDir + "/" + "kubeconfig." + region + ".json"); os.IsNotExist(err) {
|
||||
t.Fatalf("expected kubeconfig for region %s to be generated by WriteTLSArtifacts", region)
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ func getParameters(cs *api.ContainerService, generatorCode string, acsengineVers
|
|||
k8sVersion := properties.OrchestratorProfile.OrchestratorVersion
|
||||
kubeBinariesSASURL := properties.OrchestratorProfile.KubernetesConfig.CustomWindowsPackageURL
|
||||
if kubeBinariesSASURL == "" {
|
||||
kubeBinariesSASURL = cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase + KubeConfigs[k8sVersion]["windowszip"]
|
||||
kubeBinariesSASURL = cloudSpecConfig.KubernetesSpecConfig.KubeBinariesSASURLBase + api.K8sComponentsByVersionMap[k8sVersion]["windowszip"]
|
||||
}
|
||||
|
||||
addValue(parametersMap, "kubeBinariesSASURL", kubeBinariesSASURL)
|
||||
|
|
|
@ -19,15 +19,15 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
|
||||
if orchestratorProfile.IsKubernetes() ||
|
||||
orchestratorProfile.IsOpenShift() {
|
||||
k8sVersion := orchestratorProfile.OrchestratorVersion
|
||||
k8sComponents := api.K8sComponentsByVersionMap[orchestratorProfile.OrchestratorVersion]
|
||||
|
||||
dockerEngineVersion := KubeConfigs[k8sVersion]["dockerEngineVersion"]
|
||||
dockerEngineVersion := k8sComponents["dockerEngineVersion"]
|
||||
|
||||
kubernetesConfig := orchestratorProfile.KubernetesConfig
|
||||
|
||||
if kubernetesConfig != nil {
|
||||
if helpers.IsTrueBoolPointer(kubernetesConfig.UseCloudControllerManager) {
|
||||
kubernetesCcmSpec := kubernetesConfig.KubernetesImageBase + KubeConfigs[k8sVersion]["ccm"]
|
||||
kubernetesCcmSpec := kubernetesConfig.KubernetesImageBase + k8sComponents["ccm"]
|
||||
if kubernetesConfig.CustomCcmImage != "" {
|
||||
kubernetesCcmSpec = kubernetesConfig.CustomCcmImage
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
addValue(parametersMap, "kubernetesCcmImageSpec", kubernetesCcmSpec)
|
||||
}
|
||||
|
||||
kubernetesHyperkubeSpec := kubernetesConfig.KubernetesImageBase + KubeConfigs[k8sVersion]["hyperkube"]
|
||||
kubernetesHyperkubeSpec := kubernetesConfig.KubernetesImageBase + k8sComponents["hyperkube"]
|
||||
if kubernetesConfig.CustomHyperkubeImage != "" {
|
||||
kubernetesHyperkubeSpec = kubernetesConfig.CustomHyperkubeImage
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
addValue(parametersMap, "kubeDNSServiceIP", kubernetesConfig.DNSServiceIP)
|
||||
addValue(parametersMap, "kubeServiceCidr", kubernetesConfig.ServiceCIDR)
|
||||
addValue(parametersMap, "kubernetesHyperkubeSpec", kubernetesHyperkubeSpec)
|
||||
addValue(parametersMap, "kubernetesAddonManagerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["addonmanager"])
|
||||
addValue(parametersMap, "kubernetesAddonResizerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["addonresizer"])
|
||||
addValue(parametersMap, "kubernetesDNSMasqSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["dnsmasq"])
|
||||
addValue(parametersMap, "kubernetesExecHealthzSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["exechealthz"])
|
||||
addValue(parametersMap, "kubernetesDNSSidecarSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["k8s-dns-sidecar"])
|
||||
addValue(parametersMap, "kubernetesHeapsterSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["heapster"])
|
||||
addValue(parametersMap, "kubernetesAddonManagerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["addonmanager"])
|
||||
addValue(parametersMap, "kubernetesAddonResizerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["addonresizer"])
|
||||
addValue(parametersMap, "kubernetesDNSMasqSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["dnsmasq"])
|
||||
addValue(parametersMap, "kubernetesExecHealthzSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["exechealthz"])
|
||||
addValue(parametersMap, "kubernetesDNSSidecarSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["k8s-dns-sidecar"])
|
||||
addValue(parametersMap, "kubernetesHeapsterSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["heapster"])
|
||||
if kubernetesConfig.IsTillerEnabled() {
|
||||
tillerAddon := kubernetesConfig.GetAddonByName(DefaultTillerAddonName)
|
||||
c := tillerAddon.GetAddonContainersIndexByName(DefaultTillerAddonName)
|
||||
|
@ -61,7 +61,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if tillerAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "kubernetesTillerSpec", tillerAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "kubernetesTillerSpec", cloudSpecConfig.KubernetesSpecConfig.TillerImageBase+KubeConfigs[k8sVersion][DefaultTillerAddonName])
|
||||
addValue(parametersMap, "kubernetesTillerSpec", cloudSpecConfig.KubernetesSpecConfig.TillerImageBase+k8sComponents[DefaultTillerAddonName])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if aciConnectorAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "kubernetesACIConnectorSpec", aciConnectorAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "kubernetesACIConnectorSpec", cloudSpecConfig.KubernetesSpecConfig.ACIConnectorImageBase+KubeConfigs[k8sVersion][DefaultACIConnectorAddonName])
|
||||
addValue(parametersMap, "kubernetesACIConnectorSpec", cloudSpecConfig.KubernetesSpecConfig.ACIConnectorImageBase+k8sComponents[DefaultACIConnectorAddonName])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -110,7 +110,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if clusterAutoscalerAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "kubernetesClusterAutoscalerSpec", clusterAutoscalerAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "kubernetesClusterAutoscalerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion][DefaultClusterAutoscalerAddonName])
|
||||
addValue(parametersMap, "kubernetesClusterAutoscalerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents[DefaultClusterAutoscalerAddonName])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -155,7 +155,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if dashboardAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "kubernetesDashboardSpec", dashboardAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "kubernetesDashboardSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion][DefaultDashboardAddonName])
|
||||
addValue(parametersMap, "kubernetesDashboardSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents[DefaultDashboardAddonName])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if reschedulerAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "kubernetesReschedulerSpec", reschedulerAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "kubernetesReschedulerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion][DefaultReschedulerAddonName])
|
||||
addValue(parametersMap, "kubernetesReschedulerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents[DefaultReschedulerAddonName])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if metricsServerAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "kubernetesMetricsServerSpec", metricsServerAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "kubernetesMetricsServerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion][DefaultMetricsServerAddonName])
|
||||
addValue(parametersMap, "kubernetesMetricsServerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents[DefaultMetricsServerAddonName])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if nvidiaDevicePluginAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "kubernetesNVIDIADevicePluginSpec", nvidiaDevicePluginAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "kubernetesNVIDIADevicePluginSpec", cloudSpecConfig.KubernetesSpecConfig.NVIDIAImageBase+KubeConfigs[k8sVersion][NVIDIADevicePluginAddonName])
|
||||
addValue(parametersMap, "kubernetesNVIDIADevicePluginSpec", cloudSpecConfig.KubernetesSpecConfig.NVIDIAImageBase+k8sComponents[NVIDIADevicePluginAddonName])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if containerMonitoringAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "omsAgentImage", containerMonitoringAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "omsAgentImage", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion][ContainerMonitoringAddonName])
|
||||
addValue(parametersMap, "omsAgentImage", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents[ContainerMonitoringAddonName])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,13 +242,13 @@ func assignKubernetesParameters(properties *api.Properties, parametersMap params
|
|||
if azureCNINetworkmonitorAddon.Containers[c].Image != "" {
|
||||
addValue(parametersMap, "AzureCNINetworkMonitorImageURL", azureCNINetworkmonitorAddon.Containers[c].Image)
|
||||
} else {
|
||||
addValue(parametersMap, "AzureCNINetworkMonitorImageURL", cloudSpecConfig.KubernetesSpecConfig.AzureCNIImageBase+KubeConfigs[k8sVersion][AzureCNINetworkMonitoringAddonName])
|
||||
addValue(parametersMap, "AzureCNINetworkMonitorImageURL", cloudSpecConfig.KubernetesSpecConfig.AzureCNIImageBase+k8sComponents[AzureCNINetworkMonitoringAddonName])
|
||||
}
|
||||
}
|
||||
}
|
||||
addValue(parametersMap, "kubernetesCoreDNSSpec", "coredns/coredns:1.2.2")
|
||||
addValue(parametersMap, "kubernetesKubeDNSSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["dns"])
|
||||
addValue(parametersMap, "kubernetesPodInfraContainerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+KubeConfigs[k8sVersion]["pause"])
|
||||
addValue(parametersMap, "kubernetesKubeDNSSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["dns"])
|
||||
addValue(parametersMap, "kubernetesPodInfraContainerSpec", cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase+k8sComponents["pause"])
|
||||
addValue(parametersMap, "cloudproviderConfig", api.CloudProviderConfig{
|
||||
CloudProviderBackoff: kubernetesConfig.CloudProviderBackoff,
|
||||
CloudProviderBackoffRetries: kubernetesConfig.CloudProviderBackoffRetries,
|
||||
|
|
|
@ -37,7 +37,7 @@ func InitializeTemplateGenerator(ctx Context) (*TemplateGenerator, error) {
|
|||
}
|
||||
|
||||
// GenerateTemplate generates the template from the API Model
|
||||
func (t *TemplateGenerator) GenerateTemplate(containerService *api.ContainerService, generatorCode string, isUpgrade, isScale bool, acsengineVersion string) (templateRaw string, parametersRaw string, certsGenerated bool, err error) {
|
||||
func (t *TemplateGenerator) GenerateTemplate(containerService *api.ContainerService, generatorCode string, acsengineVersion string) (templateRaw string, parametersRaw string, err error) {
|
||||
// named return values are used in order to set err in case of a panic
|
||||
templateRaw = ""
|
||||
parametersRaw = ""
|
||||
|
@ -52,25 +52,22 @@ func (t *TemplateGenerator) GenerateTemplate(containerService *api.ContainerServ
|
|||
defer func() {
|
||||
properties.OrchestratorProfile.OrchestratorVersion = orchVersion
|
||||
}()
|
||||
if certsGenerated, err = setPropertiesDefaults(containerService, isUpgrade, isScale); err != nil {
|
||||
return templateRaw, parametersRaw, certsGenerated, err
|
||||
}
|
||||
|
||||
templ = template.New("acs template").Funcs(t.getTemplateFuncMap(containerService))
|
||||
|
||||
files, baseFile, e := t.prepareTemplateFiles(properties)
|
||||
if e != nil {
|
||||
return "", "", false, e
|
||||
return "", "", e
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
bytes, e := Asset(file)
|
||||
if e != nil {
|
||||
err = t.Translator.Errorf("Error reading file %s, Error: %s", file, e.Error())
|
||||
return templateRaw, parametersRaw, certsGenerated, err
|
||||
return templateRaw, parametersRaw, err
|
||||
}
|
||||
if _, err = templ.New(file).Parse(string(bytes)); err != nil {
|
||||
return templateRaw, parametersRaw, certsGenerated, err
|
||||
return templateRaw, parametersRaw, err
|
||||
}
|
||||
}
|
||||
// template generation may have panics in the called functions. This catches those panics
|
||||
|
@ -87,27 +84,27 @@ func (t *TemplateGenerator) GenerateTemplate(containerService *api.ContainerServ
|
|||
}()
|
||||
|
||||
if !validateDistro(containerService) {
|
||||
return templateRaw, parametersRaw, certsGenerated, errors.New("Invalid distro")
|
||||
return templateRaw, parametersRaw, errors.New("Invalid distro")
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
if err = templ.ExecuteTemplate(&b, baseFile, properties); err != nil {
|
||||
return templateRaw, parametersRaw, certsGenerated, err
|
||||
return templateRaw, parametersRaw, err
|
||||
}
|
||||
templateRaw = b.String()
|
||||
|
||||
var parametersMap paramsMap
|
||||
if parametersMap, err = getParameters(containerService, generatorCode, acsengineVersion); err != nil {
|
||||
return templateRaw, parametersRaw, certsGenerated, err
|
||||
return templateRaw, parametersRaw, err
|
||||
}
|
||||
|
||||
var parameterBytes []byte
|
||||
if parameterBytes, err = helpers.JSONMarshal(parametersMap, false); err != nil {
|
||||
return templateRaw, parametersRaw, certsGenerated, err
|
||||
return templateRaw, parametersRaw, err
|
||||
}
|
||||
parametersRaw = string(parameterBytes)
|
||||
|
||||
return templateRaw, parametersRaw, certsGenerated, err
|
||||
return templateRaw, parametersRaw, err
|
||||
}
|
||||
|
||||
func (t *TemplateGenerator) verifyFiles() error {
|
||||
|
@ -520,18 +517,18 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
},
|
||||
"GetMasterAllowedSizes": func() string {
|
||||
if cs.Properties.OrchestratorProfile.OrchestratorType == api.DCOS {
|
||||
return GetDCOSMasterAllowedSizes()
|
||||
return helpers.GetDCOSMasterAllowedSizes()
|
||||
}
|
||||
return GetMasterAgentAllowedSizes()
|
||||
return helpers.GetMasterAgentAllowedSizes()
|
||||
},
|
||||
"GetDefaultVNETCIDR": func() string {
|
||||
return DefaultVNETCIDR
|
||||
},
|
||||
"GetAgentAllowedSizes": func() string {
|
||||
if cs.Properties.OrchestratorProfile.IsKubernetes() || cs.Properties.OrchestratorProfile.IsOpenShift() {
|
||||
return GetKubernetesAgentAllowedSizes()
|
||||
return helpers.GetKubernetesAgentAllowedSizes()
|
||||
}
|
||||
return GetMasterAgentAllowedSizes()
|
||||
return helpers.GetMasterAgentAllowedSizes()
|
||||
},
|
||||
"getSwarmVersions": func() string {
|
||||
return getSwarmVersions(api.SwarmVersion, api.SwarmDockerComposeVersion)
|
||||
|
@ -540,7 +537,7 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat
|
|||
return getSwarmVersions(api.DockerCEVersion, api.DockerCEDockerComposeVersion)
|
||||
},
|
||||
"GetSizeMap": func() string {
|
||||
return GetSizeMap()
|
||||
return helpers.GetSizeMap()
|
||||
},
|
||||
"Base64": func(s string) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(s))
|
||||
|
|
|
@ -7,9 +7,6 @@ import (
|
|||
"github.com/Azure/acs-engine/pkg/i18n"
|
||||
)
|
||||
|
||||
// DCOSNodeType represents the type of DCOS Node
|
||||
type DCOSNodeType string
|
||||
|
||||
// VlabsContainerService is the type we read and write from file
|
||||
// needed because the json that is sent to ARM and acs-engine
|
||||
// is different from the json that the ACS RP Api gets from ARM
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
)
|
||||
|
||||
func setAddonsConfig(cs *api.ContainerService) {
|
||||
func (cs *ContainerService) setAddonsConfig() {
|
||||
o := cs.Properties.OrchestratorProfile
|
||||
defaultTillerAddonsConfig := api.KubernetesAddon{
|
||||
defaultTillerAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultTillerAddonName,
|
||||
Enabled: helpers.PointerToBool(api.DefaultTillerAddonEnabled),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(DefaultTillerAddonEnabled),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultTillerAddonName,
|
||||
CPURequests: "50m",
|
||||
|
@ -27,16 +26,16 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultACIConnectorAddonsConfig := api.KubernetesAddon{
|
||||
defaultACIConnectorAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultACIConnectorAddonName,
|
||||
Enabled: helpers.PointerToBool(api.DefaultACIConnectorAddonEnabled),
|
||||
Enabled: helpers.PointerToBool(DefaultACIConnectorAddonEnabled),
|
||||
Config: map[string]string{
|
||||
"region": "westus",
|
||||
"nodeName": "aci-connector",
|
||||
"os": "Linux",
|
||||
"taint": "azure.com/aci",
|
||||
},
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultACIConnectorAddonName,
|
||||
CPURequests: "50m",
|
||||
|
@ -47,14 +46,14 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultClusterAutoscalerAddonsConfig := api.KubernetesAddon{
|
||||
defaultClusterAutoscalerAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultClusterAutoscalerAddonName,
|
||||
Enabled: helpers.PointerToBool(api.DefaultClusterAutoscalerAddonEnabled),
|
||||
Enabled: helpers.PointerToBool(DefaultClusterAutoscalerAddonEnabled),
|
||||
Config: map[string]string{
|
||||
"minNodes": "1",
|
||||
"maxNodes": "5",
|
||||
},
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultClusterAutoscalerAddonName,
|
||||
CPURequests: "100m",
|
||||
|
@ -65,10 +64,10 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultBlobfuseFlexVolumeAddonsConfig := api.KubernetesAddon{
|
||||
defaultBlobfuseFlexVolumeAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultBlobfuseFlexVolumeAddonName,
|
||||
Enabled: helpers.PointerToBool(common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.8.0") && api.DefaultBlobfuseFlexVolumeAddonEnabled),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.8.0") && DefaultBlobfuseFlexVolumeAddonEnabled),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultBlobfuseFlexVolumeAddonName,
|
||||
CPURequests: "50m",
|
||||
|
@ -79,10 +78,10 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultSMBFlexVolumeAddonsConfig := api.KubernetesAddon{
|
||||
defaultSMBFlexVolumeAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultSMBFlexVolumeAddonName,
|
||||
Enabled: helpers.PointerToBool(common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.8.0") && api.DefaultSMBFlexVolumeAddonEnabled),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.8.0") && DefaultSMBFlexVolumeAddonEnabled),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultSMBFlexVolumeAddonName,
|
||||
CPURequests: "50m",
|
||||
|
@ -93,10 +92,10 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultKeyVaultFlexVolumeAddonsConfig := api.KubernetesAddon{
|
||||
defaultKeyVaultFlexVolumeAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultKeyVaultFlexVolumeAddonName,
|
||||
Enabled: helpers.PointerToBool(api.DefaultKeyVaultFlexVolumeAddonEnabled),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(DefaultKeyVaultFlexVolumeAddonEnabled),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultKeyVaultFlexVolumeAddonName,
|
||||
CPURequests: "50m",
|
||||
|
@ -107,10 +106,10 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultDashboardAddonsConfig := api.KubernetesAddon{
|
||||
defaultDashboardAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultDashboardAddonName,
|
||||
Enabled: helpers.PointerToBool(api.DefaultDashboardAddonEnabled),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(DefaultDashboardAddonEnabled),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultDashboardAddonName,
|
||||
CPURequests: "300m",
|
||||
|
@ -121,10 +120,10 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultReschedulerAddonsConfig := api.KubernetesAddon{
|
||||
defaultReschedulerAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultReschedulerAddonName,
|
||||
Enabled: helpers.PointerToBool(api.DefaultReschedulerAddonEnabled),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(DefaultReschedulerAddonEnabled),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultReschedulerAddonName,
|
||||
CPURequests: "10m",
|
||||
|
@ -135,20 +134,20 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultMetricsServerAddonsConfig := api.KubernetesAddon{
|
||||
defaultMetricsServerAddonsConfig := KubernetesAddon{
|
||||
Name: DefaultMetricsServerAddonName,
|
||||
Enabled: k8sVersionMetricsServerAddonEnabled(o),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: DefaultMetricsServerAddonName,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
defaultNVIDIADevicePluginAddonsConfig := api.KubernetesAddon{
|
||||
defaultNVIDIADevicePluginAddonsConfig := KubernetesAddon{
|
||||
Name: NVIDIADevicePluginAddonName,
|
||||
Enabled: helpers.PointerToBool(api.IsNSeriesSKU(cs.Properties) && common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.10.0")),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(IsNSeriesSKU(cs.Properties) && common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.10.0")),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: NVIDIADevicePluginAddonName,
|
||||
// from https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/device-plugins/nvidia-gpu/daemonset.yaml#L44
|
||||
|
@ -160,14 +159,14 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultContainerMonitoringAddonsConfig := api.KubernetesAddon{
|
||||
defaultContainerMonitoringAddonsConfig := KubernetesAddon{
|
||||
Name: ContainerMonitoringAddonName,
|
||||
Enabled: helpers.PointerToBool(api.DefaultContainerMonitoringAddonEnabled),
|
||||
Enabled: helpers.PointerToBool(DefaultContainerMonitoringAddonEnabled),
|
||||
Config: map[string]string{
|
||||
"omsAgentVersion": "1.6.0-42",
|
||||
"dockerProviderVersion": "2.0.0-3",
|
||||
},
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: "omsagent",
|
||||
Image: "microsoft/oms:acsenginelogfixnew",
|
||||
|
@ -179,10 +178,10 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultIPMasqAgentAddonsConfig := api.KubernetesAddon{
|
||||
defaultIPMasqAgentAddonsConfig := KubernetesAddon{
|
||||
Name: IPMASQAgentAddonName,
|
||||
Enabled: helpers.PointerToBool(api.IPMasqAgentAddonEnabled),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Enabled: helpers.PointerToBool(IPMasqAgentAddonEnabled),
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: IPMASQAgentAddonName,
|
||||
CPURequests: "50m",
|
||||
|
@ -193,27 +192,27 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
},
|
||||
}
|
||||
|
||||
defaultAzureCNINetworkMonitorAddonsConfig := api.KubernetesAddon{
|
||||
defaultAzureCNINetworkMonitorAddonsConfig := KubernetesAddon{
|
||||
Name: AzureCNINetworkMonitoringAddonName,
|
||||
Enabled: azureCNINetworkMonitorAddonEnabled(o),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: AzureCNINetworkMonitoringAddonName,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
defaultAzureNetworkPolicyAddonsConfig := api.KubernetesAddon{
|
||||
defaultAzureNetworkPolicyAddonsConfig := KubernetesAddon{
|
||||
Name: AzureNetworkPolicyAddonName,
|
||||
Enabled: azureNetworkPolicyAddonEnabled(o),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: AzureNetworkPolicyAddonName,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
defaultAddons := []api.KubernetesAddon{
|
||||
defaultAddons := []KubernetesAddon{
|
||||
defaultTillerAddonsConfig,
|
||||
defaultACIConnectorAddonsConfig,
|
||||
defaultClusterAutoscalerAddonsConfig,
|
||||
|
@ -246,7 +245,7 @@ func setAddonsConfig(cs *api.ContainerService) {
|
|||
}
|
||||
}
|
||||
|
||||
func getAddonsIndexByName(addons []api.KubernetesAddon, name string) int {
|
||||
func getAddonsIndexByName(addons []KubernetesAddon, name string) int {
|
||||
for i := range addons {
|
||||
if addons[i].Name == name {
|
||||
return i
|
||||
|
@ -256,7 +255,7 @@ func getAddonsIndexByName(addons []api.KubernetesAddon, name string) int {
|
|||
}
|
||||
|
||||
// assignDefaultAddonVals will assign default values to addon from defaults, for each property in addon that has a zero value
|
||||
func assignDefaultAddonVals(addon, defaults api.KubernetesAddon) api.KubernetesAddon {
|
||||
func assignDefaultAddonVals(addon, defaults KubernetesAddon) KubernetesAddon {
|
||||
if addon.Enabled == nil {
|
||||
addon.Enabled = defaults.Enabled
|
||||
}
|
||||
|
@ -293,7 +292,7 @@ func assignDefaultAddonVals(addon, defaults api.KubernetesAddon) api.KubernetesA
|
|||
return addon
|
||||
}
|
||||
|
||||
func synthesizeAddonsConfig(addons []api.KubernetesAddon, addon api.KubernetesAddon, enableIfNil bool) {
|
||||
func synthesizeAddonsConfig(addons []KubernetesAddon, addon KubernetesAddon, enableIfNil bool) {
|
||||
i := getAddonsIndexByName(addons, addon.Name)
|
||||
if i >= 0 {
|
||||
if addons[i].IsEnabled(enableIfNil) {
|
||||
|
@ -302,14 +301,14 @@ func synthesizeAddonsConfig(addons []api.KubernetesAddon, addon api.KubernetesAd
|
|||
}
|
||||
}
|
||||
|
||||
func k8sVersionMetricsServerAddonEnabled(o *api.OrchestratorProfile) *bool {
|
||||
func k8sVersionMetricsServerAddonEnabled(o *OrchestratorProfile) *bool {
|
||||
return helpers.PointerToBool(common.IsKubernetesVersionGe(o.OrchestratorVersion, "1.9.0"))
|
||||
}
|
||||
|
||||
func azureNetworkPolicyAddonEnabled(o *api.OrchestratorProfile) *bool {
|
||||
func azureNetworkPolicyAddonEnabled(o *OrchestratorProfile) *bool {
|
||||
return helpers.PointerToBool(o.KubernetesConfig.NetworkPlugin == NetworkPluginAzure && o.KubernetesConfig.NetworkPolicy == NetworkPolicyAzure)
|
||||
}
|
||||
|
||||
func azureCNINetworkMonitorAddonEnabled(o *api.OrchestratorProfile) *bool {
|
||||
func azureCNINetworkMonitorAddonEnabled(o *OrchestratorProfile) *bool {
|
||||
return helpers.PointerToBool(o.IsAzureCNI())
|
||||
}
|
|
@ -260,4 +260,12 @@ var (
|
|||
AKS: SovereignCloudsUbuntuImageConfig,
|
||||
},
|
||||
}
|
||||
|
||||
// AzureCloudSpecEnvMap is the environment configuration map for all the Azure cloid environments.
|
||||
AzureCloudSpecEnvMap = map[string]AzureEnvironmentSpecConfig{
|
||||
azureChinaCloud: AzureChinaCloudSpec,
|
||||
azureGermanCloud: AzureGermanCloudSpec,
|
||||
azureUSGovernmentCloud: AzureUSGovernmentCloud,
|
||||
azurePublicCloud: AzureCloudSpec,
|
||||
}
|
||||
)
|
||||
|
|
139
pkg/api/const.go
139
pkg/api/const.go
|
@ -225,13 +225,6 @@ const (
|
|||
DefaultKubernetesCloudProviderRateLimitBucket = 10
|
||||
)
|
||||
|
||||
const (
|
||||
azurePublicCloud = "AzurePublicCloud"
|
||||
azureChinaCloud = "AzureChinaCloud"
|
||||
azureGermanCloud = "AzureGermanCloud"
|
||||
azureUSGovernmentCloud = "AzureUSGovernmentCloud"
|
||||
)
|
||||
|
||||
const (
|
||||
//AzureEdgeDCOSBootstrapDownloadURL is the azure edge CDN download url
|
||||
AzureEdgeDCOSBootstrapDownloadURL = "https://dcosio.azureedge.net/dcos/%s/bootstrap/%s.bootstrap.tar.xz"
|
||||
|
@ -253,3 +246,135 @@ const (
|
|||
// https://github.com/containernetworking/plugins
|
||||
CNIPluginVer = "v0.7.1"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultOpenShiftMasterSubnet is the default value for master subnet for Openshift.
|
||||
DefaultOpenShiftMasterSubnet = "10.0.0.0/24"
|
||||
// DefaultOpenShiftFirstConsecutiveStaticIP is the default static ip address for master 0 for Openshift.
|
||||
DefaultOpenShiftFirstConsecutiveStaticIP = "10.0.0.11"
|
||||
// DefaultMasterSubnet specifies the default master subnet for DCOS or Swarm
|
||||
DefaultMasterSubnet = "172.16.0.0/24"
|
||||
// DefaultFirstConsecutiveStaticIP specifies the static IP address on master 0 for DCOS or Swarm
|
||||
DefaultFirstConsecutiveStaticIP = "172.16.0.5"
|
||||
// DefaultSwarmWindowsMasterSubnet specifies the default master subnet for a Swarm Windows cluster
|
||||
DefaultSwarmWindowsMasterSubnet = "192.168.255.0/24"
|
||||
// DefaultSwarmWindowsFirstConsecutiveStaticIP specifies the static IP address on master 0 for a Swarm WIndows cluster
|
||||
DefaultSwarmWindowsFirstConsecutiveStaticIP = "192.168.255.5"
|
||||
// DefaultDCOSMasterSubnet specifies the default master subnet for a DCOS cluster
|
||||
DefaultDCOSMasterSubnet = "192.168.255.0/24"
|
||||
// DefaultDCOSFirstConsecutiveStaticIP specifies the static IP address on master 0 for a DCOS cluster
|
||||
DefaultDCOSFirstConsecutiveStaticIP = "192.168.255.5"
|
||||
// DefaultDCOSBootstrapStaticIP specifies the static IP address on bootstrap for a DCOS cluster
|
||||
DefaultDCOSBootstrapStaticIP = "192.168.255.240"
|
||||
// DefaultKubernetesMasterSubnet specifies the default subnet for masters and agents.
|
||||
// Except when master VMSS is used, this specifies the default subnet for masters.
|
||||
DefaultKubernetesMasterSubnet = "10.240.0.0/16"
|
||||
// DefaultAgentSubnetTemplate specifies a default agent subnet
|
||||
DefaultAgentSubnetTemplate = "10.%d.0.0/16"
|
||||
// DefaultKubernetesSubnet specifies the default subnet used for all masters, agents and pods
|
||||
// when VNET integration is enabled.
|
||||
DefaultKubernetesSubnet = "10.240.0.0/12"
|
||||
// DefaultVNETCIDR is the default CIDR block for the VNET
|
||||
DefaultVNETCIDR = "10.0.0.0/8"
|
||||
// DefaultKubernetesMaxPods is the maximum number of pods to run on a node.
|
||||
DefaultKubernetesMaxPods = 110
|
||||
// DefaultKubernetesMaxPodsVNETIntegrated is the maximum number of pods to run on a node when VNET integration is enabled.
|
||||
DefaultKubernetesMaxPodsVNETIntegrated = 30
|
||||
// DefaultKubernetesClusterDomain is the dns suffix used in the cluster (used as a SAN in the PKI generation)
|
||||
DefaultKubernetesClusterDomain = "cluster.local"
|
||||
// DefaultInternalLbStaticIPOffset specifies the offset of the internal LoadBalancer's IP
|
||||
// address relative to the first consecutive Kubernetes static IP
|
||||
DefaultInternalLbStaticIPOffset = 10
|
||||
// NetworkPolicyCalico is the string expression for calico network policy config option
|
||||
NetworkPolicyCalico = "calico"
|
||||
// NetworkPolicyCilium is the string expression for cilium network policy config option
|
||||
NetworkPolicyCilium = "cilium"
|
||||
// NetworkPluginFlannel is the string expression for flannel network policy config option
|
||||
NetworkPluginFlannel = "flannel"
|
||||
// DefaultNetworkPlugin defines the network plugin to use by default
|
||||
DefaultNetworkPlugin = NetworkPluginKubenet
|
||||
// DefaultNetworkPolicy defines the network policy implementation to use by default
|
||||
DefaultNetworkPolicy = ""
|
||||
// DefaultNetworkPluginWindows defines the network plugin implementation to use by default for clusters with Windows agent pools
|
||||
DefaultNetworkPluginWindows = NetworkPluginKubenet
|
||||
// DefaultNetworkPolicyWindows defines the network policy implementation to use by default for clusters with Windows agent pools
|
||||
DefaultNetworkPolicyWindows = ""
|
||||
// DefaultContainerRuntime is docker
|
||||
DefaultContainerRuntime = "docker"
|
||||
// DefaultKubernetesNodeStatusUpdateFrequency is 10s, see --node-status-update-frequency at https://kubernetes.io/docs/admin/kubelet/
|
||||
DefaultKubernetesNodeStatusUpdateFrequency = "10s"
|
||||
// DefaultKubernetesHardEvictionThreshold is memory.available<100Mi,nodefs.available<10%,nodefs.inodesFree<5%, see --eviction-hard at https://kubernetes.io/docs/admin/kubelet/
|
||||
DefaultKubernetesHardEvictionThreshold = "memory.available<100Mi,nodefs.available<10%,nodefs.inodesFree<5%"
|
||||
// DefaultKubernetesCtrlMgrNodeMonitorGracePeriod is 40s, see --node-monitor-grace-period at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrNodeMonitorGracePeriod = "40s"
|
||||
// DefaultKubernetesCtrlMgrPodEvictionTimeout is 5m0s, see --pod-eviction-timeout at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrPodEvictionTimeout = "5m0s"
|
||||
// DefaultKubernetesCtrlMgrRouteReconciliationPeriod is 10s, see --route-reconciliation-period at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrRouteReconciliationPeriod = "10s"
|
||||
// DefaultKubernetesCtrlMgrTerminatedPodGcThreshold is set to 5000, see --terminated-pod-gc-threshold at https://kubernetes.io/docs/admin/kube-controller-manager/ and https://github.com/kubernetes/kubernetes/issues/22680
|
||||
DefaultKubernetesCtrlMgrTerminatedPodGcThreshold = "5000"
|
||||
// DefaultKubernetesCtrlMgrUseSvcAccountCreds is "true", see --use-service-account-credentials at https://kubernetes.io/docs/admin/kube-controller-manager/
|
||||
DefaultKubernetesCtrlMgrUseSvcAccountCreds = "false"
|
||||
// DefaultKubernetesCloudProviderBackoff is false to disable cloudprovider backoff implementation for API calls
|
||||
DefaultKubernetesCloudProviderBackoff = true
|
||||
// DefaultKubernetesCloudProviderRateLimit is false to disable cloudprovider rate limiting implementation for API calls
|
||||
DefaultKubernetesCloudProviderRateLimit = true
|
||||
// DefaultTillerMaxHistory limits the maximum number of revisions saved per release. Use 0 for no limit.
|
||||
DefaultTillerMaxHistory = 0
|
||||
//DefaultKubernetesGCHighThreshold specifies the value for for the image-gc-high-threshold kubelet flag
|
||||
DefaultKubernetesGCHighThreshold = 85
|
||||
//DefaultKubernetesGCLowThreshold specifies the value for the image-gc-low-threshold kubelet flag
|
||||
DefaultKubernetesGCLowThreshold = 80
|
||||
// DefaultEtcdVersion specifies the default etcd version to install
|
||||
DefaultEtcdVersion = "3.2.23"
|
||||
// DefaultEtcdDiskSize specifies the default size for Kubernetes master etcd disk volumes in GB
|
||||
DefaultEtcdDiskSize = "256"
|
||||
// DefaultEtcdDiskSizeGT3Nodes = size for Kubernetes master etcd disk volumes in GB if > 3 nodes
|
||||
DefaultEtcdDiskSizeGT3Nodes = "512"
|
||||
// DefaultEtcdDiskSizeGT10Nodes = size for Kubernetes master etcd disk volumes in GB if > 10 nodes
|
||||
DefaultEtcdDiskSizeGT10Nodes = "1024"
|
||||
// DefaultEtcdDiskSizeGT20Nodes = size for Kubernetes master etcd disk volumes in GB if > 20 nodes
|
||||
DefaultEtcdDiskSizeGT20Nodes = "2048"
|
||||
// AzureCNINetworkMonitoringAddonName is the name of the Azure CNI networkmonitor addon
|
||||
AzureCNINetworkMonitoringAddonName = "azure-cni-networkmonitor"
|
||||
// AzureNetworkPolicyAddonName is the name of the Azure CNI networkmonitor addon
|
||||
AzureNetworkPolicyAddonName = "azure-npm-daemonset"
|
||||
// DefaultMasterEtcdClientPort is the default etcd client port for Kubernetes master nodes
|
||||
DefaultMasterEtcdClientPort = 2379
|
||||
// DefaultKubeletEventQPS is 0, see --event-qps at https://kubernetes.io/docs/reference/generated/kubelet/
|
||||
DefaultKubeletEventQPS = "0"
|
||||
// DefaultKubeletCadvisorPort is 0, see --cadvisor-port at https://kubernetes.io/docs/reference/generated/kubelet/
|
||||
DefaultKubeletCadvisorPort = "0"
|
||||
// DefaultJumpboxDiskSize specifies the default size for private cluster jumpbox OS disk in GB
|
||||
DefaultJumpboxDiskSize = 30
|
||||
// DefaultJumpboxUsername specifies the default admin username for the private cluster jumpbox
|
||||
DefaultJumpboxUsername = "azureuser"
|
||||
// DefaultKubeletPodMaxPIDs specifies the default max pid authorized by pods
|
||||
DefaultKubeletPodMaxPIDs = 100
|
||||
// DefaultKubernetesAgentSubnetVMSS specifies the default subnet for agents when master is VMSS
|
||||
DefaultKubernetesAgentSubnetVMSS = "10.248.0.0/13"
|
||||
// DefaultKubernetesClusterSubnet specifies the default subnet for pods.
|
||||
DefaultKubernetesClusterSubnet = "10.244.0.0/16"
|
||||
// DefaultKubernetesServiceCIDR specifies the IP subnet that kubernetes will create Service IPs within.
|
||||
DefaultKubernetesServiceCIDR = "10.0.0.0/16"
|
||||
// DefaultKubernetesDNSServiceIP specifies the IP address that kube-dns listens on by default. must by in the default Service CIDR range.
|
||||
DefaultKubernetesDNSServiceIP = "10.0.0.10"
|
||||
// DefaultDockerBridgeSubnet specifies the default subnet for the docker bridge network for masters and agents.
|
||||
DefaultDockerBridgeSubnet = "172.17.0.1/16"
|
||||
// DefaultKubernetesMaxPodsKubenet is the maximum number of pods to run on a node for Kubenet.
|
||||
DefaultKubernetesMaxPodsKubenet = "110"
|
||||
// DefaultKubernetesMaxPodsAzureCNI is the maximum number of pods to run on a node for Azure CNI.
|
||||
DefaultKubernetesMaxPodsAzureCNI = "30"
|
||||
)
|
||||
|
||||
const (
|
||||
//DefaultExtensionsRootURL Root URL for extensions
|
||||
DefaultExtensionsRootURL = "https://raw.githubusercontent.com/Azure/acs-engine/master/"
|
||||
)
|
||||
|
||||
const (
|
||||
azurePublicCloud = "AzurePublicCloud"
|
||||
azureChinaCloud = "AzureChinaCloud"
|
||||
azureGermanCloud = "AzureGermanCloud"
|
||||
azureUSGovernmentCloud = "AzureUSGovernmentCloud"
|
||||
)
|
||||
|
|
|
@ -19,21 +19,6 @@ import (
|
|||
// for converting.
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const (
|
||||
// DefaultKubernetesClusterSubnet specifies the default subnet for pods.
|
||||
DefaultKubernetesClusterSubnet = "10.244.0.0/16"
|
||||
// DefaultKubernetesServiceCIDR specifies the IP subnet that kubernetes will create Service IPs within.
|
||||
DefaultKubernetesServiceCIDR = "10.0.0.0/16"
|
||||
// DefaultKubernetesDNSServiceIP specifies the IP address that kube-dns listens on by default. must by in the default Service CIDR range.
|
||||
DefaultKubernetesDNSServiceIP = "10.0.0.10"
|
||||
// DefaultDockerBridgeSubnet specifies the default subnet for the docker bridge network for masters and agents.
|
||||
DefaultDockerBridgeSubnet = "172.17.0.1/16"
|
||||
// DefaultKubernetesMaxPodsKubenet is the maximum number of pods to run on a node for Kubenet.
|
||||
DefaultKubernetesMaxPodsKubenet = "110"
|
||||
// DefaultKubernetesMaxPodsAzureCNI is the maximum number of pods to run on a node for Azure CNI.
|
||||
DefaultKubernetesMaxPodsAzureCNI = "30"
|
||||
)
|
||||
|
||||
// ConvertV20170831AgentPoolOnly converts an AgentPoolOnly object into an in-memory container service
|
||||
func ConvertV20170831AgentPoolOnly(v20170831 *v20170831.ManagedCluster) *ContainerService {
|
||||
c := &ContainerService{}
|
||||
|
|
|
@ -866,7 +866,6 @@ func convertV20170131MasterProfile(v20170131 *v20170131.MasterProfile, api *Mast
|
|||
api.FQDN = v20170131.FQDN
|
||||
api.Subnet = v20170131.GetSubnet()
|
||||
// Set default VMSize
|
||||
// TODO: Use azureconst.go to set
|
||||
api.VMSize = "Standard_D2_v2"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
)
|
||||
|
||||
func setAPIServerConfig(cs *api.ContainerService) {
|
||||
func (cs *ContainerService) setAPIServerConfig() {
|
||||
o := cs.Properties.OrchestratorProfile
|
||||
staticAPIServerConfig := map[string]string{
|
||||
"--bind-address": "0.0.0.0",
|
||||
|
@ -130,7 +129,7 @@ func setAPIServerConfig(cs *api.ContainerService) {
|
|||
}
|
||||
}
|
||||
|
||||
func getDefaultAdmissionControls(cs *api.ContainerService) (string, string) {
|
||||
func getDefaultAdmissionControls(cs *ContainerService) (string, string) {
|
||||
o := cs.Properties.OrchestratorProfile
|
||||
admissionControlKey := "--enable-admission-plugins"
|
||||
var admissionControlValues string
|
|
@ -1,9 +1,8 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
)
|
||||
|
||||
|
@ -13,7 +12,7 @@ func TestAPIServerConfigEnableDataEncryptionAtRest(t *testing.T) {
|
|||
// Test EnableDataEncryptionAtRest = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableDataEncryptionAtRest = helpers.PointerToBool(true)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--experimental-encryption-provider-config"] != "/etc/kubernetes/encryption-config.yaml" {
|
||||
t.Fatalf("got unexpected '--experimental-encryption-provider-config' API server config value for EnableDataEncryptionAtRest=true: %s",
|
||||
|
@ -23,7 +22,7 @@ func TestAPIServerConfigEnableDataEncryptionAtRest(t *testing.T) {
|
|||
// Test EnableDataEncryptionAtRest = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableDataEncryptionAtRest = helpers.PointerToBool(false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if _, ok := a["--experimental-encryption-provider-config"]; ok {
|
||||
t.Fatalf("got unexpected '--experimental-encryption-provider-config' API server config value for EnableDataEncryptionAtRest=false: %s",
|
||||
|
@ -35,7 +34,7 @@ func TestAPIServerConfigEnableEncryptionWithExternalKms(t *testing.T) {
|
|||
// Test EnableEncryptionWithExternalKms = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableEncryptionWithExternalKms = helpers.PointerToBool(true)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--experimental-encryption-provider-config"] != "/etc/kubernetes/encryption-config.yaml" {
|
||||
t.Fatalf("got unexpected '--experimental-encryption-provider-config' API server config value for EnableEncryptionWithExternalKms=true: %s",
|
||||
|
@ -45,7 +44,7 @@ func TestAPIServerConfigEnableEncryptionWithExternalKms(t *testing.T) {
|
|||
// Test EnableEncryptionWithExternalKms = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableEncryptionWithExternalKms = helpers.PointerToBool(false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if _, ok := a["--experimental-encryption-provider-config"]; ok {
|
||||
t.Fatalf("got unexpected '--experimental-encryption-provider-config' API server config value for EnableEncryptionWithExternalKms=false: %s",
|
||||
|
@ -57,7 +56,7 @@ func TestAPIServerConfigEnableAggregatedAPIs(t *testing.T) {
|
|||
// Test EnableAggregatedAPIs = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs = true
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--requestheader-client-ca-file"] != "/etc/kubernetes/certs/proxy-ca.crt" {
|
||||
t.Fatalf("got unexpected '--requestheader-client-ca-file' API server config value for EnableAggregatedAPIs=true: %s",
|
||||
|
@ -91,7 +90,7 @@ func TestAPIServerConfigEnableAggregatedAPIs(t *testing.T) {
|
|||
// Test EnableAggregatedAPIs = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs = false
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
for _, key := range []string{"--requestheader-client-ca-file", "--proxy-client-cert-file", "--proxy-client-key-file",
|
||||
"--requestheader-allowed-names", "--requestheader-extra-headers-prefix", "--requestheader-group-headers",
|
||||
|
@ -107,7 +106,7 @@ func TestAPIServerConfigUseCloudControllerManager(t *testing.T) {
|
|||
// Test UseCloudControllerManager = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager = helpers.PointerToBool(true)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if _, ok := a["--cloud-provider"]; ok {
|
||||
t.Fatalf("got unexpected '--cloud-provider' API server config value for UseCloudControllerManager=false: %s",
|
||||
|
@ -121,7 +120,7 @@ func TestAPIServerConfigUseCloudControllerManager(t *testing.T) {
|
|||
// Test UseCloudControllerManager = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager = helpers.PointerToBool(false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--cloud-provider"] != "azure" {
|
||||
t.Fatalf("got unexpected '--cloud-provider' API server config value for UseCloudControllerManager=true: %s",
|
||||
|
@ -136,11 +135,11 @@ func TestAPIServerConfigUseCloudControllerManager(t *testing.T) {
|
|||
func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
||||
// Test HasAadProfile = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.AADProfile = &api.AADProfile{
|
||||
cs.Properties.AADProfile = &AADProfile{
|
||||
ServerAppID: "test-id",
|
||||
TenantID: "test-tenant",
|
||||
}
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--oidc-username-claim"] != "oid" {
|
||||
t.Fatalf("got unexpected '--oidc-username-claim' API server config value for HasAadProfile=true: %s",
|
||||
|
@ -161,7 +160,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
|||
|
||||
// Test OIDC user overrides
|
||||
cs = CreateMockContainerService("testcluster", "1.7.12", 3, 2, false)
|
||||
cs.Properties.AADProfile = &api.AADProfile{
|
||||
cs.Properties.AADProfile = &AADProfile{
|
||||
ServerAppID: "test-id",
|
||||
TenantID: "test-tenant",
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
|||
"--oidc-client-id": clientIDOverride,
|
||||
"--oidc-issuer-url": issuerURLOverride,
|
||||
}
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--oidc-username-claim"] != usernameClaimOverride {
|
||||
t.Fatalf("got unexpected '--oidc-username-claim' API server config value when user override provided: %s, expected: %s",
|
||||
|
@ -196,12 +195,12 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
|||
|
||||
// Test China Cloud settings
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.AADProfile = &api.AADProfile{
|
||||
cs.Properties.AADProfile = &AADProfile{
|
||||
ServerAppID: "test-id",
|
||||
TenantID: "test-tenant",
|
||||
}
|
||||
cs.Location = "chinaeast"
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--oidc-issuer-url"] != "https://sts.chinacloudapi.cn/"+cs.Properties.AADProfile.TenantID+"/" {
|
||||
t.Fatalf("got unexpected '--oidc-issuer-url' API server config value for HasAadProfile=true using China cloud: %s",
|
||||
|
@ -209,7 +208,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
|||
}
|
||||
|
||||
cs.Location = "chinaeast2"
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--oidc-issuer-url"] != "https://sts.chinacloudapi.cn/"+cs.Properties.AADProfile.TenantID+"/" {
|
||||
t.Fatalf("got unexpected '--oidc-issuer-url' API server config value for HasAadProfile=true using China cloud: %s",
|
||||
|
@ -217,7 +216,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
|||
}
|
||||
|
||||
cs.Location = "chinanorth"
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--oidc-issuer-url"] != "https://sts.chinacloudapi.cn/"+cs.Properties.AADProfile.TenantID+"/" {
|
||||
t.Fatalf("got unexpected '--oidc-issuer-url' API server config value for HasAadProfile=true using China cloud: %s",
|
||||
|
@ -225,7 +224,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
|||
}
|
||||
|
||||
cs.Location = "chinanorth2"
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--oidc-issuer-url"] != "https://sts.chinacloudapi.cn/"+cs.Properties.AADProfile.TenantID+"/" {
|
||||
t.Fatalf("got unexpected '--oidc-issuer-url' API server config value for HasAadProfile=true using China cloud: %s",
|
||||
|
@ -234,7 +233,7 @@ func TestAPIServerConfigHasAadProfile(t *testing.T) {
|
|||
|
||||
// Test HasAadProfile = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
for _, key := range []string{"--oidc-username-claim", "--oidc-groups-claim", "--oidc-client-id", "--oidc-issuer-url"} {
|
||||
if _, ok := a[key]; ok {
|
||||
|
@ -248,7 +247,7 @@ func TestAPIServerConfigEnableRbac(t *testing.T) {
|
|||
// Test EnableRbac = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(true)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--authorization-mode"] != "Node,RBAC" {
|
||||
t.Fatalf("got unexpected '--authorization-mode' API server config value for EnableRbac=true: %s",
|
||||
|
@ -258,7 +257,7 @@ func TestAPIServerConfigEnableRbac(t *testing.T) {
|
|||
// Test EnableRbac = true with 1.6 cluster
|
||||
cs = CreateMockContainerService("testcluster", "1.6.11", 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(true)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--authorization-mode"] != "RBAC" {
|
||||
t.Fatalf("got unexpected '--authorization-mode' API server config value for 1.6 cluster with EnableRbac=true: %s",
|
||||
|
@ -268,7 +267,7 @@ func TestAPIServerConfigEnableRbac(t *testing.T) {
|
|||
// Test EnableRbac = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if _, ok := a["--authorization-mode"]; ok {
|
||||
t.Fatalf("got unexpected '--authorization-mode' API server config value for EnableRbac=false: %s",
|
||||
|
@ -278,7 +277,7 @@ func TestAPIServerConfigEnableRbac(t *testing.T) {
|
|||
// Test EnableRbac = false with 1.6 cluster
|
||||
cs = CreateMockContainerService("testcluster", "1.6.11", 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if _, ok := a["--authorization-mode"]; ok {
|
||||
t.Fatalf("got unexpected '--authorization-mode' API server config value for 1.6 cluster with EnableRbac=false: %s",
|
||||
|
@ -290,7 +289,7 @@ func TestAPIServerConfigDisableRbac(t *testing.T) {
|
|||
// Test EnableRbac = false
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--authorization-mode"] != "" {
|
||||
t.Fatalf("got unexpected '--authorization-mode' API server config value for EnableRbac=false: %s",
|
||||
|
@ -302,7 +301,7 @@ func TestAPIServerConfigEnableSecureKubelet(t *testing.T) {
|
|||
// Test EnableSecureKubelet = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet = helpers.PointerToBool(true)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
if a["--kubelet-client-certificate"] != "/etc/kubernetes/certs/client.crt" {
|
||||
t.Fatalf("got unexpected '--kubelet-client-certificate' API server config value for EnableSecureKubelet=true: %s",
|
||||
|
@ -316,7 +315,7 @@ func TestAPIServerConfigEnableSecureKubelet(t *testing.T) {
|
|||
// Test EnableSecureKubelet = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet = helpers.PointerToBool(false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
for _, key := range []string{"--kubelet-client-certificate", "--kubelet-client-key"} {
|
||||
if _, ok := a[key]; ok {
|
||||
|
@ -334,7 +333,7 @@ func TestAPIServerConfigDefaultAdmissionControls(t *testing.T) {
|
|||
cs := CreateMockContainerService("testcluster", version, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig = map[string]string{}
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig[admissonControlKey] = "NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota,AlwaysPullImages,ExtendedResourceToleration"
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a := cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
|
||||
// --enable-admission-plugins should be set for v1.10 and above
|
||||
|
@ -350,7 +349,7 @@ func TestAPIServerConfigDefaultAdmissionControls(t *testing.T) {
|
|||
// Test --admission-control for v1.9 and below
|
||||
version = "1.9.0"
|
||||
cs = CreateMockContainerService("testcluster", version, 3, 2, false)
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
a = cs.Properties.OrchestratorProfile.KubernetesConfig.APIServerConfig
|
||||
|
||||
// --enable-admission-plugins is available for v1.10 and above and should not be set here
|
|
@ -1,12 +1,10 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
)
|
||||
|
||||
func setCloudControllerManagerConfig(cs *api.ContainerService) {
|
||||
func (cs *ContainerService) setCloudControllerManagerConfig() {
|
||||
o := cs.Properties.OrchestratorProfile
|
||||
staticCloudControllerManagerConfig := map[string]string{
|
||||
"--allocate-node-cidrs": strconv.FormatBool(!o.IsAzureCNI()),
|
|
@ -1,13 +1,12 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
)
|
||||
|
||||
func setControllerManagerConfig(cs *api.ContainerService) {
|
||||
func (cs *ContainerService) setControllerManagerConfig() {
|
||||
o := cs.Properties.OrchestratorProfile
|
||||
staticControllerManagerConfig := map[string]string{
|
||||
"--kubeconfig": "/var/lib/kubelet/kubeconfig",
|
|
@ -1,15 +1,14 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
)
|
||||
|
||||
func setKubeletConfig(cs *api.ContainerService) {
|
||||
func (cs *ContainerService) setKubeletConfig() {
|
||||
o := cs.Properties.OrchestratorProfile
|
||||
cloudSpecConfig := cs.GetCloudSpecConfig()
|
||||
staticLinuxKubeletConfig := map[string]string{
|
||||
|
@ -49,10 +48,10 @@ func setKubeletConfig(cs *api.ContainerService) {
|
|||
defaultKubeletConfig := map[string]string{
|
||||
"--cluster-domain": "cluster.local",
|
||||
"--network-plugin": "cni",
|
||||
"--pod-infra-container-image": cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + KubeConfigs[o.OrchestratorVersion]["pause"],
|
||||
"--pod-infra-container-image": cloudSpecConfig.KubernetesSpecConfig.KubernetesImageBase + K8sComponentsByVersionMap[o.OrchestratorVersion]["pause"],
|
||||
"--max-pods": strconv.Itoa(DefaultKubernetesMaxPods),
|
||||
"--eviction-hard": DefaultKubernetesHardEvictionThreshold,
|
||||
"--node-status-update-frequency": KubeConfigs[o.OrchestratorVersion]["nodestatusfreq"],
|
||||
"--node-status-update-frequency": K8sComponentsByVersionMap[o.OrchestratorVersion]["nodestatusfreq"],
|
||||
"--image-gc-high-threshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"--image-gc-low-threshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
"--non-masquerade-cidr": "0.0.0.0",
|
||||
|
@ -110,8 +109,8 @@ func setKubeletConfig(cs *api.ContainerService) {
|
|||
// Master-specific kubelet config changes go here
|
||||
if cs.Properties.MasterProfile != nil {
|
||||
if cs.Properties.MasterProfile.KubernetesConfig == nil {
|
||||
cs.Properties.MasterProfile.KubernetesConfig = &api.KubernetesConfig{}
|
||||
cs.Properties.MasterProfile.KubernetesConfig.KubeletConfig = copyMap(cs.Properties.MasterProfile.KubernetesConfig.KubeletConfig)
|
||||
cs.Properties.MasterProfile.KubernetesConfig = &KubernetesConfig{}
|
||||
cs.Properties.MasterProfile.KubernetesConfig.KubeletConfig = make(map[string]string)
|
||||
}
|
||||
setMissingKubeletValues(cs.Properties.MasterProfile.KubernetesConfig, o.KubernetesConfig.KubeletConfig)
|
||||
addDefaultFeatureGates(cs.Properties.MasterProfile.KubernetesConfig.KubeletConfig, o.OrchestratorVersion, "", "")
|
||||
|
@ -122,8 +121,8 @@ func setKubeletConfig(cs *api.ContainerService) {
|
|||
// Agent-specific kubelet config changes go here
|
||||
for _, profile := range cs.Properties.AgentPoolProfiles {
|
||||
if profile.KubernetesConfig == nil {
|
||||
profile.KubernetesConfig = &api.KubernetesConfig{}
|
||||
profile.KubernetesConfig.KubeletConfig = copyMap(profile.KubernetesConfig.KubeletConfig)
|
||||
profile.KubernetesConfig = &KubernetesConfig{}
|
||||
profile.KubernetesConfig.KubeletConfig = make(map[string]string)
|
||||
if profile.OSType == "Windows" {
|
||||
for key, val := range staticWindowsKubeletConfig {
|
||||
profile.KubernetesConfig.KubeletConfig[key] = val
|
||||
|
@ -165,7 +164,7 @@ func removeKubeletFlags(k map[string]string, v string) {
|
|||
}
|
||||
}
|
||||
|
||||
func setMissingKubeletValues(p *api.KubernetesConfig, d map[string]string) {
|
||||
func setMissingKubeletValues(p *KubernetesConfig, d map[string]string) {
|
||||
if p.KubeletConfig == nil {
|
||||
p.KubeletConfig = d
|
||||
} else {
|
||||
|
@ -178,10 +177,3 @@ func setMissingKubeletValues(p *api.KubernetesConfig, d map[string]string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
func copyMap(input map[string]string) map[string]string {
|
||||
copy := map[string]string{}
|
||||
for key, value := range input {
|
||||
copy[key] = value
|
||||
}
|
||||
return copy
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func TestKubeletConfigDefaults(t *testing.T) {
|
||||
cs := CreateMockContainerService("testcluster", "1.8.6", 3, 2, false)
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
// TODO test all default config values
|
||||
for key, val := range map[string]string{
|
||||
|
@ -28,7 +28,7 @@ func TestKubeletConfigDefaults(t *testing.T) {
|
|||
cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig = map[string]string{
|
||||
"--azure-container-registry-config": overrideVal,
|
||||
}
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
for key, val := range map[string]string{"--azure-container-registry-config": overrideVal} {
|
||||
if k[key] != val {
|
||||
|
@ -42,7 +42,7 @@ func TestKubeletConfigUseCloudControllerManager(t *testing.T) {
|
|||
// Test UseCloudControllerManager = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager = helpers.PointerToBool(true)
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--cloud-provider"] != "external" {
|
||||
t.Fatalf("got unexpected '--cloud-provider' kubelet config value for UseCloudControllerManager=true: %s",
|
||||
|
@ -52,7 +52,7 @@ func TestKubeletConfigUseCloudControllerManager(t *testing.T) {
|
|||
// Test UseCloudControllerManager = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.UseCloudControllerManager = helpers.PointerToBool(false)
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--cloud-provider"] != "azure" {
|
||||
t.Fatalf("got unexpected '--cloud-provider' kubelet config value for UseCloudControllerManager=false: %s",
|
||||
|
@ -64,7 +64,7 @@ func TestKubeletConfigUseCloudControllerManager(t *testing.T) {
|
|||
func TestKubeletConfigCloudConfig(t *testing.T) {
|
||||
// Test default value and custom value for --cloud-config
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--cloud-config"] != "/etc/kubernetes/azure.json" {
|
||||
t.Fatalf("got unexpected '--cloud-config' kubelet config default value: %s",
|
||||
|
@ -73,7 +73,7 @@ func TestKubeletConfigCloudConfig(t *testing.T) {
|
|||
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig["--cloud-config"] = "custom.json"
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--cloud-config"] != "custom.json" {
|
||||
t.Fatalf("got unexpected '--cloud-config' kubelet config default value: %s",
|
||||
|
@ -84,7 +84,7 @@ func TestKubeletConfigCloudConfig(t *testing.T) {
|
|||
func TestKubeletConfigAzureContainerRegistryCofig(t *testing.T) {
|
||||
// Test default value and custom value for --azure-container-registry-config
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--azure-container-registry-config"] != "/etc/kubernetes/azure.json" {
|
||||
t.Fatalf("got unexpected '--azure-container-registry-config' kubelet config default value: %s",
|
||||
|
@ -93,7 +93,7 @@ func TestKubeletConfigAzureContainerRegistryCofig(t *testing.T) {
|
|||
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig["--azure-container-registry-config"] = "custom.json"
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--azure-container-registry-config"] != "custom.json" {
|
||||
t.Fatalf("got unexpected '--azure-container-registry-config' kubelet config default value: %s",
|
||||
|
@ -105,7 +105,7 @@ func TestKubeletConfigNetworkPlugin(t *testing.T) {
|
|||
// Test NetworkPlugin = "kubenet"
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginKubenet
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--network-plugin"] != NetworkPluginKubenet {
|
||||
t.Fatalf("got unexpected '--network-plugin' kubelet config value for NetworkPlugin=kubenet: %s",
|
||||
|
@ -115,7 +115,7 @@ func TestKubeletConfigNetworkPlugin(t *testing.T) {
|
|||
// Test NetworkPlugin = "azure"
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginAzure
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--network-plugin"] != "cni" {
|
||||
t.Fatalf("got unexpected '--network-plugin' kubelet config value for NetworkPlugin=azure: %s",
|
||||
|
@ -128,7 +128,7 @@ func TestKubeletConfigEnableSecureKubelet(t *testing.T) {
|
|||
// Test EnableSecureKubelet = true
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet = helpers.PointerToBool(true)
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--anonymous-auth"] != "false" {
|
||||
t.Fatalf("got unexpected '--anonymous-auth' kubelet config value for EnableSecureKubelet=true: %s",
|
||||
|
@ -146,7 +146,7 @@ func TestKubeletConfigEnableSecureKubelet(t *testing.T) {
|
|||
// Test EnableSecureKubelet = false
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet = helpers.PointerToBool(false)
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
for _, key := range []string{"--anonymous-auth", "--client-ca-file"} {
|
||||
if _, ok := k[key]; ok {
|
||||
|
@ -160,7 +160,7 @@ func TestKubeletConfigEnableSecureKubelet(t *testing.T) {
|
|||
func TestKubeletMaxPods(t *testing.T) {
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginAzure
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--max-pods"] != strconv.Itoa(DefaultKubernetesMaxPodsVNETIntegrated) {
|
||||
t.Fatalf("got unexpected '--max-pods' kubelet config value for NetworkPolicy=%s: %s",
|
||||
|
@ -169,7 +169,7 @@ func TestKubeletMaxPods(t *testing.T) {
|
|||
|
||||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginKubenet
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--max-pods"] != strconv.Itoa(DefaultKubernetesMaxPods) {
|
||||
t.Fatalf("got unexpected '--max-pods' kubelet config value for NetworkPolicy=%s: %s",
|
||||
|
@ -180,7 +180,7 @@ func TestKubeletMaxPods(t *testing.T) {
|
|||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginKubenet
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig["--max-pods"] = "99"
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--max-pods"] != "99" {
|
||||
t.Fatalf("got unexpected '--max-pods' kubelet config value for NetworkPolicy=%s: %s",
|
||||
|
@ -190,7 +190,7 @@ func TestKubeletMaxPods(t *testing.T) {
|
|||
cs = CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = NetworkPluginAzure
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig["--max-pods"] = "99"
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--max-pods"] != "99" {
|
||||
t.Fatalf("got unexpected '--max-pods' kubelet config value for NetworkPolicy=%s: %s",
|
||||
|
@ -201,7 +201,7 @@ func TestKubeletMaxPods(t *testing.T) {
|
|||
func TestKubeletCalico(t *testing.T) {
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.NetworkPolicy = NetworkPolicyCalico
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig
|
||||
if k["--network-plugin"] != "cni" {
|
||||
t.Fatalf("got unexpected '--network-plugin' kubelet config value for NetworkPolicy=%s: %s",
|
|
@ -0,0 +1,96 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
"github.com/Azure/acs-engine/pkg/openshift/certgen/release39"
|
||||
"github.com/Azure/acs-engine/pkg/openshift/certgen/unstable"
|
||||
)
|
||||
|
||||
// setOpenShiftSetDefaultCerts sets default certificate and configuration properties in the
|
||||
// openshift orchestrator.
|
||||
func setOpenShiftSetDefaultCerts(a *Properties, orchestratorName, clusterID string) (bool, error) {
|
||||
if len(a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["master"]) > 0 &&
|
||||
len(a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["bootstrap"]) > 0 {
|
||||
return true, nil
|
||||
}
|
||||
if a.OrchestratorProfile.OpenShiftConfig.ConfigBundles == nil {
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles = make(map[string][]byte)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
var masterBundle, nodeBundle []byte
|
||||
|
||||
switch a.OrchestratorProfile.OrchestratorVersion {
|
||||
case common.OpenShiftVersion3Dot9Dot0:
|
||||
c := createR39Config(a, orchestratorName, clusterID)
|
||||
masterBundle, nodeBundle, err = release39.OpenShiftSetDefaultCerts(c)
|
||||
default:
|
||||
c := createUnstableReleaseConfig(a, orchestratorName, clusterID)
|
||||
masterBundle, nodeBundle, err = unstable.OpenShiftSetDefaultCerts(c)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["master"] = masterBundle
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["bootstrap"] = nodeBundle
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func createR39Config(a *Properties, orchestratorName, clusterID string) *release39.Config {
|
||||
return &release39.Config{
|
||||
Master: &release39.Master{
|
||||
Hostname: fmt.Sprintf("%s-master-%s-0", orchestratorName, clusterID),
|
||||
IPs: []net.IP{
|
||||
net.ParseIP(a.MasterProfile.FirstConsecutiveStaticIP),
|
||||
},
|
||||
Port: 8443,
|
||||
},
|
||||
ExternalMasterHostname: fmt.Sprintf("%s.%s.cloudapp.azure.com", a.MasterProfile.DNSPrefix, a.AzProfile.Location),
|
||||
ClusterUsername: a.OrchestratorProfile.OpenShiftConfig.ClusterUsername,
|
||||
ClusterPassword: a.OrchestratorProfile.OpenShiftConfig.ClusterPassword,
|
||||
EnableAADAuthentication: a.OrchestratorProfile.OpenShiftConfig.EnableAADAuthentication,
|
||||
AzureConfig: release39.AzureConfig{
|
||||
TenantID: a.AzProfile.TenantID,
|
||||
SubscriptionID: a.AzProfile.SubscriptionID,
|
||||
AADClientID: a.ServicePrincipalProfile.ClientID,
|
||||
AADClientSecret: a.ServicePrincipalProfile.Secret,
|
||||
ResourceGroup: a.AzProfile.ResourceGroup,
|
||||
Location: a.AzProfile.Location,
|
||||
SecurityGroupName: fmt.Sprintf("%s-master-%s-nsg", orchestratorName, clusterID),
|
||||
PrimaryAvailabilitySetName: fmt.Sprintf("compute-availabilityset-%s", clusterID),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func createUnstableReleaseConfig(a *Properties, orchestratorName, clusterID string) *unstable.Config {
|
||||
return &unstable.Config{
|
||||
Master: &unstable.Master{
|
||||
Hostname: fmt.Sprintf("%s-master-%s-0", orchestratorName, clusterID),
|
||||
IPs: []net.IP{
|
||||
net.ParseIP(a.MasterProfile.FirstConsecutiveStaticIP),
|
||||
},
|
||||
Port: 8443,
|
||||
},
|
||||
ExternalMasterHostname: fmt.Sprintf("%s.%s.cloudapp.azure.com", a.MasterProfile.DNSPrefix, a.AzProfile.Location),
|
||||
ClusterUsername: a.OrchestratorProfile.OpenShiftConfig.ClusterUsername,
|
||||
ClusterPassword: a.OrchestratorProfile.OpenShiftConfig.ClusterPassword,
|
||||
EnableAADAuthentication: a.OrchestratorProfile.OpenShiftConfig.EnableAADAuthentication,
|
||||
AzureConfig: unstable.AzureConfig{
|
||||
TenantID: a.AzProfile.TenantID,
|
||||
SubscriptionID: a.AzProfile.SubscriptionID,
|
||||
AADClientID: a.ServicePrincipalProfile.ClientID,
|
||||
AADClientSecret: a.ServicePrincipalProfile.Secret,
|
||||
ResourceGroup: a.AzProfile.ResourceGroup,
|
||||
Location: a.AzProfile.Location,
|
||||
SecurityGroupName: fmt.Sprintf("%s-master-%s-nsg", orchestratorName, clusterID),
|
||||
PrimaryAvailabilitySetName: fmt.Sprintf("compute-availabilityset-%s", clusterID),
|
||||
},
|
||||
}
|
||||
}
|
|
@ -1,8 +1,4 @@
|
|||
package acsengine
|
||||
|
||||
import (
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
)
|
||||
package api
|
||||
|
||||
// staticSchedulerConfig is not user-overridable
|
||||
var staticSchedulerConfig = map[string]string{
|
||||
|
@ -16,7 +12,7 @@ var defaultSchedulerConfig = map[string]string{
|
|||
"--v": "2",
|
||||
}
|
||||
|
||||
func setSchedulerConfig(cs *api.ContainerService) {
|
||||
func (cs *ContainerService) setSchedulerConfig() {
|
||||
o := cs.Properties.OrchestratorProfile
|
||||
|
||||
// If no user-configurable scheduler config values exists, use the defaults
|
|
@ -1,4 +1,4 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
func TestSchedulerDefaultConfig(t *testing.T) {
|
||||
cs := CreateMockContainerService("testcluster", "1.9.6", 3, 2, false)
|
||||
setSchedulerConfig(cs)
|
||||
cs.setSchedulerConfig()
|
||||
s := cs.Properties.OrchestratorProfile.KubernetesConfig.SchedulerConfig
|
||||
for key, val := range staticSchedulerConfig {
|
||||
if val != s[key] {
|
||||
|
@ -23,13 +23,13 @@ func TestSchedulerDefaultConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSchedulerUserConfig(t *testing.T) {
|
||||
cs := CreateMockContainerService("testcluster", "1.9.6", 3, 2, false)
|
||||
cs := CreateMockContainerService("testcluster", "1.9.6", 3, 2, true)
|
||||
assignmentMap := map[string]string{
|
||||
"--scheduler-name": "my-custom-name",
|
||||
"--feature-gates": "APIListChunking=true,APIResponseCompression=true,Accelerators=true,AdvancedAuditing=true",
|
||||
}
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.SchedulerConfig = assignmentMap
|
||||
setSchedulerConfig(cs)
|
||||
cs.setSchedulerConfig()
|
||||
for key, val := range assignmentMap {
|
||||
if val != cs.Properties.OrchestratorProfile.KubernetesConfig.SchedulerConfig[key] {
|
||||
t.Fatalf("got unexpected kube-scheduler config value for %s. Expected %s, got %s",
|
||||
|
@ -45,7 +45,7 @@ func TestSchedulerStaticConfig(t *testing.T) {
|
|||
"--leader-elect": "user-override",
|
||||
"--profiling": "user-override",
|
||||
}
|
||||
setSchedulerConfig(cs)
|
||||
cs.setSchedulerConfig()
|
||||
for key, val := range staticSchedulerConfig {
|
||||
if val != cs.Properties.OrchestratorProfile.KubernetesConfig.SchedulerConfig[key] {
|
||||
t.Fatalf("kube-scheduler static config did not override user values for %s. Expected %s, got %s",
|
|
@ -1,4 +1,4 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -10,55 +10,42 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
"github.com/Azure/acs-engine/pkg/openshift/certgen"
|
||||
"github.com/blang/semver"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
// AzureCniPluginVerLinux specifies version of Azure CNI plugin, which has been mirrored from
|
||||
// https://github.com/Azure/azure-container-networking/releases/download/${AZURE_PLUGIN_VER}/azure-vnet-cni-linux-amd64-${AZURE_PLUGIN_VER}.tgz
|
||||
// to https://acs-mirror.azureedge.net/cni
|
||||
AzureCniPluginVerLinux = "v1.0.11"
|
||||
// AzureCniPluginVerWindows specifies version of Azure CNI plugin, which has been mirrored from
|
||||
// https://github.com/Azure/azure-container-networking/releases/download/${AZURE_PLUGIN_VER}/azure-vnet-cni-windows-amd64-${AZURE_PLUGIN_VER}.tgz
|
||||
// to https://acs-mirror.azureedge.net/cni
|
||||
AzureCniPluginVerWindows = "v1.0.11"
|
||||
)
|
||||
|
||||
// setPropertiesDefaults for the container Properties, returns true if certs are generated
|
||||
func setPropertiesDefaults(cs *api.ContainerService, isUpgrade, isScale bool) (bool, error) {
|
||||
// SetPropertiesDefaults for the container Properties, returns true if certs are generated
|
||||
func (cs *ContainerService) SetPropertiesDefaults(isUpgrade, isScale bool) (bool, error) {
|
||||
properties := cs.Properties
|
||||
|
||||
setOrchestratorDefaults(cs, isUpgrade || isScale)
|
||||
cs.setOrchestratorDefaults(isUpgrade || isScale)
|
||||
|
||||
// Set master profile defaults if this cluster configuration includes master node(s)
|
||||
if cs.Properties.MasterProfile != nil {
|
||||
setMasterProfileDefaults(properties, isUpgrade)
|
||||
properties.setMasterProfileDefaults(isUpgrade)
|
||||
}
|
||||
// Set VMSS Defaults for Masters
|
||||
if cs.Properties.MasterProfile != nil && cs.Properties.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
setVMSSDefaultsForMasters(properties)
|
||||
properties.setVMSSDefaultsForMasters()
|
||||
}
|
||||
|
||||
setAgentProfileDefaults(properties, isUpgrade, isScale)
|
||||
properties.setAgentProfileDefaults(isUpgrade, isScale)
|
||||
|
||||
setStorageDefaults(properties)
|
||||
setExtensionDefaults(properties)
|
||||
properties.setStorageDefaults()
|
||||
properties.setExtensionDefaults()
|
||||
// Set VMSS Defaults for Agents
|
||||
if cs.Properties.HasVMSSAgentPool() {
|
||||
setVMSSDefaultsForAgents(properties)
|
||||
properties.setVMSSDefaultsForAgents()
|
||||
}
|
||||
|
||||
// Set hosted master profile defaults if this cluster configuration has a hosted control plane
|
||||
if cs.Properties.HostedMasterProfile != nil {
|
||||
setHostedMasterProfileDefaults(properties)
|
||||
properties.setHostedMasterProfileDefaults()
|
||||
}
|
||||
|
||||
certsGenerated, e := setDefaultCerts(properties)
|
||||
certsGenerated, e := properties.setDefaultCerts()
|
||||
if e != nil {
|
||||
return false, e
|
||||
}
|
||||
|
@ -66,7 +53,7 @@ func setPropertiesDefaults(cs *api.ContainerService, isUpgrade, isScale bool) (b
|
|||
}
|
||||
|
||||
// setOrchestratorDefaults for orchestrators
|
||||
func setOrchestratorDefaults(cs *api.ContainerService, isUpdate bool) {
|
||||
func (cs *ContainerService) setOrchestratorDefaults(isUpdate bool) {
|
||||
a := cs.Properties
|
||||
|
||||
cloudSpecConfig := cs.GetCloudSpecConfig()
|
||||
|
@ -79,9 +66,9 @@ func setOrchestratorDefaults(cs *api.ContainerService, isUpdate bool) {
|
|||
o.OrchestratorVersion, isUpdate, a.HasWindows())
|
||||
|
||||
switch o.OrchestratorType {
|
||||
case api.Kubernetes:
|
||||
case Kubernetes:
|
||||
if o.KubernetesConfig == nil {
|
||||
o.KubernetesConfig = &api.KubernetesConfig{}
|
||||
o.KubernetesConfig = &KubernetesConfig{}
|
||||
}
|
||||
// For backwards compatibility with original, overloaded "NetworkPolicy" config vector
|
||||
// we translate deprecated NetworkPolicy usage to the NetworkConfig equivalent
|
||||
|
@ -161,11 +148,11 @@ func setOrchestratorDefaults(cs *api.ContainerService, isUpdate bool) {
|
|||
}
|
||||
|
||||
if o.KubernetesConfig.PrivateCluster == nil {
|
||||
o.KubernetesConfig.PrivateCluster = &api.PrivateCluster{}
|
||||
o.KubernetesConfig.PrivateCluster = &PrivateCluster{}
|
||||
}
|
||||
|
||||
if o.KubernetesConfig.PrivateCluster.Enabled == nil {
|
||||
o.KubernetesConfig.PrivateCluster.Enabled = helpers.PointerToBool(api.DefaultPrivateClusterEnabled)
|
||||
o.KubernetesConfig.PrivateCluster.Enabled = helpers.PointerToBool(DefaultPrivateClusterEnabled)
|
||||
}
|
||||
|
||||
if "" == a.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB {
|
||||
|
@ -196,7 +183,7 @@ func setOrchestratorDefaults(cs *api.ContainerService, isUpdate bool) {
|
|||
}
|
||||
|
||||
if a.OrchestratorProfile.KubernetesConfig.PrivateJumpboxProvision() && a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile == "" {
|
||||
a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile = api.ManagedDisks
|
||||
a.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile = ManagedDisks
|
||||
}
|
||||
|
||||
if !helpers.IsFalseBoolPointer(a.OrchestratorProfile.KubernetesConfig.EnableRbac) {
|
||||
|
@ -205,24 +192,24 @@ func setOrchestratorDefaults(cs *api.ContainerService, isUpdate bool) {
|
|||
a.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs = true
|
||||
}
|
||||
if a.OrchestratorProfile.KubernetesConfig.EnableRbac == nil {
|
||||
a.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(api.DefaultRBACEnabled)
|
||||
a.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(DefaultRBACEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
if a.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet == nil {
|
||||
a.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet = helpers.PointerToBool(api.DefaultSecureKubeletEnabled)
|
||||
a.OrchestratorProfile.KubernetesConfig.EnableSecureKubelet = helpers.PointerToBool(DefaultSecureKubeletEnabled)
|
||||
}
|
||||
|
||||
if a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata == nil {
|
||||
a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata = helpers.PointerToBool(api.DefaultUseInstanceMetadata)
|
||||
a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata = helpers.PointerToBool(DefaultUseInstanceMetadata)
|
||||
}
|
||||
|
||||
if !a.HasAvailabilityZones() && a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "" {
|
||||
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = api.DefaultLoadBalancerSku
|
||||
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = DefaultLoadBalancerSku
|
||||
}
|
||||
|
||||
if common.IsKubernetesVersionGe(a.OrchestratorProfile.OrchestratorVersion, "1.11.0") && a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "Standard" && a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB == nil {
|
||||
a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = helpers.PointerToBool(api.DefaultExcludeMasterFromStandardLB)
|
||||
a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = helpers.PointerToBool(DefaultExcludeMasterFromStandardLB)
|
||||
}
|
||||
|
||||
if a.OrchestratorProfile.IsAzureCNI() {
|
||||
|
@ -234,36 +221,36 @@ func setOrchestratorDefaults(cs *api.ContainerService, isUpdate bool) {
|
|||
}
|
||||
|
||||
// Configure addons
|
||||
setAddonsConfig(cs)
|
||||
cs.setAddonsConfig()
|
||||
// Configure kubelet
|
||||
setKubeletConfig(cs)
|
||||
cs.setKubeletConfig()
|
||||
// Configure controller-manager
|
||||
setControllerManagerConfig(cs)
|
||||
cs.setControllerManagerConfig()
|
||||
// Configure cloud-controller-manager
|
||||
setCloudControllerManagerConfig(cs)
|
||||
cs.setCloudControllerManagerConfig()
|
||||
// Configure apiserver
|
||||
setAPIServerConfig(cs)
|
||||
cs.setAPIServerConfig()
|
||||
// Configure scheduler
|
||||
setSchedulerConfig(cs)
|
||||
cs.setSchedulerConfig()
|
||||
|
||||
case api.DCOS:
|
||||
case DCOS:
|
||||
if o.DcosConfig == nil {
|
||||
o.DcosConfig = &api.DcosConfig{}
|
||||
o.DcosConfig = &DcosConfig{}
|
||||
}
|
||||
dcosSemVer, _ := semver.Make(o.OrchestratorVersion)
|
||||
dcosBootstrapSemVer, _ := semver.Make(common.DCOSVersion1Dot11Dot0)
|
||||
if !dcosSemVer.LT(dcosBootstrapSemVer) {
|
||||
if o.DcosConfig.BootstrapProfile == nil {
|
||||
o.DcosConfig.BootstrapProfile = &api.BootstrapProfile{}
|
||||
o.DcosConfig.BootstrapProfile = &BootstrapProfile{}
|
||||
}
|
||||
if len(o.DcosConfig.BootstrapProfile.VMSize) == 0 {
|
||||
o.DcosConfig.BootstrapProfile.VMSize = "Standard_D2s_v3"
|
||||
}
|
||||
}
|
||||
case api.OpenShift:
|
||||
case OpenShift:
|
||||
kc := a.OrchestratorProfile.OpenShiftConfig.KubernetesConfig
|
||||
if kc == nil {
|
||||
kc = &api.KubernetesConfig{}
|
||||
kc = &KubernetesConfig{}
|
||||
}
|
||||
if kc.ContainerRuntime == "" {
|
||||
kc.ContainerRuntime = DefaultContainerRuntime
|
||||
|
@ -274,151 +261,151 @@ func setOrchestratorDefaults(cs *api.ContainerService, isUpdate bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func setExtensionDefaults(a *api.Properties) {
|
||||
if a.ExtensionProfiles == nil {
|
||||
func (p *Properties) setExtensionDefaults() {
|
||||
if p.ExtensionProfiles == nil {
|
||||
return
|
||||
}
|
||||
for _, extension := range a.ExtensionProfiles {
|
||||
for _, extension := range p.ExtensionProfiles {
|
||||
if extension.RootURL == "" {
|
||||
extension.RootURL = DefaultExtensionsRootURL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setMasterProfileDefaults(a *api.Properties, isUpgrade bool) {
|
||||
if a.MasterProfile.Distro == "" {
|
||||
if a.OrchestratorProfile.IsKubernetes() {
|
||||
a.MasterProfile.Distro = api.AKS
|
||||
} else if !a.OrchestratorProfile.IsOpenShift() {
|
||||
a.MasterProfile.Distro = api.Ubuntu
|
||||
func (p *Properties) setMasterProfileDefaults(isUpgrade bool) {
|
||||
if p.MasterProfile.Distro == "" {
|
||||
if p.OrchestratorProfile.IsKubernetes() {
|
||||
p.MasterProfile.Distro = AKS
|
||||
} else if !p.OrchestratorProfile.IsOpenShift() {
|
||||
p.MasterProfile.Distro = Ubuntu
|
||||
}
|
||||
}
|
||||
// set default to VMAS for now
|
||||
if len(a.MasterProfile.AvailabilityProfile) == 0 {
|
||||
a.MasterProfile.AvailabilityProfile = api.AvailabilitySet
|
||||
if len(p.MasterProfile.AvailabilityProfile) == 0 {
|
||||
p.MasterProfile.AvailabilityProfile = AvailabilitySet
|
||||
}
|
||||
|
||||
if !a.MasterProfile.IsCustomVNET() {
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
if a.OrchestratorProfile.IsAzureCNI() {
|
||||
if !p.MasterProfile.IsCustomVNET() {
|
||||
if p.OrchestratorProfile.OrchestratorType == Kubernetes {
|
||||
if p.OrchestratorProfile.IsAzureCNI() {
|
||||
// When VNET integration is enabled, all masters, agents and pods share the same large subnet.
|
||||
a.MasterProfile.Subnet = a.OrchestratorProfile.KubernetesConfig.ClusterSubnet
|
||||
p.MasterProfile.Subnet = p.OrchestratorProfile.KubernetesConfig.ClusterSubnet
|
||||
// FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
|
||||
if !isUpgrade || len(a.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
if a.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = api.DefaultFirstConsecutiveKubernetesStaticIPVMSS
|
||||
a.MasterProfile.Subnet = DefaultKubernetesMasterSubnet
|
||||
a.MasterProfile.AgentSubnet = DefaultKubernetesAgentSubnetVMSS
|
||||
if !isUpgrade || len(p.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
if p.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIPVMSS
|
||||
p.MasterProfile.Subnet = DefaultKubernetesMasterSubnet
|
||||
p.MasterProfile.AgentSubnet = DefaultKubernetesAgentSubnetVMSS
|
||||
} else {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = a.MasterProfile.GetFirstConsecutiveStaticIPAddress(a.MasterProfile.Subnet)
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = p.MasterProfile.GetFirstConsecutiveStaticIPAddress(p.MasterProfile.Subnet)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
a.MasterProfile.Subnet = DefaultKubernetesMasterSubnet
|
||||
p.MasterProfile.Subnet = DefaultKubernetesMasterSubnet
|
||||
// FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
|
||||
if !isUpgrade || len(a.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
if a.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = api.DefaultFirstConsecutiveKubernetesStaticIPVMSS
|
||||
a.MasterProfile.AgentSubnet = DefaultKubernetesAgentSubnetVMSS
|
||||
if !isUpgrade || len(p.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
if p.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIPVMSS
|
||||
p.MasterProfile.AgentSubnet = DefaultKubernetesAgentSubnetVMSS
|
||||
} else {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = api.DefaultFirstConsecutiveKubernetesStaticIP
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIP
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if a.OrchestratorProfile.OrchestratorType == api.OpenShift {
|
||||
a.MasterProfile.Subnet = DefaultOpenShiftMasterSubnet
|
||||
if !isUpgrade || len(a.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = DefaultOpenShiftFirstConsecutiveStaticIP
|
||||
} else if p.OrchestratorProfile.OrchestratorType == OpenShift {
|
||||
p.MasterProfile.Subnet = DefaultOpenShiftMasterSubnet
|
||||
if !isUpgrade || len(p.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = DefaultOpenShiftFirstConsecutiveStaticIP
|
||||
}
|
||||
} else if a.OrchestratorProfile.OrchestratorType == api.DCOS {
|
||||
a.MasterProfile.Subnet = DefaultDCOSMasterSubnet
|
||||
} else if p.OrchestratorProfile.OrchestratorType == DCOS {
|
||||
p.MasterProfile.Subnet = DefaultDCOSMasterSubnet
|
||||
// FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
|
||||
if !isUpgrade || len(a.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = DefaultDCOSFirstConsecutiveStaticIP
|
||||
if !isUpgrade || len(p.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = DefaultDCOSFirstConsecutiveStaticIP
|
||||
}
|
||||
if a.OrchestratorProfile.DcosConfig != nil && a.OrchestratorProfile.DcosConfig.BootstrapProfile != nil {
|
||||
if !isUpgrade || len(a.OrchestratorProfile.DcosConfig.BootstrapProfile.StaticIP) == 0 {
|
||||
a.OrchestratorProfile.DcosConfig.BootstrapProfile.StaticIP = DefaultDCOSBootstrapStaticIP
|
||||
if p.OrchestratorProfile.DcosConfig != nil && p.OrchestratorProfile.DcosConfig.BootstrapProfile != nil {
|
||||
if !isUpgrade || len(p.OrchestratorProfile.DcosConfig.BootstrapProfile.StaticIP) == 0 {
|
||||
p.OrchestratorProfile.DcosConfig.BootstrapProfile.StaticIP = DefaultDCOSBootstrapStaticIP
|
||||
}
|
||||
}
|
||||
} else if a.HasWindows() {
|
||||
a.MasterProfile.Subnet = DefaultSwarmWindowsMasterSubnet
|
||||
} else if p.HasWindows() {
|
||||
p.MasterProfile.Subnet = DefaultSwarmWindowsMasterSubnet
|
||||
// FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
|
||||
if !isUpgrade || len(a.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = DefaultSwarmWindowsFirstConsecutiveStaticIP
|
||||
if !isUpgrade || len(p.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = DefaultSwarmWindowsFirstConsecutiveStaticIP
|
||||
}
|
||||
} else {
|
||||
a.MasterProfile.Subnet = DefaultMasterSubnet
|
||||
p.MasterProfile.Subnet = DefaultMasterSubnet
|
||||
// FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
|
||||
if !isUpgrade || len(a.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveStaticIP
|
||||
if !isUpgrade || len(p.MasterProfile.FirstConsecutiveStaticIP) == 0 {
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = DefaultFirstConsecutiveStaticIP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if a.MasterProfile.IsCustomVNET() && a.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
a.MasterProfile.FirstConsecutiveStaticIP = a.MasterProfile.GetFirstConsecutiveStaticIPAddress(a.MasterProfile.VnetCidr)
|
||||
if p.MasterProfile.IsCustomVNET() && p.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
if p.OrchestratorProfile.OrchestratorType == Kubernetes {
|
||||
p.MasterProfile.FirstConsecutiveStaticIP = p.MasterProfile.GetFirstConsecutiveStaticIPAddress(p.MasterProfile.VnetCidr)
|
||||
}
|
||||
}
|
||||
// Set the default number of IP addresses allocated for masters.
|
||||
if a.MasterProfile.IPAddressCount == 0 {
|
||||
if p.MasterProfile.IPAddressCount == 0 {
|
||||
// Allocate one IP address for the node.
|
||||
a.MasterProfile.IPAddressCount = 1
|
||||
p.MasterProfile.IPAddressCount = 1
|
||||
|
||||
// Allocate IP addresses for pods if VNET integration is enabled.
|
||||
if a.OrchestratorProfile.IsAzureCNI() {
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
masterMaxPods, _ := strconv.Atoi(a.MasterProfile.KubernetesConfig.KubeletConfig["--max-pods"])
|
||||
a.MasterProfile.IPAddressCount += masterMaxPods
|
||||
if p.OrchestratorProfile.IsAzureCNI() {
|
||||
if p.OrchestratorProfile.OrchestratorType == Kubernetes {
|
||||
masterMaxPods, _ := strconv.Atoi(p.MasterProfile.KubernetesConfig.KubeletConfig["--max-pods"])
|
||||
p.MasterProfile.IPAddressCount += masterMaxPods
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if a.MasterProfile.HTTPSourceAddressPrefix == "" {
|
||||
a.MasterProfile.HTTPSourceAddressPrefix = "*"
|
||||
if p.MasterProfile.HTTPSourceAddressPrefix == "" {
|
||||
p.MasterProfile.HTTPSourceAddressPrefix = "*"
|
||||
}
|
||||
}
|
||||
|
||||
// setVMSSDefaultsForMasters
|
||||
func setVMSSDefaultsForMasters(a *api.Properties) {
|
||||
if a.MasterProfile.SinglePlacementGroup == nil {
|
||||
a.MasterProfile.SinglePlacementGroup = helpers.PointerToBool(api.DefaultSinglePlacementGroup)
|
||||
func (p *Properties) setVMSSDefaultsForMasters() {
|
||||
if p.MasterProfile.SinglePlacementGroup == nil {
|
||||
p.MasterProfile.SinglePlacementGroup = helpers.PointerToBool(DefaultSinglePlacementGroup)
|
||||
}
|
||||
if a.MasterProfile.HasAvailabilityZones() && (a.OrchestratorProfile.KubernetesConfig != nil && a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "") {
|
||||
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = "Standard"
|
||||
a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = helpers.PointerToBool(api.DefaultExcludeMasterFromStandardLB)
|
||||
if p.MasterProfile.HasAvailabilityZones() && (p.OrchestratorProfile.KubernetesConfig != nil && p.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "") {
|
||||
p.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = "Standard"
|
||||
p.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = helpers.PointerToBool(DefaultExcludeMasterFromStandardLB)
|
||||
}
|
||||
}
|
||||
|
||||
// setVMSSDefaultsForAgents
|
||||
func setVMSSDefaultsForAgents(a *api.Properties) {
|
||||
for _, profile := range a.AgentPoolProfiles {
|
||||
if profile.AvailabilityProfile == api.VirtualMachineScaleSets {
|
||||
func (p *Properties) setVMSSDefaultsForAgents() {
|
||||
for _, profile := range p.AgentPoolProfiles {
|
||||
if profile.AvailabilityProfile == VirtualMachineScaleSets {
|
||||
if profile.Count > 100 {
|
||||
profile.SinglePlacementGroup = helpers.PointerToBool(false)
|
||||
}
|
||||
if profile.SinglePlacementGroup == nil {
|
||||
profile.SinglePlacementGroup = helpers.PointerToBool(api.DefaultSinglePlacementGroup)
|
||||
profile.SinglePlacementGroup = helpers.PointerToBool(DefaultSinglePlacementGroup)
|
||||
}
|
||||
if profile.HasAvailabilityZones() && (a.OrchestratorProfile.KubernetesConfig != nil && a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "") {
|
||||
a.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = "Standard"
|
||||
a.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = helpers.PointerToBool(api.DefaultExcludeMasterFromStandardLB)
|
||||
if profile.HasAvailabilityZones() && (p.OrchestratorProfile.KubernetesConfig != nil && p.OrchestratorProfile.KubernetesConfig.LoadBalancerSku == "") {
|
||||
p.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = "Standard"
|
||||
p.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB = helpers.PointerToBool(DefaultExcludeMasterFromStandardLB)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func setAgentProfileDefaults(a *api.Properties, isUpgrade, isScale bool) {
|
||||
func (p *Properties) setAgentProfileDefaults(isUpgrade, isScale bool) {
|
||||
// configure the subnets if not in custom VNET
|
||||
if a.MasterProfile != nil && !a.MasterProfile.IsCustomVNET() {
|
||||
if p.MasterProfile != nil && !p.MasterProfile.IsCustomVNET() {
|
||||
subnetCounter := 0
|
||||
for _, profile := range a.AgentPoolProfiles {
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes ||
|
||||
a.OrchestratorProfile.OrchestratorType == api.OpenShift {
|
||||
if !a.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
profile.Subnet = a.MasterProfile.Subnet
|
||||
for _, profile := range p.AgentPoolProfiles {
|
||||
if p.OrchestratorProfile.OrchestratorType == Kubernetes ||
|
||||
p.OrchestratorProfile.OrchestratorType == OpenShift {
|
||||
if !p.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
profile.Subnet = p.MasterProfile.Subnet
|
||||
}
|
||||
} else {
|
||||
profile.Subnet = fmt.Sprintf(DefaultAgentSubnetTemplate, subnetCounter)
|
||||
|
@ -428,10 +415,10 @@ func setAgentProfileDefaults(a *api.Properties, isUpgrade, isScale bool) {
|
|||
}
|
||||
}
|
||||
|
||||
for _, profile := range a.AgentPoolProfiles {
|
||||
for _, profile := range p.AgentPoolProfiles {
|
||||
// set default OSType to Linux
|
||||
if profile.OSType == "" {
|
||||
profile.OSType = api.Linux
|
||||
profile.OSType = Linux
|
||||
}
|
||||
|
||||
// Accelerated Networking is supported on most general purpose and compute-optimized instance sizes with 2 or more vCPUs.
|
||||
|
@ -443,18 +430,18 @@ func setAgentProfileDefaults(a *api.Properties, isUpgrade, isScale bool) {
|
|||
}
|
||||
|
||||
if profile.AcceleratedNetworkingEnabledWindows == nil {
|
||||
profile.AcceleratedNetworkingEnabledWindows = helpers.PointerToBool(api.DefaultAcceleratedNetworkingWindowsEnabled)
|
||||
profile.AcceleratedNetworkingEnabledWindows = helpers.PointerToBool(DefaultAcceleratedNetworkingWindowsEnabled)
|
||||
}
|
||||
|
||||
if profile.Distro == "" && profile.OSType != api.Windows {
|
||||
if a.OrchestratorProfile.IsKubernetes() {
|
||||
if profile.OSDiskSizeGB != 0 && profile.OSDiskSizeGB < api.VHDDiskSizeAKS {
|
||||
profile.Distro = api.Ubuntu
|
||||
if profile.Distro == "" && profile.OSType != Windows {
|
||||
if p.OrchestratorProfile.IsKubernetes() {
|
||||
if profile.OSDiskSizeGB != 0 && profile.OSDiskSizeGB < VHDDiskSizeAKS {
|
||||
profile.Distro = Ubuntu
|
||||
} else {
|
||||
profile.Distro = api.AKS
|
||||
profile.Distro = AKS
|
||||
}
|
||||
} else if !a.OrchestratorProfile.IsOpenShift() {
|
||||
profile.Distro = api.Ubuntu
|
||||
} else if !p.OrchestratorProfile.IsOpenShift() {
|
||||
profile.Distro = Ubuntu
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,7 +451,7 @@ func setAgentProfileDefaults(a *api.Properties, isUpgrade, isScale bool) {
|
|||
profile.IPAddressCount = 1
|
||||
|
||||
// Allocate IP addresses for pods if VNET integration is enabled.
|
||||
if a.OrchestratorProfile.IsAzureCNI() {
|
||||
if p.OrchestratorProfile.IsAzureCNI() {
|
||||
agentPoolMaxPods, _ := strconv.Atoi(profile.KubernetesConfig.KubeletConfig["--max-pods"])
|
||||
profile.IPAddressCount += agentPoolMaxPods
|
||||
}
|
||||
|
@ -473,45 +460,45 @@ func setAgentProfileDefaults(a *api.Properties, isUpgrade, isScale bool) {
|
|||
}
|
||||
|
||||
// setStorageDefaults for agents
|
||||
func setStorageDefaults(a *api.Properties) {
|
||||
if a.MasterProfile != nil && len(a.MasterProfile.StorageProfile) == 0 {
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
a.MasterProfile.StorageProfile = api.ManagedDisks
|
||||
func (p *Properties) setStorageDefaults() {
|
||||
if p.MasterProfile != nil && len(p.MasterProfile.StorageProfile) == 0 {
|
||||
if p.OrchestratorProfile.OrchestratorType == Kubernetes {
|
||||
p.MasterProfile.StorageProfile = ManagedDisks
|
||||
} else {
|
||||
a.MasterProfile.StorageProfile = api.StorageAccount
|
||||
p.MasterProfile.StorageProfile = StorageAccount
|
||||
}
|
||||
}
|
||||
for _, profile := range a.AgentPoolProfiles {
|
||||
for _, profile := range p.AgentPoolProfiles {
|
||||
if len(profile.StorageProfile) == 0 {
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
||||
profile.StorageProfile = api.ManagedDisks
|
||||
if p.OrchestratorProfile.OrchestratorType == Kubernetes {
|
||||
profile.StorageProfile = ManagedDisks
|
||||
} else {
|
||||
profile.StorageProfile = api.StorageAccount
|
||||
profile.StorageProfile = StorageAccount
|
||||
}
|
||||
}
|
||||
if len(profile.AvailabilityProfile) == 0 {
|
||||
profile.AvailabilityProfile = api.VirtualMachineScaleSets
|
||||
profile.AvailabilityProfile = VirtualMachineScaleSets
|
||||
// VMSS is not supported for k8s below 1.10.2
|
||||
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes && !common.IsKubernetesVersionGe(a.OrchestratorProfile.OrchestratorVersion, "1.10.2") {
|
||||
profile.AvailabilityProfile = api.AvailabilitySet
|
||||
if p.OrchestratorProfile.OrchestratorType == Kubernetes && !common.IsKubernetesVersionGe(p.OrchestratorProfile.OrchestratorVersion, "1.10.2") {
|
||||
profile.AvailabilityProfile = AvailabilitySet
|
||||
}
|
||||
}
|
||||
if len(profile.ScaleSetEvictionPolicy) == 0 && profile.ScaleSetPriority == api.ScaleSetPriorityLow {
|
||||
profile.ScaleSetEvictionPolicy = api.ScaleSetEvictionPolicyDelete
|
||||
if len(profile.ScaleSetEvictionPolicy) == 0 && profile.ScaleSetPriority == ScaleSetPriorityLow {
|
||||
profile.ScaleSetEvictionPolicy = ScaleSetEvictionPolicyDelete
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setHostedMasterProfileDefaults(a *api.Properties) {
|
||||
a.HostedMasterProfile.Subnet = DefaultKubernetesMasterSubnet
|
||||
func (p *Properties) setHostedMasterProfileDefaults() {
|
||||
p.HostedMasterProfile.Subnet = DefaultKubernetesMasterSubnet
|
||||
}
|
||||
|
||||
func setDefaultCerts(p *api.Properties) (bool, error) {
|
||||
if p.MasterProfile != nil && p.OrchestratorProfile.OrchestratorType == api.OpenShift {
|
||||
return certgen.OpenShiftSetDefaultCerts(p, api.DefaultOpenshiftOrchestratorName, p.GetClusterID())
|
||||
func (p *Properties) setDefaultCerts() (bool, error) {
|
||||
if p.MasterProfile != nil && p.OrchestratorProfile.OrchestratorType == OpenShift {
|
||||
return setOpenShiftSetDefaultCerts(p, DefaultOpenshiftOrchestratorName, p.GetClusterID())
|
||||
}
|
||||
|
||||
if p.MasterProfile == nil || p.OrchestratorProfile.OrchestratorType != api.Kubernetes {
|
||||
if p.MasterProfile == nil || p.OrchestratorProfile.OrchestratorType != Kubernetes {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
@ -521,7 +508,12 @@ func setDefaultCerts(p *api.Properties) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
masterExtraFQDNs := append(formatAzureProdFQDNs(p.MasterProfile.DNSPrefix), p.MasterProfile.SubjectAltNames...)
|
||||
var azureProdFQDNs []string
|
||||
for _, location := range helpers.GetAzureLocations() {
|
||||
azureProdFQDNs = append(azureProdFQDNs, FormatAzureProdFQDNByLocation(p.MasterProfile.DNSPrefix, location))
|
||||
}
|
||||
|
||||
masterExtraFQDNs := append(azureProdFQDNs, p.MasterProfile.SubjectAltNames...)
|
||||
firstMasterIP := net.ParseIP(p.MasterProfile.FirstConsecutiveStaticIP).To4()
|
||||
|
||||
if firstMasterIP == nil {
|
||||
|
@ -533,21 +525,19 @@ func setDefaultCerts(p *api.Properties) (bool, error) {
|
|||
ips = append(ips, net.IP{firstMasterIP[0], firstMasterIP[1], firstMasterIP[2], firstMasterIP[3] + byte(DefaultInternalLbStaticIPOffset)})
|
||||
// Include the Internal load balancer as well
|
||||
|
||||
var offsetMultiplier int
|
||||
if p.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
// Include the Internal load balancer as well
|
||||
for i := 1; i < p.MasterProfile.Count; i++ {
|
||||
offset := i * p.MasterProfile.IPAddressCount
|
||||
ip := net.IP{firstMasterIP[0], firstMasterIP[1], firstMasterIP[2], firstMasterIP[3] + byte(offset)}
|
||||
ips = append(ips, ip)
|
||||
}
|
||||
offsetMultiplier = p.MasterProfile.IPAddressCount
|
||||
} else {
|
||||
for i := 1; i < p.MasterProfile.Count; i++ {
|
||||
ip := net.IP{firstMasterIP[0], firstMasterIP[1], firstMasterIP[2], firstMasterIP[3] + byte(i)}
|
||||
ips = append(ips, ip)
|
||||
}
|
||||
offsetMultiplier = 1
|
||||
}
|
||||
for i := 1; i < p.MasterProfile.Count; i++ {
|
||||
offset := i * offsetMultiplier
|
||||
ip := net.IP{firstMasterIP[0], firstMasterIP[1], firstMasterIP[2], firstMasterIP[3] + byte(offset)}
|
||||
ips = append(ips, ip)
|
||||
}
|
||||
if p.CertificateProfile == nil {
|
||||
p.CertificateProfile = &api.CertificateProfile{}
|
||||
p.CertificateProfile = &CertificateProfile{}
|
||||
}
|
||||
|
||||
// use the specified Certificate Authority pair, or generate p new pair
|
||||
|
@ -614,7 +604,7 @@ func areAllTrue(m map[string]bool) bool {
|
|||
}
|
||||
|
||||
// certsAlreadyPresent already present returns a map where each key is a type of cert and each value is true if that cert/key pair is user-provided
|
||||
func certsAlreadyPresent(c *api.CertificateProfile, m int) map[string]bool {
|
||||
func certsAlreadyPresent(c *CertificateProfile, m int) map[string]bool {
|
||||
g := map[string]bool{
|
||||
"ca": false,
|
||||
"apiserver": false,
|
|
@ -1,16 +1,15 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
)
|
||||
|
||||
func TestCertsAlreadyPresent(t *testing.T) {
|
||||
var cert *api.CertificateProfile
|
||||
var cert *CertificateProfile
|
||||
|
||||
result := certsAlreadyPresent(nil, 1)
|
||||
expected := map[string]bool{
|
||||
|
@ -24,7 +23,7 @@ func TestCertsAlreadyPresent(t *testing.T) {
|
|||
if !reflect.DeepEqual(result, expected) {
|
||||
t.Fatalf("certsAlreadyPresent() did not return false for all certs for a non-existent CertificateProfile")
|
||||
}
|
||||
cert = &api.CertificateProfile{}
|
||||
cert = &CertificateProfile{}
|
||||
result = certsAlreadyPresent(cert, 1)
|
||||
expected = map[string]bool{
|
||||
"ca": false,
|
||||
|
@ -37,7 +36,7 @@ func TestCertsAlreadyPresent(t *testing.T) {
|
|||
if !reflect.DeepEqual(result, expected) {
|
||||
t.Fatalf("certsAlreadyPresent() did not return false for all certs for empty CertificateProfile")
|
||||
}
|
||||
cert = &api.CertificateProfile{
|
||||
cert = &CertificateProfile{
|
||||
APIServerCertificate: "a",
|
||||
}
|
||||
result = certsAlreadyPresent(cert, 1)
|
||||
|
@ -53,7 +52,7 @@ func TestCertsAlreadyPresent(t *testing.T) {
|
|||
t.Fatalf("certsAlreadyPresent() did not return false for all certs for 1 cert in CertificateProfile")
|
||||
}
|
||||
|
||||
cert = &api.CertificateProfile{
|
||||
cert = &CertificateProfile{
|
||||
APIServerCertificate: "a",
|
||||
CaCertificate: "c",
|
||||
CaPrivateKey: "d",
|
||||
|
@ -78,7 +77,7 @@ func TestCertsAlreadyPresent(t *testing.T) {
|
|||
if !reflect.DeepEqual(result, expected) {
|
||||
t.Fatalf("certsAlreadyPresent() did not return expected result for some certs in CertificateProfile")
|
||||
}
|
||||
cert = &api.CertificateProfile{
|
||||
cert = &CertificateProfile{
|
||||
APIServerCertificate: "a",
|
||||
APIServerPrivateKey: "b",
|
||||
CaCertificate: "c",
|
||||
|
@ -109,7 +108,7 @@ func TestCertsAlreadyPresent(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetMissingKubeletValues(t *testing.T) {
|
||||
config := &api.KubernetesConfig{}
|
||||
config := &KubernetesConfig{}
|
||||
defaultKubeletConfig := map[string]string{
|
||||
"--network-plugin": "1",
|
||||
"--pod-infra-container-image": "2",
|
||||
|
@ -129,7 +128,7 @@ func TestSetMissingKubeletValues(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
config = &api.KubernetesConfig{
|
||||
config = &KubernetesConfig{
|
||||
KubeletConfig: map[string]string{
|
||||
"--network-plugin": "a",
|
||||
"--pod-infra-container-image": "b",
|
||||
|
@ -154,7 +153,7 @@ func TestSetMissingKubeletValues(t *testing.T) {
|
|||
t.Fatalf("setMissingKubeletValue() did not return the expected value %s for key %s, instead returned: %s", val, key, config.KubeletConfig[key])
|
||||
}
|
||||
}
|
||||
config = &api.KubernetesConfig{
|
||||
config = &KubernetesConfig{
|
||||
KubeletConfig: map[string]string{},
|
||||
}
|
||||
setMissingKubeletValues(config, defaultKubeletConfig)
|
||||
|
@ -167,7 +166,7 @@ func TestSetMissingKubeletValues(t *testing.T) {
|
|||
|
||||
func TestAddonsIndexByName(t *testing.T) {
|
||||
addonName := "testaddon"
|
||||
addons := []api.KubernetesAddon{
|
||||
addons := []KubernetesAddon{
|
||||
getMockAddon(addonName),
|
||||
}
|
||||
i := getAddonsIndexByName(addons, addonName)
|
||||
|
@ -187,10 +186,10 @@ func TestAssignDefaultAddonVals(t *testing.T) {
|
|||
customCPULimits := "40m"
|
||||
customMemoryLimits := "140Mi"
|
||||
// Verify that an addon with all custom values provided remains unmodified during default value assignment
|
||||
customAddon := api.KubernetesAddon{
|
||||
customAddon := KubernetesAddon{
|
||||
Name: addonName,
|
||||
Enabled: helpers.PointerToBool(true),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: addonName,
|
||||
CPURequests: customCPURequests,
|
||||
|
@ -219,10 +218,10 @@ func TestAssignDefaultAddonVals(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify that an addon with no custom values provided gets all the appropriate defaults
|
||||
customAddon = api.KubernetesAddon{
|
||||
customAddon = KubernetesAddon{
|
||||
Name: addonName,
|
||||
Enabled: helpers.PointerToBool(true),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: addonName,
|
||||
},
|
||||
|
@ -243,10 +242,10 @@ func TestAssignDefaultAddonVals(t *testing.T) {
|
|||
}
|
||||
|
||||
// More checking to verify default interpolation
|
||||
customAddon = api.KubernetesAddon{
|
||||
customAddon = KubernetesAddon{
|
||||
Name: addonName,
|
||||
Enabled: helpers.PointerToBool(true),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: addonName,
|
||||
CPURequests: customCPURequests,
|
||||
|
@ -268,6 +267,20 @@ func TestAssignDefaultAddonVals(t *testing.T) {
|
|||
t.Fatalf("assignDefaultAddonVals() should not have modified Containers 'MemoryLimits' value %s to %s,", customAddon.Containers[0].MemoryLimits, modifiedAddon.Containers[0].MemoryLimits)
|
||||
}
|
||||
|
||||
addonWithDefaults.Config = map[string]string{
|
||||
"os": "Linux",
|
||||
"taint": "node.kubernetes.io/memory-pressure",
|
||||
}
|
||||
modifiedAddon = assignDefaultAddonVals(customAddon, addonWithDefaults)
|
||||
|
||||
if modifiedAddon.Config["os"] != "Linux" {
|
||||
t.Error("assignDefaultAddonVals() should have added the default config property")
|
||||
}
|
||||
|
||||
if modifiedAddon.Config["taint"] != "node.kubernetes.io/memory-pressure" {
|
||||
t.Error("assignDefaultAddonVals() should have added the default config property")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestKubeletFeatureGatesEnsureFeatureGatesOnAgentsFor1_6_0(t *testing.T) {
|
||||
|
@ -278,7 +291,7 @@ func TestKubeletFeatureGatesEnsureFeatureGatesOnAgentsFor1_6_0(t *testing.T) {
|
|||
// so they will inherit the top-level config
|
||||
properties.OrchestratorProfile.KubernetesConfig = getKubernetesConfigWithFeatureGates("TopLevel=true")
|
||||
|
||||
setKubeletConfig(&mockCS)
|
||||
mockCS.setKubeletConfig()
|
||||
|
||||
agentFeatureGates := properties.AgentPoolProfiles[0].KubernetesConfig.KubeletConfig["--feature-gates"]
|
||||
if agentFeatureGates != "TopLevel=true" {
|
||||
|
@ -299,10 +312,10 @@ func TestKubeletFeatureGatesEnsureMasterAndAgentConfigUsedFor1_6_0(t *testing.T)
|
|||
// Set MasterProfile and AgentProfiles KubernetesConfig.KubeletConfig values
|
||||
// Verify that they are used instead of the top-level config
|
||||
properties.OrchestratorProfile.KubernetesConfig = getKubernetesConfigWithFeatureGates("TopLevel=true")
|
||||
properties.MasterProfile = &api.MasterProfile{KubernetesConfig: getKubernetesConfigWithFeatureGates("MasterLevel=true")}
|
||||
properties.MasterProfile = &MasterProfile{KubernetesConfig: getKubernetesConfigWithFeatureGates("MasterLevel=true")}
|
||||
properties.AgentPoolProfiles[0].KubernetesConfig = getKubernetesConfigWithFeatureGates("AgentLevel=true")
|
||||
|
||||
setKubeletConfig(&mockCS)
|
||||
mockCS.setKubeletConfig()
|
||||
|
||||
agentFeatureGates := properties.AgentPoolProfiles[0].KubernetesConfig.KubeletConfig["--feature-gates"]
|
||||
if agentFeatureGates != "AgentLevel=true" {
|
||||
|
@ -321,7 +334,7 @@ func TestEtcdDiskSize(t *testing.T) {
|
|||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 1
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB != DefaultEtcdDiskSize {
|
||||
t.Fatalf("EtcdDiskSizeGB did not have the expected size, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB, DefaultEtcdDiskSize)
|
||||
|
@ -331,7 +344,7 @@ func TestEtcdDiskSize(t *testing.T) {
|
|||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 5
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB != DefaultEtcdDiskSizeGT3Nodes {
|
||||
t.Fatalf("EtcdDiskSizeGB did not have the expected size, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB, DefaultEtcdDiskSizeGT3Nodes)
|
||||
|
@ -342,7 +355,7 @@ func TestEtcdDiskSize(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 5
|
||||
properties.AgentPoolProfiles[0].Count = 6
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB != DefaultEtcdDiskSizeGT10Nodes {
|
||||
t.Fatalf("EtcdDiskSizeGB did not have the expected size, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB, DefaultEtcdDiskSizeGT10Nodes)
|
||||
|
@ -353,7 +366,7 @@ func TestEtcdDiskSize(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 5
|
||||
properties.AgentPoolProfiles[0].Count = 16
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB != DefaultEtcdDiskSizeGT20Nodes {
|
||||
t.Fatalf("EtcdDiskSizeGB did not have the expected size, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB, DefaultEtcdDiskSizeGT20Nodes)
|
||||
|
@ -366,7 +379,7 @@ func TestEtcdDiskSize(t *testing.T) {
|
|||
properties.AgentPoolProfiles[0].Count = 50
|
||||
customEtcdDiskSize := "512"
|
||||
properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB = customEtcdDiskSize
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB != customEtcdDiskSize {
|
||||
t.Fatalf("EtcdDiskSizeGB did not have the expected size, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.EtcdDiskSizeGB, customEtcdDiskSize)
|
||||
|
@ -392,7 +405,7 @@ func TestNetworkPolicyDefaults(t *testing.T) {
|
|||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPolicy = "calico"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin != "kubenet" {
|
||||
t.Fatalf("NetworkPlugin did not have the expected value, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin, "kubenet")
|
||||
|
@ -402,7 +415,7 @@ func TestNetworkPolicyDefaults(t *testing.T) {
|
|||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPolicy = "cilium"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin != "cilium" {
|
||||
t.Fatalf("NetworkPlugin did not have the expected value, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin, "cilium")
|
||||
|
@ -412,7 +425,7 @@ func TestNetworkPolicyDefaults(t *testing.T) {
|
|||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPolicy = "azure"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin != "azure" {
|
||||
t.Fatalf("NetworkPlugin did not have the expected value, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin, "azure")
|
||||
|
@ -426,7 +439,7 @@ func TestNetworkPolicyDefaults(t *testing.T) {
|
|||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPolicy = "none"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin != "kubenet" {
|
||||
t.Fatalf("NetworkPlugin did not have the expected value, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin, "kubenet")
|
||||
|
@ -443,43 +456,43 @@ func TestStorageProfile(t *testing.T) {
|
|||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 1
|
||||
properties.OrchestratorProfile.KubernetesConfig.PrivateCluster = &api.PrivateCluster{
|
||||
properties.OrchestratorProfile.KubernetesConfig.PrivateCluster = &PrivateCluster{
|
||||
Enabled: helpers.PointerToBool(true),
|
||||
JumpboxProfile: &api.PrivateJumpboxProfile{},
|
||||
JumpboxProfile: &PrivateJumpboxProfile{},
|
||||
}
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
if properties.MasterProfile.StorageProfile != api.ManagedDisks {
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if properties.MasterProfile.StorageProfile != ManagedDisks {
|
||||
t.Fatalf("MasterProfile.StorageProfile did not have the expected configuration, got %s, expected %s",
|
||||
properties.MasterProfile.StorageProfile, api.ManagedDisks)
|
||||
properties.MasterProfile.StorageProfile, ManagedDisks)
|
||||
}
|
||||
if !properties.MasterProfile.IsManagedDisks() {
|
||||
t.Fatalf("MasterProfile.StorageProfile did not have the expected configuration, got %t, expected %t",
|
||||
false, true)
|
||||
}
|
||||
if properties.AgentPoolProfiles[0].StorageProfile != api.ManagedDisks {
|
||||
if properties.AgentPoolProfiles[0].StorageProfile != ManagedDisks {
|
||||
t.Fatalf("AgentPoolProfile.StorageProfile did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].StorageProfile, api.ManagedDisks)
|
||||
properties.AgentPoolProfiles[0].StorageProfile, ManagedDisks)
|
||||
}
|
||||
if !properties.AgentPoolProfiles[0].IsManagedDisks() {
|
||||
t.Fatalf("AgentPoolProfile.IsManagedDisks() did not have the expected configuration, got %t, expected %t",
|
||||
false, true)
|
||||
}
|
||||
if properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile != api.ManagedDisks {
|
||||
if properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile != ManagedDisks {
|
||||
t.Fatalf("MasterProfile.StorageProfile did not have the expected configuration, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile, api.ManagedDisks)
|
||||
properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile, ManagedDisks)
|
||||
}
|
||||
if !properties.AgentPoolProfiles[0].IsAvailabilitySets() {
|
||||
t.Fatalf("AgentPoolProfile[0].AvailabilityProfile did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].AvailabilityProfile, api.AvailabilitySet)
|
||||
properties.AgentPoolProfiles[0].AvailabilityProfile, AvailabilitySet)
|
||||
}
|
||||
|
||||
mockCS = getMockBaseContainerService("1.10.2")
|
||||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if !properties.AgentPoolProfiles[0].IsVirtualMachineScaleSets() {
|
||||
t.Fatalf("AgentPoolProfile[0].AvailabilityProfile did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].AvailabilityProfile, api.VirtualMachineScaleSets)
|
||||
properties.AgentPoolProfiles[0].AvailabilityProfile, VirtualMachineScaleSets)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -495,10 +508,10 @@ func TestMasterProfileDefaults(t *testing.T) {
|
|||
properties.MasterProfile.AvailabilityProfile = ""
|
||||
properties.MasterProfile.Count = 3
|
||||
mockCS.Properties = properties
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if properties.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
t.Fatalf("Master VMAS, AzureCNI: MasterProfile AvailabilityProfile did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.AvailabilityProfile, api.AvailabilitySet)
|
||||
properties.MasterProfile.AvailabilityProfile, AvailabilitySet)
|
||||
}
|
||||
if properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet != DefaultKubernetesSubnet {
|
||||
t.Fatalf("Master VMAS, AzureCNI: MasterProfile ClusterSubnet did not have the expected default configuration, got %s, expected %s",
|
||||
|
@ -523,19 +536,19 @@ func TestMasterProfileDefaults(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "azure"
|
||||
properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet = ""
|
||||
properties.MasterProfile.AvailabilityProfile = api.VirtualMachineScaleSets
|
||||
setPropertiesDefaults(&mockCS, false, true)
|
||||
properties.MasterProfile.AvailabilityProfile = VirtualMachineScaleSets
|
||||
mockCS.SetPropertiesDefaults(false, true)
|
||||
if !properties.MasterProfile.IsVirtualMachineScaleSets() {
|
||||
t.Fatalf("Master VMSS, AzureCNI: MasterProfile AvailabilityProfile did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.AvailabilityProfile, api.VirtualMachineScaleSets)
|
||||
properties.MasterProfile.AvailabilityProfile, VirtualMachineScaleSets)
|
||||
}
|
||||
if properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet != DefaultKubernetesSubnet {
|
||||
t.Fatalf("Master VMSS, AzureCNI: MasterProfile ClusterSubnet did not have the expected default configuration, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet, DefaultKubernetesSubnet)
|
||||
}
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != api.DefaultFirstConsecutiveKubernetesStaticIPVMSS {
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != DefaultFirstConsecutiveKubernetesStaticIPVMSS {
|
||||
t.Fatalf("Master VMSS, AzureCNI: MasterProfile FirstConsecutiveStaticIP did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, api.DefaultFirstConsecutiveKubernetesStaticIPVMSS)
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, DefaultFirstConsecutiveKubernetesStaticIPVMSS)
|
||||
}
|
||||
if properties.MasterProfile.Subnet != DefaultKubernetesMasterSubnet {
|
||||
t.Fatalf("Master VMSS, AzureCNI: MasterProfile Subnet did not have the expected default configuration, got %s, expected %s",
|
||||
|
@ -552,8 +565,8 @@ func TestMasterProfileDefaults(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet = ""
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "kubenet"
|
||||
properties.MasterProfile.AvailabilityProfile = api.VirtualMachineScaleSets
|
||||
setPropertiesDefaults(&mockCS, false, true)
|
||||
properties.MasterProfile.AvailabilityProfile = VirtualMachineScaleSets
|
||||
mockCS.SetPropertiesDefaults(false, true)
|
||||
if properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet != DefaultKubernetesClusterSubnet {
|
||||
t.Fatalf("Master VMSS, kubenet: MasterProfile ClusterSubnet did not have the expected default configuration, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet, DefaultKubernetesClusterSubnet)
|
||||
|
@ -562,19 +575,19 @@ func TestMasterProfileDefaults(t *testing.T) {
|
|||
t.Fatalf("Master VMSS, kubenet: MasterProfile Subnet did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.Subnet, DefaultKubernetesMasterSubnet)
|
||||
}
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != api.DefaultFirstConsecutiveKubernetesStaticIPVMSS {
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != DefaultFirstConsecutiveKubernetesStaticIPVMSS {
|
||||
t.Fatalf("Master VMSS, kubenet: MasterProfile FirstConsecutiveStaticIP did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, api.DefaultFirstConsecutiveKubernetesStaticIPVMSS)
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, DefaultFirstConsecutiveKubernetesStaticIPVMSS)
|
||||
}
|
||||
if properties.MasterProfile.AgentSubnet != DefaultKubernetesAgentSubnetVMSS {
|
||||
t.Fatalf("Master VMSS, kubenet: MasterProfile AgentSubnet did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.AgentSubnet, DefaultKubernetesAgentSubnetVMSS)
|
||||
}
|
||||
properties.MasterProfile.AvailabilityProfile = api.AvailabilitySet
|
||||
setPropertiesDefaults(&mockCS, false, true)
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != api.DefaultFirstConsecutiveKubernetesStaticIP {
|
||||
properties.MasterProfile.AvailabilityProfile = AvailabilitySet
|
||||
mockCS.SetPropertiesDefaults(false, true)
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != DefaultFirstConsecutiveKubernetesStaticIP {
|
||||
t.Fatalf("Master VMAS, kubenet: MasterProfile FirstConsecutiveStaticIP did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, api.DefaultFirstConsecutiveKubernetesStaticIP)
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, DefaultFirstConsecutiveKubernetesStaticIP)
|
||||
}
|
||||
|
||||
// this validates default vmas masterProfile configuration, AzureCNI, and custom vnet
|
||||
|
@ -586,8 +599,8 @@ func TestMasterProfileDefaults(t *testing.T) {
|
|||
properties.MasterProfile.FirstConsecutiveStaticIP = "10.239.255.239"
|
||||
properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet = ""
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "azure"
|
||||
properties.MasterProfile.AvailabilityProfile = api.AvailabilitySet
|
||||
setPropertiesDefaults(&mockCS, false, true)
|
||||
properties.MasterProfile.AvailabilityProfile = AvailabilitySet
|
||||
mockCS.SetPropertiesDefaults(false, true)
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != "10.239.255.239" {
|
||||
t.Fatalf("Master VMAS, AzureCNI, customvnet: MasterProfile FirstConsecutiveStaticIP did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, "10.239.255.239")
|
||||
|
@ -601,8 +614,8 @@ func TestMasterProfileDefaults(t *testing.T) {
|
|||
properties.MasterProfile.VnetCidr = "10.239.0.0/16"
|
||||
properties.OrchestratorProfile.KubernetesConfig.ClusterSubnet = ""
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "azure"
|
||||
properties.MasterProfile.AvailabilityProfile = api.VirtualMachineScaleSets
|
||||
setPropertiesDefaults(&mockCS, false, true)
|
||||
properties.MasterProfile.AvailabilityProfile = VirtualMachineScaleSets
|
||||
mockCS.SetPropertiesDefaults(false, true)
|
||||
if properties.MasterProfile.FirstConsecutiveStaticIP != "10.239.0.4" {
|
||||
t.Fatalf("Master VMSS, AzureCNI, customvnet: MasterProfile FirstConsecutiveStaticIP did not have the expected default configuration, got %s, expected %s",
|
||||
properties.MasterProfile.FirstConsecutiveStaticIP, "10.239.0.4")
|
||||
|
@ -613,10 +626,10 @@ func TestMasterProfileDefaults(t *testing.T) {
|
|||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku = "Standard"
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
if *properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB != api.DefaultExcludeMasterFromStandardLB {
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if *properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB != DefaultExcludeMasterFromStandardLB {
|
||||
t.Fatalf("OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB did not have the expected configuration, got %t, expected %t",
|
||||
*properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB, api.DefaultExcludeMasterFromStandardLB)
|
||||
*properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB, DefaultExcludeMasterFromStandardLB)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -625,7 +638,7 @@ func TestAgentPoolProfile(t *testing.T) {
|
|||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 1
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if properties.AgentPoolProfiles[0].ScaleSetPriority != "" {
|
||||
t.Fatalf("AgentPoolProfiles[0].ScaleSetPriority did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].ScaleSetPriority, "")
|
||||
|
@ -634,65 +647,65 @@ func TestAgentPoolProfile(t *testing.T) {
|
|||
t.Fatalf("AgentPoolProfiles[0].ScaleSetEvictionPolicy did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].ScaleSetEvictionPolicy, "")
|
||||
}
|
||||
properties.AgentPoolProfiles[0].ScaleSetPriority = api.ScaleSetPriorityLow
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
if properties.AgentPoolProfiles[0].ScaleSetEvictionPolicy != api.ScaleSetEvictionPolicyDelete {
|
||||
properties.AgentPoolProfiles[0].ScaleSetPriority = ScaleSetPriorityLow
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if properties.AgentPoolProfiles[0].ScaleSetEvictionPolicy != ScaleSetEvictionPolicyDelete {
|
||||
t.Fatalf("AgentPoolProfile[0].ScaleSetEvictionPolicy did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].ScaleSetEvictionPolicy, api.ScaleSetEvictionPolicyDelete)
|
||||
properties.AgentPoolProfiles[0].ScaleSetEvictionPolicy, ScaleSetEvictionPolicyDelete)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSetComponentsNetworkDefaults covers tests for setMasterProfileDefaults and setAgentProfileDefaults
|
||||
// TODO: Currently this test covers only api.Distro setting. Extend test cases to cover network configuration too.
|
||||
// TODO: Currently this test covers only Distro setting. Extend test cases to cover network configuration too.
|
||||
func TestSetComponentsNetworkDefaults(t *testing.T) {
|
||||
|
||||
var tests = []struct {
|
||||
name string // test case name
|
||||
orchestratorProfile api.OrchestratorProfile // orchestrator to be tested
|
||||
expectedDistro api.Distro // expected result default disto to be used
|
||||
name string // test case name
|
||||
orchestratorProfile OrchestratorProfile // orchestrator to be tested
|
||||
expectedDistro Distro // expected result default disto to be used
|
||||
}{
|
||||
{
|
||||
"default_kubernetes",
|
||||
api.OrchestratorProfile{
|
||||
OrchestratorType: api.Kubernetes,
|
||||
OrchestratorProfile{
|
||||
OrchestratorType: Kubernetes,
|
||||
},
|
||||
api.AKS,
|
||||
AKS,
|
||||
},
|
||||
{
|
||||
"default_openshift",
|
||||
api.OrchestratorProfile{
|
||||
OrchestratorType: api.OpenShift,
|
||||
OrchestratorProfile{
|
||||
OrchestratorType: OpenShift,
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"default_swarm",
|
||||
api.OrchestratorProfile{
|
||||
OrchestratorType: api.Swarm,
|
||||
OrchestratorProfile{
|
||||
OrchestratorType: Swarm,
|
||||
},
|
||||
api.Ubuntu,
|
||||
Ubuntu,
|
||||
},
|
||||
{
|
||||
"default_swarmmode",
|
||||
api.OrchestratorProfile{
|
||||
OrchestratorType: api.SwarmMode,
|
||||
OrchestratorProfile{
|
||||
OrchestratorType: SwarmMode,
|
||||
},
|
||||
api.Ubuntu,
|
||||
Ubuntu,
|
||||
},
|
||||
{
|
||||
"default_dcos",
|
||||
api.OrchestratorProfile{
|
||||
OrchestratorType: api.DCOS,
|
||||
OrchestratorProfile{
|
||||
OrchestratorType: DCOS,
|
||||
},
|
||||
api.Ubuntu,
|
||||
Ubuntu,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
mockAPI := getMockAPIProperties("1.0.0")
|
||||
mockAPI.OrchestratorProfile = &test.orchestratorProfile
|
||||
setMasterProfileDefaults(&mockAPI, false)
|
||||
setAgentProfileDefaults(&mockAPI, false, false)
|
||||
mockAPI.setMasterProfileDefaults(false)
|
||||
mockAPI.setAgentProfileDefaults(false, false)
|
||||
if mockAPI.MasterProfile.Distro != test.expectedDistro {
|
||||
t.Fatalf("setMasterProfileDefaults() test case %v did not return right Distro configurations %v != %v", test.name, mockAPI.MasterProfile.Distro, test.expectedDistro)
|
||||
}
|
||||
|
@ -709,10 +722,22 @@ func TestIsAzureCNINetworkmonitorAddon(t *testing.T) {
|
|||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 1
|
||||
properties.OrchestratorProfile.KubernetesConfig.Addons = []api.KubernetesAddon{
|
||||
getMockAddon(AzureCNINetworkMonitoringAddonName),
|
||||
properties.OrchestratorProfile.KubernetesConfig.Addons = []KubernetesAddon{
|
||||
{
|
||||
Name: AzureCNINetworkMonitoringAddonName,
|
||||
Containers: []KubernetesContainerSpec{
|
||||
{
|
||||
Name: AzureCNINetworkMonitoringAddonName,
|
||||
CPURequests: "50m",
|
||||
MemoryRequests: "150Mi",
|
||||
CPULimits: "50m",
|
||||
MemoryLimits: "150Mi",
|
||||
},
|
||||
},
|
||||
Enabled: helpers.PointerToBool(true),
|
||||
},
|
||||
}
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
i := getAddonsIndexByName(properties.OrchestratorProfile.KubernetesConfig.Addons, AzureCNINetworkMonitoringAddonName)
|
||||
if !helpers.IsTrueBoolPointer(properties.OrchestratorProfile.KubernetesConfig.Addons[i].Enabled) {
|
||||
|
@ -724,7 +749,7 @@ func TestIsAzureCNINetworkmonitorAddon(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 1
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "azure"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
i = getAddonsIndexByName(properties.OrchestratorProfile.KubernetesConfig.Addons, AzureCNINetworkMonitoringAddonName)
|
||||
if !helpers.IsTrueBoolPointer(properties.OrchestratorProfile.KubernetesConfig.Addons[i].Enabled) {
|
||||
|
@ -738,26 +763,26 @@ func TestSetVMSSDefaultsAndZones(t *testing.T) {
|
|||
mockCS := getMockBaseContainerService("1.12.0")
|
||||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.AvailabilityProfile = api.VirtualMachineScaleSets
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
properties.MasterProfile.AvailabilityProfile = VirtualMachineScaleSets
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if properties.MasterProfile.HasAvailabilityZones() {
|
||||
t.Fatalf("MasterProfile.HasAvailabilityZones did not have the expected return, got %t, expected %t",
|
||||
properties.MasterProfile.HasAvailabilityZones(), false)
|
||||
}
|
||||
if properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku != api.DefaultLoadBalancerSku {
|
||||
if properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku != DefaultLoadBalancerSku {
|
||||
t.Fatalf("OrchestratorProfile.KubernetesConfig.LoadBalancerSku did not have the expected configuration, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, api.DefaultLoadBalancerSku)
|
||||
properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, DefaultLoadBalancerSku)
|
||||
}
|
||||
// masters with vmss and zones
|
||||
mockCS = getMockBaseContainerService("1.12.0")
|
||||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.AvailabilityProfile = api.VirtualMachineScaleSets
|
||||
properties.MasterProfile.AvailabilityProfile = VirtualMachineScaleSets
|
||||
properties.MasterProfile.AvailabilityZones = []string{"1", "2"}
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
if *properties.MasterProfile.SinglePlacementGroup != api.DefaultSinglePlacementGroup {
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if *properties.MasterProfile.SinglePlacementGroup != DefaultSinglePlacementGroup {
|
||||
t.Fatalf("MasterProfile.SinglePlacementGroup default did not have the expected configuration, got %t, expected %t",
|
||||
*properties.MasterProfile.SinglePlacementGroup, api.DefaultSinglePlacementGroup)
|
||||
*properties.MasterProfile.SinglePlacementGroup, DefaultSinglePlacementGroup)
|
||||
}
|
||||
if !properties.MasterProfile.HasAvailabilityZones() {
|
||||
t.Fatalf("MasterProfile.HasAvailabilityZones did not have the expected return, got %t, expected %t",
|
||||
|
@ -767,23 +792,23 @@ func TestSetVMSSDefaultsAndZones(t *testing.T) {
|
|||
t.Fatalf("OrchestratorProfile.KubernetesConfig.LoadBalancerSku did not have the expected configuration, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, "Standard")
|
||||
}
|
||||
if *properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB != api.DefaultExcludeMasterFromStandardLB {
|
||||
if *properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB != DefaultExcludeMasterFromStandardLB {
|
||||
t.Fatalf("OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB did not have the expected configuration, got %t, expected %t",
|
||||
*properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB, api.DefaultExcludeMasterFromStandardLB)
|
||||
*properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB, DefaultExcludeMasterFromStandardLB)
|
||||
}
|
||||
// agents with vmss and no zones
|
||||
mockCS = getMockBaseContainerService("1.12.0")
|
||||
properties = mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.AgentPoolProfiles[0].Count = 4
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if properties.AgentPoolProfiles[0].HasAvailabilityZones() {
|
||||
t.Fatalf("AgentPoolProfiles[0].HasAvailabilityZones did not have the expected return, got %t, expected %t",
|
||||
properties.AgentPoolProfiles[0].HasAvailabilityZones(), false)
|
||||
}
|
||||
if properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku != api.DefaultLoadBalancerSku {
|
||||
if properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku != DefaultLoadBalancerSku {
|
||||
t.Fatalf("OrchestratorProfile.KubernetesConfig.LoadBalancerSku did not have the expected configuration, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, api.DefaultLoadBalancerSku)
|
||||
properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, DefaultLoadBalancerSku)
|
||||
}
|
||||
// agents with vmss and zones
|
||||
mockCS = getMockBaseContainerService("1.12.0")
|
||||
|
@ -791,38 +816,38 @@ func TestSetVMSSDefaultsAndZones(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.AgentPoolProfiles[0].Count = 4
|
||||
properties.AgentPoolProfiles[0].AvailabilityZones = []string{"1", "2"}
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if !properties.AgentPoolProfiles[0].IsVirtualMachineScaleSets() {
|
||||
t.Fatalf("AgentPoolProfile[0].AvailabilityProfile did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].AvailabilityProfile, api.VirtualMachineScaleSets)
|
||||
properties.AgentPoolProfiles[0].AvailabilityProfile, VirtualMachineScaleSets)
|
||||
}
|
||||
if !properties.AgentPoolProfiles[0].HasAvailabilityZones() {
|
||||
t.Fatalf("AgentPoolProfiles[0].HasAvailabilityZones did not have the expected return, got %t, expected %t",
|
||||
properties.AgentPoolProfiles[0].HasAvailabilityZones(), true)
|
||||
}
|
||||
if *properties.AgentPoolProfiles[0].SinglePlacementGroup != api.DefaultSinglePlacementGroup {
|
||||
if *properties.AgentPoolProfiles[0].SinglePlacementGroup != DefaultSinglePlacementGroup {
|
||||
t.Fatalf("AgentPoolProfile[0].SinglePlacementGroup default did not have the expected configuration, got %t, expected %t",
|
||||
*properties.AgentPoolProfiles[0].SinglePlacementGroup, api.DefaultSinglePlacementGroup)
|
||||
*properties.AgentPoolProfiles[0].SinglePlacementGroup, DefaultSinglePlacementGroup)
|
||||
}
|
||||
if properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku != "Standard" {
|
||||
t.Fatalf("OrchestratorProfile.KubernetesConfig.LoadBalancerSku did not have the expected configuration, got %s, expected %s",
|
||||
properties.OrchestratorProfile.KubernetesConfig.LoadBalancerSku, "Standard")
|
||||
}
|
||||
if *properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB != api.DefaultExcludeMasterFromStandardLB {
|
||||
if *properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB != DefaultExcludeMasterFromStandardLB {
|
||||
t.Fatalf("OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB did not have the expected configuration, got %t, expected %t",
|
||||
*properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB, api.DefaultExcludeMasterFromStandardLB)
|
||||
*properties.OrchestratorProfile.KubernetesConfig.ExcludeMasterFromStandardLB, DefaultExcludeMasterFromStandardLB)
|
||||
}
|
||||
|
||||
properties.AgentPoolProfiles[0].Count = 110
|
||||
setPropertiesDefaults(&mockCS, false, false)
|
||||
mockCS.SetPropertiesDefaults(false, false)
|
||||
if helpers.IsTrueBoolPointer(properties.AgentPoolProfiles[0].SinglePlacementGroup) {
|
||||
t.Fatalf("AgentPoolProfile[0].SinglePlacementGroup did not have the expected configuration, got %t, expected %t",
|
||||
*properties.AgentPoolProfiles[0].SinglePlacementGroup, false)
|
||||
}
|
||||
|
||||
if !*properties.AgentPoolProfiles[0].SinglePlacementGroup && properties.AgentPoolProfiles[0].StorageProfile != api.ManagedDisks {
|
||||
if !*properties.AgentPoolProfiles[0].SinglePlacementGroup && properties.AgentPoolProfiles[0].StorageProfile != ManagedDisks {
|
||||
t.Fatalf("AgentPoolProfile[0].StorageProfile did not have the expected configuration, got %s, expected %s",
|
||||
properties.AgentPoolProfiles[0].StorageProfile, api.ManagedDisks)
|
||||
properties.AgentPoolProfiles[0].StorageProfile, ManagedDisks)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -833,7 +858,7 @@ func TestAzureCNIVersionString(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 1
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "azure"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
if properties.OrchestratorProfile.KubernetesConfig.AzureCNIVersion != AzureCniPluginVerLinux {
|
||||
t.Fatalf("Azure CNI Version string not the expected value, got %s, expected %s", properties.OrchestratorProfile.KubernetesConfig.AzureCNIVersion, AzureCniPluginVerLinux)
|
||||
|
@ -845,7 +870,7 @@ func TestAzureCNIVersionString(t *testing.T) {
|
|||
properties.MasterProfile.Count = 1
|
||||
properties.AgentPoolProfiles[0].OSType = "Windows"
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "azure"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
if properties.OrchestratorProfile.KubernetesConfig.AzureCNIVersion != AzureCniPluginVerWindows {
|
||||
t.Fatalf("Azure CNI Version string not the expected value, got %s, expected %s", properties.OrchestratorProfile.KubernetesConfig.AzureCNIVersion, AzureCniPluginVerWindows)
|
||||
|
@ -856,7 +881,7 @@ func TestAzureCNIVersionString(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.MasterProfile.Count = 1
|
||||
properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = "kubenet"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
if properties.OrchestratorProfile.KubernetesConfig.AzureCNIVersion != "" {
|
||||
t.Fatalf("Azure CNI Version string not the expected value, got %s, expected %s", properties.OrchestratorProfile.KubernetesConfig.AzureCNIVersion, "")
|
||||
|
@ -868,7 +893,7 @@ func TestDefaultDisableRbac(t *testing.T) {
|
|||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.EnableRbac = helpers.PointerToBool(false)
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
if properties.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs {
|
||||
t.Fatalf("got unexpected EnableAggregatedAPIs config value for EnableRbac=false: %t",
|
||||
|
@ -880,7 +905,7 @@ func TestDefaultCloudProvider(t *testing.T) {
|
|||
mockCS := getMockBaseContainerService("1.10.3")
|
||||
properties := mockCS.Properties
|
||||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
if !helpers.IsTrueBoolPointer(properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoff) {
|
||||
t.Fatalf("got unexpected CloudProviderBackoff expected true, got %t",
|
||||
|
@ -897,7 +922,7 @@ func TestDefaultCloudProvider(t *testing.T) {
|
|||
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
|
||||
properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoff = helpers.PointerToBool(false)
|
||||
properties.OrchestratorProfile.KubernetesConfig.CloudProviderRateLimit = helpers.PointerToBool(false)
|
||||
setOrchestratorDefaults(&mockCS, true)
|
||||
mockCS.setOrchestratorDefaults(true)
|
||||
|
||||
if !helpers.IsFalseBoolPointer(properties.OrchestratorProfile.KubernetesConfig.CloudProviderBackoff) {
|
||||
t.Fatalf("got unexpected CloudProviderBackoff expected true, got %t",
|
||||
|
@ -910,44 +935,104 @@ func TestDefaultCloudProvider(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func getMockAddon(name string) api.KubernetesAddon {
|
||||
return api.KubernetesAddon{
|
||||
Name: name,
|
||||
Enabled: helpers.PointerToBool(true),
|
||||
Containers: []api.KubernetesContainerSpec{
|
||||
{
|
||||
Name: name,
|
||||
CPURequests: "50m",
|
||||
MemoryRequests: "150Mi",
|
||||
CPULimits: "50m",
|
||||
MemoryLimits: "150Mi",
|
||||
func TestSetOpenShiftCertDefaults(t *testing.T) {
|
||||
cs := &ContainerService{
|
||||
Properties: &Properties{
|
||||
AzProfile: &AzProfile{
|
||||
TenantID: "sampleTenantID",
|
||||
SubscriptionID: "foobarsubscription",
|
||||
ResourceGroup: "sampleRG",
|
||||
Location: "westus2",
|
||||
},
|
||||
ServicePrincipalProfile: &ServicePrincipalProfile{
|
||||
ClientID: "barClientID",
|
||||
Secret: "bazSecret",
|
||||
},
|
||||
MasterProfile: &MasterProfile{
|
||||
Count: 1,
|
||||
DNSPrefix: "myprefix1",
|
||||
VMSize: "Standard_DS2_v2",
|
||||
},
|
||||
OrchestratorProfile: &OrchestratorProfile{
|
||||
OrchestratorType: OpenShift,
|
||||
OrchestratorVersion: "3.9.0",
|
||||
OpenShiftConfig: &OpenShiftConfig{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cs.Properties.setMasterProfileDefaults(false)
|
||||
|
||||
result, err := cs.Properties.setDefaultCerts()
|
||||
if !result {
|
||||
t.Error("expected setOpenShiftDefaultCerts to return true")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error thrown while executing setOpenShiftDefaultCerts %s", err.Error())
|
||||
}
|
||||
|
||||
cs = &ContainerService{
|
||||
Properties: &Properties{
|
||||
AzProfile: &AzProfile{
|
||||
TenantID: "sampleTenantID",
|
||||
SubscriptionID: "foobarsubscription",
|
||||
ResourceGroup: "sampleRG",
|
||||
Location: "westus2",
|
||||
},
|
||||
ServicePrincipalProfile: &ServicePrincipalProfile{
|
||||
ClientID: "barClientID",
|
||||
Secret: "bazSecret",
|
||||
},
|
||||
MasterProfile: &MasterProfile{
|
||||
Count: 1,
|
||||
DNSPrefix: "myprefix1",
|
||||
VMSize: "Standard_DS2_v2",
|
||||
AvailabilityProfile: VirtualMachineScaleSets,
|
||||
},
|
||||
OrchestratorProfile: &OrchestratorProfile{
|
||||
OrchestratorType: OpenShift,
|
||||
OrchestratorVersion: "3.7.0",
|
||||
OpenShiftConfig: &OpenShiftConfig{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cs.Properties.setMasterProfileDefaults(false)
|
||||
result, err = cs.Properties.setDefaultCerts()
|
||||
|
||||
if !result {
|
||||
t.Error("expected setOpenShiftDefaultCerts to return true")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error thrown while executing setOpenShiftDefaultCerts %s", err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func getMockBaseContainerService(orchestratorVersion string) api.ContainerService {
|
||||
func getMockBaseContainerService(orchestratorVersion string) ContainerService {
|
||||
mockAPIProperties := getMockAPIProperties(orchestratorVersion)
|
||||
return api.ContainerService{
|
||||
return ContainerService{
|
||||
Properties: &mockAPIProperties,
|
||||
}
|
||||
}
|
||||
|
||||
func getMockAPIProperties(orchestratorVersion string) api.Properties {
|
||||
return api.Properties{
|
||||
func getMockAPIProperties(orchestratorVersion string) Properties {
|
||||
return Properties{
|
||||
ProvisioningState: "",
|
||||
OrchestratorProfile: &api.OrchestratorProfile{
|
||||
OrchestratorProfile: &OrchestratorProfile{
|
||||
OrchestratorVersion: orchestratorVersion,
|
||||
KubernetesConfig: &api.KubernetesConfig{},
|
||||
KubernetesConfig: &KubernetesConfig{},
|
||||
},
|
||||
MasterProfile: &api.MasterProfile{},
|
||||
AgentPoolProfiles: []*api.AgentPoolProfile{
|
||||
MasterProfile: &MasterProfile{},
|
||||
AgentPoolProfiles: []*AgentPoolProfile{
|
||||
{},
|
||||
}}
|
||||
}
|
||||
|
||||
func getKubernetesConfigWithFeatureGates(featureGates string) *api.KubernetesConfig {
|
||||
return &api.KubernetesConfig{
|
||||
func getKubernetesConfigWithFeatureGates(featureGates string) *KubernetesConfig {
|
||||
return &KubernetesConfig{
|
||||
KubeletConfig: map[string]string{"--feature-gates": featureGates},
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
)
|
||||
|
||||
|
@ -32,12 +31,12 @@ var k8sComponentVersions = map[string]map[string]string{
|
|||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(api.DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(api.DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"gchighthreshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"gclowthreshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
},
|
||||
|
@ -64,12 +63,12 @@ var k8sComponentVersions = map[string]map[string]string{
|
|||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(api.DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(api.DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"gchighthreshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"gclowthreshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
},
|
||||
|
@ -96,12 +95,12 @@ var k8sComponentVersions = map[string]map[string]string{
|
|||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(api.DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(api.DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"gchighthreshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"gclowthreshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
},
|
||||
|
@ -127,12 +126,12 @@ var k8sComponentVersions = map[string]map[string]string{
|
|||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(api.DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(api.DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"gchighthreshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"gclowthreshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
},
|
||||
|
@ -156,12 +155,12 @@ var k8sComponentVersions = map[string]map[string]string{
|
|||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(api.DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(api.DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"gchighthreshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"gclowthreshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
},
|
||||
|
@ -185,12 +184,12 @@ var k8sComponentVersions = map[string]map[string]string{
|
|||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(api.DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(api.DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"gchighthreshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"gclowthreshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
},
|
||||
|
@ -213,19 +212,23 @@ var k8sComponentVersions = map[string]map[string]string{
|
|||
"nodegraceperiod": DefaultKubernetesCtrlMgrNodeMonitorGracePeriod,
|
||||
"podeviction": DefaultKubernetesCtrlMgrPodEvictionTimeout,
|
||||
"routeperiod": DefaultKubernetesCtrlMgrRouteReconciliationPeriod,
|
||||
"backoffretries": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(api.DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(api.DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(api.DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(api.DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"backoffretries": strconv.Itoa(DefaultKubernetesCloudProviderBackoffRetries),
|
||||
"backoffjitter": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffJitter, 'f', -1, 64),
|
||||
"backoffduration": strconv.Itoa(DefaultKubernetesCloudProviderBackoffDuration),
|
||||
"backoffexponent": strconv.FormatFloat(DefaultKubernetesCloudProviderBackoffExponent, 'f', -1, 64),
|
||||
"ratelimitqps": strconv.FormatFloat(DefaultKubernetesCloudProviderRateLimitQPS, 'f', -1, 64),
|
||||
"ratelimitbucket": strconv.Itoa(DefaultKubernetesCloudProviderRateLimitBucket),
|
||||
"gchighthreshold": strconv.Itoa(DefaultKubernetesGCHighThreshold),
|
||||
"gclowthreshold": strconv.Itoa(DefaultKubernetesGCLowThreshold),
|
||||
},
|
||||
}
|
||||
|
||||
// KubeConfigs represents Docker images used for Kubernetes components based on Kubernetes versions (major.minor.patch)
|
||||
var KubeConfigs = getKubeConfigs()
|
||||
// K8sComponentsByVersionMap represents Docker images used for Kubernetes components based on Kubernetes versions (major.minor.patch)
|
||||
var K8sComponentsByVersionMap map[string]map[string]string
|
||||
|
||||
func init() {
|
||||
K8sComponentsByVersionMap = getKubeConfigs()
|
||||
}
|
||||
|
||||
func getKubeConfigs() map[string]map[string]string {
|
||||
ret := make(map[string]map[string]string)
|
|
@ -1,4 +1,4 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -1,27 +1,26 @@
|
|||
package acsengine
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
"github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
// CreateMockContainerService returns a mock container service for testing purposes
|
||||
func CreateMockContainerService(containerServiceName, orchestratorVersion string, masterCount, agentCount int, certs bool) *api.ContainerService {
|
||||
cs := api.ContainerService{}
|
||||
func CreateMockContainerService(containerServiceName, orchestratorVersion string, masterCount, agentCount int, certs bool) *ContainerService {
|
||||
cs := ContainerService{}
|
||||
cs.ID = uuid.NewV4().String()
|
||||
cs.Location = "eastus"
|
||||
cs.Name = containerServiceName
|
||||
|
||||
cs.Properties = &api.Properties{}
|
||||
cs.Properties = &Properties{}
|
||||
|
||||
cs.Properties.MasterProfile = &api.MasterProfile{}
|
||||
cs.Properties.MasterProfile = &MasterProfile{}
|
||||
cs.Properties.MasterProfile.Count = masterCount
|
||||
cs.Properties.MasterProfile.DNSPrefix = "testmaster"
|
||||
cs.Properties.MasterProfile.VMSize = "Standard_D2_v2"
|
||||
|
||||
cs.Properties.AgentPoolProfiles = []*api.AgentPoolProfile{}
|
||||
agentPool := &api.AgentPoolProfile{}
|
||||
cs.Properties.AgentPoolProfiles = []*AgentPoolProfile{}
|
||||
agentPool := &AgentPoolProfile{}
|
||||
agentPool.Count = agentCount
|
||||
agentPool.Name = "agentpool1"
|
||||
agentPool.VMSize = "Standard_D2_v2"
|
||||
|
@ -31,27 +30,27 @@ func CreateMockContainerService(containerServiceName, orchestratorVersion string
|
|||
|
||||
cs.Properties.AgentPoolProfiles = append(cs.Properties.AgentPoolProfiles, agentPool)
|
||||
|
||||
cs.Properties.LinuxProfile = &api.LinuxProfile{
|
||||
cs.Properties.LinuxProfile = &LinuxProfile{
|
||||
AdminUsername: "azureuser",
|
||||
SSH: struct {
|
||||
PublicKeys []api.PublicKey `json:"publicKeys"`
|
||||
PublicKeys []PublicKey `json:"publicKeys"`
|
||||
}{},
|
||||
}
|
||||
|
||||
cs.Properties.LinuxProfile.AdminUsername = "azureuser"
|
||||
cs.Properties.LinuxProfile.SSH.PublicKeys = append(
|
||||
cs.Properties.LinuxProfile.SSH.PublicKeys, api.PublicKey{KeyData: "test"})
|
||||
cs.Properties.LinuxProfile.SSH.PublicKeys, PublicKey{KeyData: "test"})
|
||||
|
||||
cs.Properties.ServicePrincipalProfile = &api.ServicePrincipalProfile{}
|
||||
cs.Properties.ServicePrincipalProfile = &ServicePrincipalProfile{}
|
||||
cs.Properties.ServicePrincipalProfile.ClientID = "DEC923E3-1EF1-4745-9516-37906D56DEC4"
|
||||
cs.Properties.ServicePrincipalProfile.Secret = "DEC923E3-1EF1-4745-9516-37906D56DEC4"
|
||||
|
||||
cs.Properties.OrchestratorProfile = &api.OrchestratorProfile{}
|
||||
cs.Properties.OrchestratorProfile.OrchestratorType = api.Kubernetes
|
||||
cs.Properties.OrchestratorProfile = &OrchestratorProfile{}
|
||||
cs.Properties.OrchestratorProfile.OrchestratorType = Kubernetes
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = orchestratorVersion
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{
|
||||
EnableSecureKubelet: helpers.PointerToBool(api.DefaultSecureKubeletEnabled),
|
||||
EnableRbac: helpers.PointerToBool(api.DefaultRBACEnabled),
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig = &KubernetesConfig{
|
||||
EnableSecureKubelet: helpers.PointerToBool(DefaultSecureKubeletEnabled),
|
||||
EnableRbac: helpers.PointerToBool(DefaultRBACEnabled),
|
||||
EtcdDiskSizeGB: DefaultEtcdDiskSize,
|
||||
ServiceCIDR: DefaultKubernetesServiceCIDR,
|
||||
DockerBridgeSubnet: DefaultDockerBridgeSubnet,
|
||||
|
@ -67,7 +66,7 @@ func CreateMockContainerService(containerServiceName, orchestratorVersion string
|
|||
KubeletConfig: make(map[string]string),
|
||||
}
|
||||
|
||||
cs.Properties.CertificateProfile = &api.CertificateProfile{}
|
||||
cs.Properties.CertificateProfile = &CertificateProfile{}
|
||||
if certs {
|
||||
cs.Properties.CertificateProfile.CaCertificate = "cacert"
|
||||
cs.Properties.CertificateProfile.CaPrivateKey = "cakey"
|
|
@ -1319,14 +1319,18 @@ func (k *KubernetesConfig) SetCloudProviderRateLimitDefaults() {
|
|||
//for example: if the target is the public azure, then the default container image url should be k8s.gcr.io/...
|
||||
//if the target is azure china, then the default container image should be mirror.azure.cn:5000/google_container/...
|
||||
func (cs *ContainerService) GetCloudSpecConfig() AzureEnvironmentSpecConfig {
|
||||
switch helpers.GetCloudTargetEnv(cs.Location) {
|
||||
case azureChinaCloud:
|
||||
return AzureChinaCloudSpec
|
||||
case azureGermanCloud:
|
||||
return AzureGermanCloudSpec
|
||||
case azureUSGovernmentCloud:
|
||||
return AzureUSGovernmentCloud
|
||||
default:
|
||||
return AzureCloudSpec
|
||||
}
|
||||
targetEnv := helpers.GetCloudTargetEnv(cs.Location)
|
||||
return AzureCloudSpecEnvMap[targetEnv]
|
||||
}
|
||||
|
||||
// GetAzureProdFQDN returns the formatted FQDN string for a given apimodel.
|
||||
func (cs *ContainerService) GetAzureProdFQDN() string {
|
||||
return FormatAzureProdFQDNByLocation(cs.Properties.MasterProfile.DNSPrefix, cs.Location)
|
||||
}
|
||||
|
||||
// FormatAzureProdFQDNByLocation constructs an Azure prod fqdn
|
||||
func FormatAzureProdFQDNByLocation(fqdnPrefix string, location string) string {
|
||||
targetEnv := helpers.GetCloudTargetEnv(location)
|
||||
FQDNFormat := AzureCloudSpecEnvMap[targetEnv].EndpointConfig.ResourceManagerVMDNSSuffix
|
||||
return fmt.Sprintf("%s.%s."+FQDNFormat, fqdnPrefix, location)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"log"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
|
@ -2332,7 +2333,8 @@ func TestGetAgentVMPrefix(t *testing.T) {
|
|||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
actual := test.properties.GetAgentVMPrefix(test.profile)
|
||||
p := test.properties
|
||||
actual := p.GetAgentVMPrefix(test.profile)
|
||||
|
||||
if actual != test.expectedVMPrefix {
|
||||
t.Errorf("expected agent VM name %s, but got %s", test.expectedVMPrefix, actual)
|
||||
|
@ -2340,3 +2342,141 @@ func TestGetAgentVMPrefix(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatAzureProdFQDN(t *testing.T) {
|
||||
dnsPrefix := "santest"
|
||||
var actual []string
|
||||
for _, location := range helpers.GetAzureLocations() {
|
||||
actual = append(actual, FormatAzureProdFQDNByLocation(dnsPrefix, location))
|
||||
}
|
||||
|
||||
expected := []string{
|
||||
"santest.australiacentral.cloudapp.azure.com",
|
||||
"santest.australiacentral2.cloudapp.azure.com",
|
||||
"santest.australiaeast.cloudapp.azure.com",
|
||||
"santest.australiasoutheast.cloudapp.azure.com",
|
||||
"santest.brazilsouth.cloudapp.azure.com",
|
||||
"santest.canadacentral.cloudapp.azure.com",
|
||||
"santest.canadaeast.cloudapp.azure.com",
|
||||
"santest.centralindia.cloudapp.azure.com",
|
||||
"santest.centralus.cloudapp.azure.com",
|
||||
"santest.centraluseuap.cloudapp.azure.com",
|
||||
"santest.chinaeast.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinaeast2.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth2.cloudapp.chinacloudapi.cn",
|
||||
"santest.eastasia.cloudapp.azure.com",
|
||||
"santest.eastus.cloudapp.azure.com",
|
||||
"santest.eastus2.cloudapp.azure.com",
|
||||
"santest.eastus2euap.cloudapp.azure.com",
|
||||
"santest.francecentral.cloudapp.azure.com",
|
||||
"santest.francesouth.cloudapp.azure.com",
|
||||
"santest.japaneast.cloudapp.azure.com",
|
||||
"santest.japanwest.cloudapp.azure.com",
|
||||
"santest.koreacentral.cloudapp.azure.com",
|
||||
"santest.koreasouth.cloudapp.azure.com",
|
||||
"santest.northcentralus.cloudapp.azure.com",
|
||||
"santest.northeurope.cloudapp.azure.com",
|
||||
"santest.southcentralus.cloudapp.azure.com",
|
||||
"santest.southeastasia.cloudapp.azure.com",
|
||||
"santest.southindia.cloudapp.azure.com",
|
||||
"santest.uksouth.cloudapp.azure.com",
|
||||
"santest.ukwest.cloudapp.azure.com",
|
||||
"santest.westcentralus.cloudapp.azure.com",
|
||||
"santest.westeurope.cloudapp.azure.com",
|
||||
"santest.westindia.cloudapp.azure.com",
|
||||
"santest.westus.cloudapp.azure.com",
|
||||
"santest.westus2.cloudapp.azure.com",
|
||||
"santest.chinaeast.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinanorth2.cloudapp.chinacloudapi.cn",
|
||||
"santest.chinaeast2.cloudapp.chinacloudapi.cn",
|
||||
"santest.germanycentral.cloudapp.microsoftazure.de",
|
||||
"santest.germanynortheast.cloudapp.microsoftazure.de",
|
||||
"santest.usgovvirginia.cloudapp.usgovcloudapi.net",
|
||||
"santest.usgoviowa.cloudapp.usgovcloudapi.net",
|
||||
"santest.usgovarizona.cloudapp.usgovcloudapi.net",
|
||||
"santest.usgovtexas.cloudapp.usgovcloudapi.net",
|
||||
"santest.francecentral.cloudapp.azure.com",
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("expected formatted fqdns %s, but got %s", expected, actual)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestKubernetesConfig_GetAddonScript(t *testing.T) {
|
||||
addon := getMockAddon(IPMASQAgentAddonName)
|
||||
addon.Data = "foobarbazdata"
|
||||
k := &KubernetesConfig{
|
||||
Addons: []KubernetesAddon{
|
||||
addon,
|
||||
},
|
||||
}
|
||||
|
||||
expected := "foobarbazdata"
|
||||
actual := k.GetAddonScript(IPMASQAgentAddonName)
|
||||
if actual != expected {
|
||||
t.Errorf("expected GetAddonScript to return %s, but got %s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerService_GetAzureProdFQDN(t *testing.T) {
|
||||
cs := CreateMockContainerService("testcluster", defaultTestClusterVer, 1, 3, false)
|
||||
expected := "testmaster.eastus.cloudapp.azure.com"
|
||||
actual := cs.GetAzureProdFQDN()
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("expected GetAzureProdFQDN to return %s, but got %s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestKubernetesConfig_RequiresDocker(t *testing.T) {
|
||||
// k8sConfig with empty runtime string
|
||||
k := &KubernetesConfig{
|
||||
ContainerRuntime: "",
|
||||
}
|
||||
|
||||
if !k.RequiresDocker() {
|
||||
t.Error("expected RequiresDocker to return true for empty runtime string")
|
||||
}
|
||||
|
||||
// k8sConfig with empty runtime string
|
||||
k = &KubernetesConfig{
|
||||
ContainerRuntime: "docker",
|
||||
}
|
||||
|
||||
if !k.RequiresDocker() {
|
||||
t.Error("expected RequiresDocker to return true for docker runtime")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProperties_GetMasterVMPrefix(t *testing.T) {
|
||||
p := &Properties{
|
||||
OrchestratorProfile: &OrchestratorProfile{
|
||||
OrchestratorType: Kubernetes,
|
||||
},
|
||||
MasterProfile: &MasterProfile{
|
||||
Count: 1,
|
||||
DNSPrefix: "myprefix1",
|
||||
VMSize: "Standard_DS2_v2",
|
||||
},
|
||||
AgentPoolProfiles: []*AgentPoolProfile{
|
||||
{
|
||||
Name: "agentpool",
|
||||
VMSize: "Standard_D2_v2",
|
||||
Count: 1,
|
||||
AvailabilityProfile: "VirtualMachineScaleSets",
|
||||
OSType: "Linux",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual := p.GetMasterVMPrefix()
|
||||
expected := "k8s-master-30819786-"
|
||||
|
||||
if actual != expected {
|
||||
t.Errorf("expected master VM prefix %s, but got %s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from time import gmtime, strftime
|
||||
import subprocess
|
||||
import json
|
||||
import subprocess
|
||||
from time import gmtime, strftime
|
||||
|
||||
time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
|
||||
|
||||
|
@ -72,16 +72,17 @@ def getStorageAccountType(sizeName):
|
|||
return "Standard_LRS"
|
||||
|
||||
def getFileContents(dcosMasterMap, masterAgentMap, kubernetesAgentMap, sizeMap, locations):
|
||||
text = r"""package acsengine
|
||||
text = r"""package helpers
|
||||
|
||||
// AUTOGENERATED FILE """
|
||||
|
||||
text += r"""
|
||||
|
||||
// AzureLocations provides all azure regions in prod.
|
||||
// GetAzureLocations provides all azure regions in prod.
|
||||
// Related powershell to refresh this list:
|
||||
// Get-AzureRmLocation | Select-Object -Property Location
|
||||
var AzureLocations = []string{
|
||||
func GetAzureLocations() []string{
|
||||
return []string{
|
||||
"""
|
||||
for location in locations:
|
||||
text += ' "' + location + '",' + '\n'
|
||||
|
@ -98,6 +99,7 @@ var AzureLocations = []string{
|
|||
"usgovtexas",
|
||||
"francecentral",
|
||||
}
|
||||
}
|
||||
|
||||
// GetDCOSMasterAllowedSizes returns the master allowed sizes
|
||||
func GetDCOSMasterAllowedSizes() string {
|
||||
|
@ -198,7 +200,7 @@ func GetClassicSizeMap() string {
|
|||
|
||||
|
||||
def main():
|
||||
outfile = 'pkg/acsengine/azureconst.go'
|
||||
outfile = 'pkg/helpers/azureconst.go'
|
||||
allSizes = getAllSizes()
|
||||
dcosMasterMap = getDcosMasterMap(allSizes)
|
||||
masterAgentMap = getMasterAgentMap(allSizes)
|
|
@ -1,58 +1,60 @@
|
|||
package acsengine
|
||||
package helpers
|
||||
|
||||
// AUTOGENERATED FILE
|
||||
|
||||
// AzureLocations provides all azure regions in prod.
|
||||
// GetAzureLocations provides all azure regions in prod.
|
||||
// Related powershell to refresh this list:
|
||||
// Get-AzureRmLocation | Select-Object -Property Location
|
||||
var AzureLocations = []string{
|
||||
"australiacentral",
|
||||
"australiacentral2",
|
||||
"australiaeast",
|
||||
"australiasoutheast",
|
||||
"brazilsouth",
|
||||
"canadacentral",
|
||||
"canadaeast",
|
||||
"centralindia",
|
||||
"centralus",
|
||||
"centraluseuap",
|
||||
"chinaeast",
|
||||
"chinaeast2",
|
||||
"chinanorth",
|
||||
"chinanorth2",
|
||||
"eastasia",
|
||||
"eastus",
|
||||
"eastus2",
|
||||
"eastus2euap",
|
||||
"francecentral",
|
||||
"francesouth",
|
||||
"japaneast",
|
||||
"japanwest",
|
||||
"koreacentral",
|
||||
"koreasouth",
|
||||
"northcentralus",
|
||||
"northeurope",
|
||||
"southcentralus",
|
||||
"southeastasia",
|
||||
"southindia",
|
||||
"uksouth",
|
||||
"ukwest",
|
||||
"westcentralus",
|
||||
"westeurope",
|
||||
"westindia",
|
||||
"westus",
|
||||
"westus2",
|
||||
"chinaeast",
|
||||
"chinanorth",
|
||||
"chinanorth2",
|
||||
"chinaeast2",
|
||||
"germanycentral",
|
||||
"germanynortheast",
|
||||
"usgovvirginia",
|
||||
"usgoviowa",
|
||||
"usgovarizona",
|
||||
"usgovtexas",
|
||||
"francecentral",
|
||||
func GetAzureLocations() []string {
|
||||
return []string{
|
||||
"australiacentral",
|
||||
"australiacentral2",
|
||||
"australiaeast",
|
||||
"australiasoutheast",
|
||||
"brazilsouth",
|
||||
"canadacentral",
|
||||
"canadaeast",
|
||||
"centralindia",
|
||||
"centralus",
|
||||
"centraluseuap",
|
||||
"chinaeast",
|
||||
"chinaeast2",
|
||||
"chinanorth",
|
||||
"chinanorth2",
|
||||
"eastasia",
|
||||
"eastus",
|
||||
"eastus2",
|
||||
"eastus2euap",
|
||||
"francecentral",
|
||||
"francesouth",
|
||||
"japaneast",
|
||||
"japanwest",
|
||||
"koreacentral",
|
||||
"koreasouth",
|
||||
"northcentralus",
|
||||
"northeurope",
|
||||
"southcentralus",
|
||||
"southeastasia",
|
||||
"southindia",
|
||||
"uksouth",
|
||||
"ukwest",
|
||||
"westcentralus",
|
||||
"westeurope",
|
||||
"westindia",
|
||||
"westus",
|
||||
"westus2",
|
||||
"chinaeast",
|
||||
"chinanorth",
|
||||
"chinanorth2",
|
||||
"chinaeast2",
|
||||
"germanycentral",
|
||||
"germanynortheast",
|
||||
"usgovvirginia",
|
||||
"usgoviowa",
|
||||
"usgovarizona",
|
||||
"usgovtexas",
|
||||
"francecentral",
|
||||
}
|
||||
}
|
||||
|
||||
// GetDCOSMasterAllowedSizes returns the master allowed sizes
|
||||
|
@ -113,6 +115,8 @@ func GetDCOSMasterAllowedSizes() string {
|
|||
"Standard_D64s_v3",
|
||||
"Standard_D8_v3",
|
||||
"Standard_D8s_v3",
|
||||
"Standard_DC2s",
|
||||
"Standard_DC4s",
|
||||
"Standard_DS11",
|
||||
"Standard_DS11-1_v2",
|
||||
"Standard_DS11_v2",
|
||||
|
@ -145,6 +149,8 @@ func GetDCOSMasterAllowedSizes() string {
|
|||
"Standard_E16-8s_v3",
|
||||
"Standard_E16_v3",
|
||||
"Standard_E16s_v3",
|
||||
"Standard_E20_v3",
|
||||
"Standard_E20s_v3",
|
||||
"Standard_E2_v3",
|
||||
"Standard_E2s_v3",
|
||||
"Standard_E32-16s_v3",
|
||||
|
@ -317,6 +323,8 @@ func GetMasterAgentAllowedSizes() string {
|
|||
"Standard_D64s_v3",
|
||||
"Standard_D8_v3",
|
||||
"Standard_D8s_v3",
|
||||
"Standard_DC2s",
|
||||
"Standard_DC4s",
|
||||
"Standard_DS1",
|
||||
"Standard_DS11",
|
||||
"Standard_DS11-1_v2",
|
||||
|
@ -354,6 +362,8 @@ func GetMasterAgentAllowedSizes() string {
|
|||
"Standard_E16-8s_v3",
|
||||
"Standard_E16_v3",
|
||||
"Standard_E16s_v3",
|
||||
"Standard_E20_v3",
|
||||
"Standard_E20s_v3",
|
||||
"Standard_E2_v3",
|
||||
"Standard_E2s_v3",
|
||||
"Standard_E32-16s_v3",
|
||||
|
@ -529,6 +539,8 @@ func GetKubernetesAgentAllowedSizes() string {
|
|||
"Standard_D64s_v3",
|
||||
"Standard_D8_v3",
|
||||
"Standard_D8s_v3",
|
||||
"Standard_DC2s",
|
||||
"Standard_DC4s",
|
||||
"Standard_DS1",
|
||||
"Standard_DS11",
|
||||
"Standard_DS11-1_v2",
|
||||
|
@ -566,6 +578,8 @@ func GetKubernetesAgentAllowedSizes() string {
|
|||
"Standard_E16-8s_v3",
|
||||
"Standard_E16_v3",
|
||||
"Standard_E16s_v3",
|
||||
"Standard_E20_v3",
|
||||
"Standard_E20s_v3",
|
||||
"Standard_E2_v3",
|
||||
"Standard_E2s_v3",
|
||||
"Standard_E32-16s_v3",
|
||||
|
@ -867,6 +881,12 @@ func GetSizeMap() string {
|
|||
"Standard_D8s_v3": {
|
||||
"storageAccountType": "Premium_LRS"
|
||||
},
|
||||
"Standard_DC2s": {
|
||||
"storageAccountType": "Premium_LRS"
|
||||
},
|
||||
"Standard_DC4s": {
|
||||
"storageAccountType": "Premium_LRS"
|
||||
},
|
||||
"Standard_DS1": {
|
||||
"storageAccountType": "Premium_LRS"
|
||||
},
|
||||
|
@ -978,6 +998,12 @@ func GetSizeMap() string {
|
|||
"Standard_E16s_v3": {
|
||||
"storageAccountType": "Premium_LRS"
|
||||
},
|
||||
"Standard_E20_v3": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"Standard_E20s_v3": {
|
||||
"storageAccountType": "Premium_LRS"
|
||||
},
|
||||
"Standard_E2_v3": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
|
@ -1363,6 +1389,8 @@ func GetClassicAllowedSizes() string {
|
|||
"Standard_D64s_v3",
|
||||
"Standard_D8_v3",
|
||||
"Standard_D8s_v3",
|
||||
"Standard_DC2s",
|
||||
"Standard_DC4s",
|
||||
"Standard_DS1",
|
||||
"Standard_DS11",
|
||||
"Standard_DS11-1_v2",
|
||||
|
@ -1400,6 +1428,8 @@ func GetClassicAllowedSizes() string {
|
|||
"Standard_E16-8s_v3",
|
||||
"Standard_E16_v3",
|
||||
"Standard_E16s_v3",
|
||||
"Standard_E20_v3",
|
||||
"Standard_E20s_v3",
|
||||
"Standard_E2_v3",
|
||||
"Standard_E2s_v3",
|
||||
"Standard_E32-16s_v3",
|
||||
|
@ -1700,6 +1730,12 @@ func GetClassicSizeMap() string {
|
|||
},
|
||||
"Standard_D8s_v3": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"Standard_DC2s": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"Standard_DC4s": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"Standard_DS1": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
|
@ -1811,6 +1847,12 @@ func GetClassicSizeMap() string {
|
|||
},
|
||||
"Standard_E16s_v3": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"Standard_E20_v3": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"Standard_E20s_v3": {
|
||||
"storageAccountType": "Standard_LRS"
|
||||
},
|
||||
"Standard_E2_v3": {
|
||||
"storageAccountType": "Standard_LRS"
|
|
@ -69,22 +69,28 @@ func TestNormalizeAzureRegion(t *testing.T) {
|
|||
func TestPointerToBool(t *testing.T) {
|
||||
boolVar := true
|
||||
ret := PointerToBool(boolVar)
|
||||
if *ret != boolVar {
|
||||
t.Fatalf("expected PointerToBool(true) to return *true, instead returned %#v", ret)
|
||||
if !*ret {
|
||||
t.Fatal("expected PointerToBool(true) to return true")
|
||||
}
|
||||
|
||||
if IsTrueBoolPointer(ret) != boolVar {
|
||||
t.Fatalf("expected IsTrueBoolPointer(*true) to return true, instead returned %#v", IsTrueBoolPointer(ret))
|
||||
if !IsTrueBoolPointer(ret) {
|
||||
t.Fatal("expected IsTrueBoolPointer(*true) to return true")
|
||||
}
|
||||
|
||||
boolVar = false
|
||||
ret = PointerToBool(boolVar)
|
||||
if *ret != boolVar {
|
||||
t.Fatalf("expected PointerToBool(false) to return *false, instead returned %#v", ret)
|
||||
if *ret {
|
||||
t.Fatal("expected PointerToBool(false) to return false")
|
||||
}
|
||||
|
||||
if IsTrueBoolPointer(ret) != boolVar {
|
||||
t.Fatalf("expected IsTrueBoolPointer(*false) to return false, instead returned %#v", IsTrueBoolPointer(ret))
|
||||
if !IsFalseBoolPointer(ret) {
|
||||
t.Fatal("expected IsFalseBoolPointer(*false) to return true")
|
||||
}
|
||||
|
||||
boolVar = true
|
||||
ret = PointerToBool(boolVar)
|
||||
if IsFalseBoolPointer(ret) {
|
||||
t.Fatal("expected IsFalseBoolPointer(*true) to return false")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +111,15 @@ func TestPointerToInt(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPointerToString(t *testing.T) {
|
||||
str := "foobar"
|
||||
ret := PointerToString(str)
|
||||
|
||||
if *ret != str {
|
||||
t.Fatalf("expected PointerToString(foobar) to return *foobar, instead returned %#v", ret)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateSSH(t *testing.T) {
|
||||
rg := rand.New(rand.NewSource(42))
|
||||
|
||||
|
@ -334,3 +349,59 @@ func TestCreateSaveSSH(t *testing.T) {
|
|||
t.Fatalf("ssh file was not created")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCloudTargetEnv(t *testing.T) {
|
||||
testcases := []struct {
|
||||
input string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
"chinaeast",
|
||||
"AzureChinaCloud",
|
||||
},
|
||||
{
|
||||
"chinanorth",
|
||||
"AzureChinaCloud",
|
||||
},
|
||||
{
|
||||
"chinaeast",
|
||||
"AzureChinaCloud",
|
||||
},
|
||||
{
|
||||
"chinaeast2",
|
||||
"AzureChinaCloud",
|
||||
},
|
||||
{
|
||||
"chinanorth2",
|
||||
"AzureChinaCloud",
|
||||
},
|
||||
{
|
||||
"germanycentral",
|
||||
"AzureGermanCloud",
|
||||
},
|
||||
{
|
||||
"germanynortheast",
|
||||
"AzureGermanCloud",
|
||||
},
|
||||
{
|
||||
"usgov123",
|
||||
"AzureUSGovernmentCloud",
|
||||
},
|
||||
{
|
||||
"usdod-123",
|
||||
"AzureUSGovernmentCloud",
|
||||
},
|
||||
{
|
||||
"sampleinput",
|
||||
"AzurePublicCloud",
|
||||
},
|
||||
}
|
||||
|
||||
for _, testcase := range testcases {
|
||||
actual := GetCloudTargetEnv(testcase.input)
|
||||
if testcase.expected != actual {
|
||||
t.Errorf("expected GetCloudTargetEnv to return %s, but got %s", testcase.expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -221,3 +221,11 @@ func TestSubjectAltNameInCert(t *testing.T) {
|
|||
t.Fatalf("API server pair not generated.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePkiKeyCertPair(t *testing.T) {
|
||||
subject := "foosubject"
|
||||
_, err := CreatePkiKeyCertPair(subject)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error thrown while executing CreatePkiKeyCertPair : %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package certgen
|
||||
|
||||
import (
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/api/common"
|
||||
"github.com/Azure/acs-engine/pkg/openshift/certgen/release39"
|
||||
"github.com/Azure/acs-engine/pkg/openshift/certgen/unstable"
|
||||
)
|
||||
|
||||
// OpenShiftSetDefaultCerts sets default certificate and configuration properties in the
|
||||
// openshift orchestrator.
|
||||
func OpenShiftSetDefaultCerts(a *api.Properties, orchestratorName, clusterID string) (bool, error) {
|
||||
switch a.OrchestratorProfile.OrchestratorVersion {
|
||||
case common.OpenShiftVersion3Dot9Dot0:
|
||||
return release39.OpenShiftSetDefaultCerts(a, orchestratorName, clusterID)
|
||||
default:
|
||||
return unstable.OpenShiftSetDefaultCerts(a, orchestratorName, clusterID)
|
||||
}
|
||||
}
|
|
@ -2,80 +2,41 @@ package release39
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/openshift/filesystem"
|
||||
)
|
||||
|
||||
// OpenShiftSetDefaultCerts sets default certificate and configuration properties in the
|
||||
// openshift orchestrator for 3.9.
|
||||
func OpenShiftSetDefaultCerts(a *api.Properties, orchestratorName, clusterID string) (bool, error) {
|
||||
if len(a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["master"]) > 0 &&
|
||||
len(a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["bootstrap"]) > 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
c := Config{
|
||||
Master: &Master{
|
||||
Hostname: fmt.Sprintf("%s-master-%s-0", orchestratorName, clusterID),
|
||||
IPs: []net.IP{
|
||||
net.ParseIP(a.MasterProfile.FirstConsecutiveStaticIP),
|
||||
},
|
||||
Port: 8443,
|
||||
},
|
||||
ExternalMasterHostname: fmt.Sprintf("%s.%s.cloudapp.azure.com", a.MasterProfile.DNSPrefix, a.AzProfile.Location),
|
||||
ClusterUsername: a.OrchestratorProfile.OpenShiftConfig.ClusterUsername,
|
||||
ClusterPassword: a.OrchestratorProfile.OpenShiftConfig.ClusterPassword,
|
||||
EnableAADAuthentication: a.OrchestratorProfile.OpenShiftConfig.EnableAADAuthentication,
|
||||
AzureConfig: AzureConfig{
|
||||
TenantID: a.AzProfile.TenantID,
|
||||
SubscriptionID: a.AzProfile.SubscriptionID,
|
||||
AADClientID: a.ServicePrincipalProfile.ClientID,
|
||||
AADClientSecret: a.ServicePrincipalProfile.Secret,
|
||||
ResourceGroup: a.AzProfile.ResourceGroup,
|
||||
Location: a.AzProfile.Location,
|
||||
SecurityGroupName: fmt.Sprintf("%s-master-%s-nsg", orchestratorName, clusterID),
|
||||
PrimaryAvailabilitySetName: fmt.Sprintf("compute-availabilityset-%s", clusterID),
|
||||
},
|
||||
}
|
||||
func OpenShiftSetDefaultCerts(c *Config) ([]byte, []byte, error) {
|
||||
|
||||
err := c.PrepareMasterCerts()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
err = c.PrepareMasterKubeConfigs()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
err = c.PrepareMasterFiles()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
err = c.PrepareBootstrapKubeConfig()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if a.OrchestratorProfile.OpenShiftConfig.ConfigBundles == nil {
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles = make(map[string][]byte)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
masterBundle, err := getConfigBundle(c.WriteMaster)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["master"] = masterBundle
|
||||
|
||||
nodeBundle, err := getConfigBundle(c.WriteNode)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["bootstrap"] = nodeBundle
|
||||
|
||||
return true, nil
|
||||
return masterBundle, nodeBundle, nil
|
||||
}
|
||||
|
||||
type writeFn func(filesystem.Writer) error
|
||||
|
|
|
@ -2,80 +2,42 @@ package unstable
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/openshift/filesystem"
|
||||
)
|
||||
|
||||
// OpenShiftSetDefaultCerts sets default certificate and configuration properties in the
|
||||
// openshift orchestrator.
|
||||
func OpenShiftSetDefaultCerts(a *api.Properties, orchestratorName, clusterID string) (bool, error) {
|
||||
if len(a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["master"]) > 0 &&
|
||||
len(a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["bootstrap"]) > 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
c := Config{
|
||||
Master: &Master{
|
||||
Hostname: fmt.Sprintf("%s-master-%s-0", orchestratorName, clusterID),
|
||||
IPs: []net.IP{
|
||||
net.ParseIP(a.MasterProfile.FirstConsecutiveStaticIP),
|
||||
},
|
||||
Port: 8443,
|
||||
},
|
||||
ExternalMasterHostname: fmt.Sprintf("%s.%s.cloudapp.azure.com", a.MasterProfile.DNSPrefix, a.AzProfile.Location),
|
||||
ClusterUsername: a.OrchestratorProfile.OpenShiftConfig.ClusterUsername,
|
||||
ClusterPassword: a.OrchestratorProfile.OpenShiftConfig.ClusterPassword,
|
||||
EnableAADAuthentication: a.OrchestratorProfile.OpenShiftConfig.EnableAADAuthentication,
|
||||
AzureConfig: AzureConfig{
|
||||
TenantID: a.AzProfile.TenantID,
|
||||
SubscriptionID: a.AzProfile.SubscriptionID,
|
||||
AADClientID: a.ServicePrincipalProfile.ClientID,
|
||||
AADClientSecret: a.ServicePrincipalProfile.Secret,
|
||||
ResourceGroup: a.AzProfile.ResourceGroup,
|
||||
Location: a.AzProfile.Location,
|
||||
SecurityGroupName: fmt.Sprintf("%s-master-%s-nsg", orchestratorName, clusterID),
|
||||
PrimaryAvailabilitySetName: fmt.Sprintf("compute-availabilityset-%s", clusterID),
|
||||
},
|
||||
}
|
||||
|
||||
func OpenShiftSetDefaultCerts(c *Config) ([]byte, []byte, error) {
|
||||
err := c.PrepareMasterCerts()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
err = c.PrepareMasterKubeConfigs()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
err = c.PrepareMasterFiles()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
err = c.PrepareBootstrapKubeConfig()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if a.OrchestratorProfile.OpenShiftConfig.ConfigBundles == nil {
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles = make(map[string][]byte)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
masterBundle, err := getConfigBundle(c.WriteMaster)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["master"] = masterBundle
|
||||
|
||||
nodeBundle, err := getConfigBundle(c.WriteNode)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, nil, err
|
||||
}
|
||||
a.OrchestratorProfile.OpenShiftConfig.ConfigBundles["bootstrap"] = nodeBundle
|
||||
|
||||
return true, nil
|
||||
return masterBundle, nodeBundle, nil
|
||||
}
|
||||
|
||||
type writeFn func(filesystem.Writer) error
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/acsengine"
|
||||
"github.com/Azure/acs-engine/pkg/operations"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -66,12 +65,14 @@ func (uc *UpgradeCluster) runUpgrade() error {
|
|||
uc.ClusterTopology.DataModel.Properties.OrchestratorProfile.DcosConfig.BootstrapProfile == nil {
|
||||
return errors.New("BootstrapProfile is not set")
|
||||
}
|
||||
newVersion := uc.ClusterTopology.DataModel.Properties.OrchestratorProfile.OrchestratorVersion
|
||||
|
||||
cs := uc.ClusterTopology.DataModel
|
||||
newVersion := cs.Properties.OrchestratorProfile.OrchestratorVersion
|
||||
dashedVersion := strings.Replace(newVersion, ".", "-", -1)
|
||||
|
||||
masterDNS := acsengine.FormatAzureProdFQDN(uc.ClusterTopology.DataModel.Properties.MasterProfile.DNSPrefix, uc.ClusterTopology.DataModel.Location)
|
||||
masterCount := uc.ClusterTopology.DataModel.Properties.MasterProfile.Count
|
||||
bootstrapIP := uc.ClusterTopology.DataModel.Properties.OrchestratorProfile.DcosConfig.BootstrapProfile.StaticIP
|
||||
masterDNS := cs.GetAzureProdFQDN()
|
||||
masterCount := cs.Properties.MasterProfile.Count
|
||||
bootstrapIP := cs.Properties.OrchestratorProfile.DcosConfig.BootstrapProfile.StaticIP
|
||||
uc.Logger.Infof("masterDNS:%s masterCount:%d bootstrapIP:%s", masterDNS, masterCount, bootstrapIP)
|
||||
|
||||
// copy SSH key to master
|
||||
|
|
|
@ -4,16 +4,14 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/acsengine"
|
||||
"fmt"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/api"
|
||||
"github.com/Azure/acs-engine/pkg/armhelpers"
|
||||
"github.com/Azure/acs-engine/pkg/i18n"
|
||||
. "github.com/Azure/acs-engine/pkg/test"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"fmt"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/satori/go.uuid"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -31,7 +29,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing to list VMs during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 1, 1, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 1, 1, false)
|
||||
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.14"
|
||||
|
||||
|
@ -55,7 +53,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing to delete VMs during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 1, 1, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 1, 1, false)
|
||||
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.16"
|
||||
uc := UpgradeCluster{
|
||||
|
@ -75,7 +73,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing to deploy template during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.7.16", 1, 1, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.7.16", 1, 1, false)
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.16"
|
||||
uc := UpgradeCluster{
|
||||
Translator: &i18n.Translator{},
|
||||
|
@ -94,7 +92,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing to get a virtual machine during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 1, 6, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 1, 6, false)
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.16"
|
||||
uc := UpgradeCluster{
|
||||
Translator: &i18n.Translator{},
|
||||
|
@ -113,7 +111,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing to get storage client during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 5, 1, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 5, 1, false)
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.16"
|
||||
uc := UpgradeCluster{
|
||||
Translator: &i18n.Translator{},
|
||||
|
@ -132,7 +130,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing to delete network interface during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 3, 2, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.16"
|
||||
uc := UpgradeCluster{
|
||||
Translator: &i18n.Translator{},
|
||||
|
@ -151,7 +149,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing on ClusterPreflightCheck operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 3, 3, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 3, 3, false)
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.8.15"
|
||||
uc := UpgradeCluster{
|
||||
Translator: &i18n.Translator{},
|
||||
|
@ -170,7 +168,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should return error message when failing to delete role assignment during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 3, 2, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.16"
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{}
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity = true
|
||||
|
@ -192,7 +190,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
|
|||
})
|
||||
|
||||
It("Should not fail if no managed identity is returned by azure during upgrade operation", func() {
|
||||
cs := acsengine.CreateMockContainerService("testcluster", "1.6.9", 3, 2, false)
|
||||
cs := api.CreateMockContainerService("testcluster", "1.6.9", 3, 2, false)
|
||||
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.7.16"
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{}
|
||||
cs.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity = true
|
||||
|
|
|
@ -530,9 +530,15 @@ func (ku *Upgrader) generateUpgradeTemplate(upgradeContainerService *api.Contain
|
|||
return nil, nil, ku.Translator.Errorf("failed to initialize template generator: %s", err.Error())
|
||||
}
|
||||
|
||||
_, err = upgradeContainerService.SetPropertiesDefaults(true, false)
|
||||
if err != nil {
|
||||
return nil, nil, ku.Translator.Errorf("error in SetPropertiesDefaults: %s", err.Error())
|
||||
|
||||
}
|
||||
|
||||
var templateJSON string
|
||||
var parametersJSON string
|
||||
if templateJSON, parametersJSON, _, err = templateGenerator.GenerateTemplate(upgradeContainerService, acsengine.DefaultGeneratorCode, true, false, acsengineVersion); err != nil {
|
||||
if templateJSON, parametersJSON, err = templateGenerator.GenerateTemplate(upgradeContainerService, acsengine.DefaultGeneratorCode, acsengineVersion); err != nil {
|
||||
return nil, nil, ku.Translator.Errorf("error generating upgrade template: %s", err.Error())
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/acs-engine/pkg/acsengine"
|
||||
"github.com/Azure/acs-engine/pkg/helpers"
|
||||
"github.com/Azure/acs-engine/test/acs-engine-test/config"
|
||||
"github.com/Azure/acs-engine/test/acs-engine-test/metrics"
|
||||
"github.com/Azure/acs-engine/test/acs-engine-test/promote"
|
||||
|
@ -590,7 +590,7 @@ func mainInternal() error {
|
|||
}
|
||||
// set regions
|
||||
regions := []string{}
|
||||
for _, region := range acsengine.AzureLocations {
|
||||
for _, region := range helpers.GetAzureLocations() {
|
||||
switch region {
|
||||
case "eastus2euap": // initial deploy region for all RPs, known to be less stable
|
||||
case "japanwest": // no D2V2 support
|
||||
|
|
Загрузка…
Ссылка в новой задаче