Retrieve the Azure credentials from Azure administrator and encode them
echo -n CREDENTIAL | base64 -w 0Target the Management cluster and update the capz-manager-bootstrap-credentials secret
kubectl config use-context MGMT-CONTEXT
kubectl patch secret capz-manager-bootstrap-credentials -n capz-system --type merge -p '{"data":{"client-secret": "ENCODED-CREDENTIAL"}}'Restart the Controller Manager pod
kubectl delete pod CONTROLLER_MANAGER-POD -n capz-system kubectl get pods -n capz-systemThe azure json secrets will also be updated with new credentials
kubectl get secrets -A | grep azure-json
kubectl get secret AZURE-JSON-SECRET -o jsonpath='{.data.azure\.json}' | base64 -dAzure CSI DriversIf Azure CSI drivers have been installed on the cluster, please perform the following steps to rotate the credentials. When installing the Azure CSI Drivers, the administrator would have chosen to store the credentials in a secret on the cluster or else in a file on the Control Plane nodes.
Proceed with the corresponding steps below depending on which option was selected when the CSI driver were installed.
- Credentials stored in Secret
kubectl get secret azure-cloud-provider -n kube-system
kubectl get secrets -n kube-system azure-cloud-provider -o jsonpath={'.data.cloud-config'} | base64 -d > cloud-config.yaml
vi cloud-config.yaml
kubectl create secret generic azure-cloud-provider --from-file=cloud-config=cloud-config.yaml -n kube-system -o yaml --dry-run | kubectl replace -f-Restart the CSI Driver pods in kube-system namespace
kubectl get pods -n kube-system | grep csi
kubectl delete pod POD -n kube-system
- Credentials stored in azure.json on Control Plane nodes
The /etc/kubernetes/azure.json file is created during initialisation of the node using data from secret MACHINE-NAME-azure-json.
The nodes will need to be redeployed to update azure.json.
For Control Plane nodes, add "upgradeAfter" to kubeadmControlPlane spec with a timestamp in RFC3339 UTC "Zulu" format
kubectl get kcp -A
kubectl edit kcp -n NAMESPACE KUBEADM-CONTROL-PLANE
spec:
replicas: 1
upgradeAfter: "2022-04-19T16:16:07Z"For Worker nodes, delete the machine and it will be redeployed.
kubectl get machines -A
kubectl delete machine MACHINE-NAME -n namespace