diff --git a/parts/k8s/kubernetesagentresourcesvmas.t b/parts/k8s/kubernetesagentresourcesvmas.t index 255225e6c3..2d85590f2a 100644 --- a/parts/k8s/kubernetesagentresourcesvmas.t +++ b/parts/k8s/kubernetesagentresourcesvmas.t @@ -331,7 +331,7 @@ {{if IsOpenShift }} "script": "{{ Base64 (OpenShiftGetNodeSh .) }}" {{else}} - "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 40 1 3 nc -vz k8s.gcr.io 443 || retrycmd_if_failure 40 1 3 nc -vz gcr.azk8s.cn 80 || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' GPU_NODE={{IsNSeriesSKU .}} /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1{{if CSERunInBackground }} &{{end}}\"')]" + "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 75 1 3 nc -vz {{if IsMooncake}}gcr.azk8s.cn 80{{else}}k8s.gcr.io 443 || retrycmd_if_failure 75 1 3 nc -vz 8.8.8.8 443{{end}} || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' GPU_NODE={{IsNSeriesSKU .}} /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1{{if CSERunInBackground }} &{{end}}\"')]" {{end}} } } diff --git a/parts/k8s/kubernetesagentresourcesvmss.t b/parts/k8s/kubernetesagentresourcesvmss.t index 5bd16e755b..fb6c283e0a 100644 --- a/parts/k8s/kubernetesagentresourcesvmss.t +++ b/parts/k8s/kubernetesagentresourcesvmss.t @@ -155,7 +155,7 @@ "autoUpgradeMinorVersion": true, "settings": {}, "protectedSettings": { - "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 40 1 3 nc -vz k8s.gcr.io 443 || retrycmd_if_failure 40 1 3 nc -vz gcr.azk8s.cn 80 || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' GPU_NODE={{IsNSeriesSKU .}} /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1{{if CSERunInBackground }} &{{end}}\"')]" + "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 75 1 3 nc -vz {{if IsMooncake}}gcr.azk8s.cn 80{{else}}k8s.gcr.io 443 || retrycmd_if_failure 75 1 3 nc -vz 8.8.8.8 443{{end}} || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' GPU_NODE={{IsNSeriesSKU .}} /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1{{if CSERunInBackground }} &{{end}}\"')]" } } } diff --git a/parts/k8s/kubernetesmasterresources.t b/parts/k8s/kubernetesmasterresources.t index 9b03e9632d..fb835810f5 100644 --- a/parts/k8s/kubernetesmasterresources.t +++ b/parts/k8s/kubernetesmasterresources.t @@ -929,7 +929,7 @@ {{if IsOpenShift}} "script": "{{ Base64 OpenShiftGetMasterSh }}" {{else}} - "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 40 1 3 nc -vz k8s.gcr.io 443 || retrycmd_if_failure 40 1 3 nc -vz gcr.azk8s.cn 80 || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' ',variables('provisionScriptParametersMaster'), ' /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1\"')]" + "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 75 1 3 nc -vz {{if IsMooncake}}gcr.azk8s.cn 80{{else}}k8s.gcr.io 443 || retrycmd_if_failure 75 1 3 nc -vz 8.8.8.8 443{{end}} || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' ',variables('provisionScriptParametersMaster'), ' /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1\"')]" {{end}} } } diff --git a/parts/k8s/kubernetesmasterresourcesvmss.t b/parts/k8s/kubernetesmasterresourcesvmss.t index 4d20fe224f..18891186bf 100644 --- a/parts/k8s/kubernetesmasterresourcesvmss.t +++ b/parts/k8s/kubernetesmasterresourcesvmss.t @@ -431,7 +431,7 @@ "autoUpgradeMinorVersion": true, "settings": {}, "protectedSettings": { - "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 40 1 3 nc -vz k8s.gcr.io 443 || retrycmd_if_failure 40 1 3 nc -vz gcr.azk8s.cn 80 || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' ',variables('provisionScriptParametersMaster'), ' /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1\"')]" + "commandToExecute": "[concat('retrycmd_if_failure() { r=$1; w=$2; t=$3; shift && shift && shift; for i in $(seq 1 $retries); do timeout $t ${@}; [ $? -eq 0 ] && break || if [ $i -eq $r ]; then return 1; else sleep $w; fi; done }; ERR_OUTBOUND_CONN_FAIL=50; retrycmd_if_failure 75 1 3 nc -vz {{if IsMooncake}}gcr.azk8s.cn 80{{else}}k8s.gcr.io 443 || retrycmd_if_failure 75 1 3 nc -vz 8.8.8.8 443{{end}} || exit $ERR_OUTBOUND_CONN_FAIL; for i in $(seq 1 1200); do if [ -f /opt/azure/containers/provision.sh ]; then break; fi; if [ $i -eq 1200 ]; then exit 100; else sleep 1; fi; done; ', variables('provisionScriptParametersCommon'),' ',variables('provisionScriptParametersMaster'), ' /usr/bin/nohup /bin/bash -c \"/bin/bash /opt/azure/containers/provision.sh >> /var/log/azure/cluster-provision.log 2>&1\"')]" } } } diff --git a/pkg/acsengine/const.go b/pkg/acsengine/const.go index 710b99ecff..c90a056a8c 100644 --- a/pkg/acsengine/const.go +++ b/pkg/acsengine/const.go @@ -200,7 +200,3 @@ const ( swarmWinAgentResourcesVMSS = "swarm/swarmwinagentresourcesvmss.t" windowsParams = "windowsparams.t" ) - -const ( - azurePublicCloud = "AzurePublicCloud" -) diff --git a/pkg/acsengine/template_generator.go b/pkg/acsengine/template_generator.go index 9f5b6f6ebd..72cf4aa5cb 100644 --- a/pkg/acsengine/template_generator.go +++ b/pkg/acsengine/template_generator.go @@ -371,7 +371,11 @@ func (t *TemplateGenerator) getTemplateFuncMap(cs *api.ContainerService) templat }, "UseAksExtension": func() bool { cloudSpecConfig := cs.GetCloudSpecConfig() - return cloudSpecConfig.CloudName == azurePublicCloud + return cloudSpecConfig.CloudName == api.AzurePublicCloud + }, + "IsMooncake": func() bool { + cloudSpecConfig := cs.GetCloudSpecConfig() + return cloudSpecConfig.CloudName == api.AzureChinaCloud }, "UseInstanceMetadata": func() bool { return helpers.IsTrueBoolPointer(cs.Properties.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata) diff --git a/pkg/api/azenvtypes.go b/pkg/api/azenvtypes.go index a862a22eac..15fdc73d80 100644 --- a/pkg/api/azenvtypes.go +++ b/pkg/api/azenvtypes.go @@ -169,7 +169,7 @@ var ( //AzureCloudSpec is the default configurations for global azure. AzureCloudSpec = AzureEnvironmentSpecConfig{ - CloudName: azurePublicCloud, + CloudName: AzurePublicCloud, //DockerSpecConfig specify the docker engine download repo DockerSpecConfig: DefaultDockerSpecConfig, //KubernetesSpecConfig is the default kubernetes container image url. @@ -228,7 +228,7 @@ var ( //AzureChinaCloudSpec is the configurations for Azure China (Mooncake) AzureChinaCloudSpec = AzureEnvironmentSpecConfig{ - CloudName: azureChinaCloud, + CloudName: AzureChinaCloud, //DockerSpecConfig specify the docker engine download repo DockerSpecConfig: DockerSpecConfig{ DockerEngineRepo: "https://mirror.azk8s.cn/docker-engine/apt/repo/", @@ -269,9 +269,9 @@ var ( // AzureCloudSpecEnvMap is the environment configuration map for all the Azure cloid environments. AzureCloudSpecEnvMap = map[string]AzureEnvironmentSpecConfig{ - azureChinaCloud: AzureChinaCloudSpec, + AzureChinaCloud: AzureChinaCloudSpec, azureGermanCloud: AzureGermanCloudSpec, azureUSGovernmentCloud: AzureUSGovernmentCloud, - azurePublicCloud: AzureCloudSpec, + AzurePublicCloud: AzureCloudSpec, } ) diff --git a/pkg/api/const.go b/pkg/api/const.go index 71b48ebffa..41b860e899 100644 --- a/pkg/api/const.go +++ b/pkg/api/const.go @@ -382,8 +382,10 @@ const ( ) const ( - azurePublicCloud = "AzurePublicCloud" - azureChinaCloud = "AzureChinaCloud" + // AzurePublicCloud is a const string reference identifier for public cloud + AzurePublicCloud = "AzurePublicCloud" + // AzureChinaCloud is a const string reference identifier for china cloud + AzureChinaCloud = "AzureChinaCloud" azureGermanCloud = "AzureGermanCloud" azureUSGovernmentCloud = "AzureUSGovernmentCloud" )