@@ -141,6 +141,18 @@ wait_for_nodes() {
141141 " ${KUBECTL} " get nodes -owide
142142}
143143
144+ copy_secret () {
145+ # point at the management cluster
146+ unset KUBECONFIG
147+ " ${KUBECTL} " get secret " ${CLUSTER_NAME} -control-plane-azure-json" -o jsonpath=' {.data.control-plane-azure\.json}' | base64 --decode > azure_json
148+
149+ # set KUBECONFIG back to the workload cluster
150+ export KUBECONFIG=" ${KUBECONFIG:- ${PWD} / kubeconfig} "
151+ " ${KUBECTL} " create secret generic " ${CONFIG_SECRET_NAME} " -n kube-system \
152+ --from-file=cloud-config=azure_json
153+ rm azure_json
154+ }
155+
144156# cleanup all resources we use
145157cleanup () {
146158 timeout 1800 " ${KUBECTL} " delete cluster " ${CLUSTER_NAME} " || true
@@ -185,6 +197,17 @@ if [[ -n "${TEST_CCM:-}" ]]; then
185197 # "app=calico" is the label only for calico-node-windows pods
186198 " ${KUBECTL} " wait --for=condition=Ready pod -l app=calico -n kube-system --timeout=10m
187199 fi
200+
201+ CLOUD_CONFIG=" /etc/kubernetes/azure.json"
202+ CONFIG_SECRET_NAME=" "
203+ ENABLE_DYNAMIC_RELOADING=false
204+ if [[ -n " ${LOAD_CLOUD_CONFIG_FROM_SECRET:- } " ]]; then
205+ CLOUD_CONFIG=" "
206+ CONFIG_SECRET_NAME=" azure-cloud-provider"
207+ ENABLE_DYNAMIC_RELOADING=true
208+ copy_secret
209+ fi
210+
188211 echo " Installing cloud-provider-azure components via helm"
189212 " ${HELM} " install --repo https://raw.githubusercontent.com/kubernetes-sigs/cloud-provider-azure/master/helm/repo cloud-provider-azure --generate-name \
190213--set infra.clusterName=" ${CLUSTER_NAME} " \
@@ -194,7 +217,11 @@ if [[ -n "${TEST_CCM:-}" ]]; then
194217--set cloudNodeManager.imageName=" ${CNM_IMAGE_NAME} " \
195218--set-string cloudControllerManager.imageTag=" ${IMAGE_TAG} " \
196219--set-string cloudNodeManager.imageTag=" ${IMAGE_TAG} " \
197- --set cloudControllerManager.replicas=" ${CCM_COUNT} "
220+ --set cloudControllerManager.replicas=" ${CCM_COUNT} " \
221+ --set cloudControllerManager.enableDynamicReloading=" ${ENABLE_DYNAMIC_RELOADING} " \
222+ --set cloudControllerManager.cloudConfig=" ${CLOUD_CONFIG} " \
223+ --set cloudControllerManager.cloudConfigSecretName=" ${CONFIG_SECRET_NAME} "
224+
198225 echo " Waiting for all kube-system pods to be ready"
199226 " ${KUBECTL} " wait --for=condition=Ready pod -n kube-system --all --timeout=10m
200227fi
0 commit comments