TKGm: 2.5.x
This issue happens because customers rotated the AVI certificate before the upgrade, but this new value won’t be updated in the ako operator addon secret/tkg-pkg secret. When upgrading to a 2.1 (and above) cluster, the ako operator will be reconciled by tkg-pkg, and the AVI certificate value is set to the value in the tkg-pkg secret. Upgrade will fail because AVI still uses the old AVI certificate.
kubectl get secret <cluster-name>-ako-operator-addon -n tkg-systemkubectl get secret avi-controller-ca -n tkg-system-networkingkubectl edit secret <cluster-name>-ako-operator-addon -n tkg-systemkubectl edit secret avi-controller-ca -n tkg-system-networking
Before the upgrade, check the AVI certificate in tkg-pkg-<namespace>-values and in avi-controller-ca. If the two values differ, manually patch the tkg-pkg-<namespace>-values secret with the new AVI certificate.
kubectl get secret tkg-pkg-tkg-system-values -n tkg-system -o yaml > tkg-values-backup.yaml
openssl s_client -connect #.#.#.#:443 -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM > avi-controller.crtNEW_CA=$(cat avi-controller.crt | base64 -w 0)kubectl get secret tkg-pkg-tkg-system-values -n tkg-system -o jsonpath='{.data.tkgpackagevalues\.yaml}' | base64 -d > tkg-internal-config.yamlsed -i "s/AVI_CA_DATA_B64: .*/AVI_CA_DATA_B64: $NEW_CA/" tkg-internal-config.yamlsed -i "s/avi_ca_data_b64: .*/avi_ca_data_b64: $NEW_CA/" tkg-internal-config.yamlkubectl patch secret tkg-pkg-tkg-system-values -n tkg-system --type='json' -p="[{\"op\": \"replace\", \"path\": \"/data/tkgpackagevalues.yaml\", \"value\":\"$(cat tkg-internal-config.yaml | base64 -w 0)\"}]"kubectl patch secret avi-controller-ca -n tkg-system-networking --type='json' -p="[{\"op\": \"replace\", \"path\": \"/data/certificate\", \"value\":\"$NEW_CA\"}]"kubectl get secret tkg-pkg-tkg-system-values -n tkg-system -o jsonpath='{.data.tkgpackagevalues\.yaml}' | base64 -d | grep "AVI_CA_DATA_B64"kubectl rollout restart deployment/ako -n avi-system