NOTE: the method below is for old unsupported TKGi version. From TKGi 1.10+, you should use tkgi rotate-certificate cli as per: Tanzu Kubernetes Grid Integrated Edition Certificates
Identify the tls-nsx-t certificate that needs to be rotated and match with it in NSX-T Manager:
export BOSH_CLIENT=ops_manager BOSH_CLIENT_SECRET=gu_v9OiwFmDjDnrQ-9Kpwca121lTYzxx BOSH_CA_CERT=/var/tempest/workspaces/default/root_ca_certificate BOSH_ENVIRONMENT=<Bosh-ip-address>
export CREDHUB_CLIENT=$BOSH_CLIENT CREDHUB_SECRET=$BOSH_CLIENT_SECRET && credhub api --server $BOSH_ENVIRONMENT:8844 --ca-cert $BOSH_CA_CERT && credhub login
# bosh deployments --column=name | grep service-instance
service-instance_c18dd0e4-00b6-4054-9f86-b1a82aebac1e
credhub get -n /p-bosh/service-instance_UUID/tls-nsx-t --output-json | jq '.value | .certificate' -r | openssl x509 -enddate -noout
notBefore=Jul 23 22:19:50 2018 GMT
notAfter=Jul 23 22:19:50 2020 GMT >>>>> Certificate Is expired
mkdir cluster-<The_Last_Numbers_of_Cluster-UUID>
cd cluster-b1a82aebac1e
credhub get -n /p-bosh/<service-instance_UUID>/tls-nsx-t --output-json | jq '.value | .certificate' -r > old-tls-nsx-t.crt
credhub r -n /p-bosh/<service-instance_UUID>/tls-nsx-t
id: c4bf1cdb-af06-4a88-b25e-4f3123c939db
name: /p-bosh/service-instance_c18dd0e4-00b6-4054-9f86-b1a82aebac1e/tls-nsx-t
type: certificate
value: <redacted>
version_created_at: "2020-08-10T19:20:50Z"
credhub get -n /p-bosh/service-instance_UUID/tls-nsx-t --output-json | jq '.value | .certificate' -r | openssl x509 -startdate -enddate -noout
notBefore=Aug 10 19:20:50 2020 GMT
notAfter=Aug 10 19:20:50 2022 GM >>>>>> The certificate will expired in the next 2 years
Register the certificate with NSX-T and push it to Kubernetes VMs to replace the old certificate:
You can leverage pksnsxcli present on the Kubernetes master nodes to register the tls-nsx-t certificate with NSX-T Manager. The advantage of following this procedure is that it creates a locked certificate object which can’t be deleted via the UI.
bosh ssh -d service-instance_<cluster-uuid> master
alias pksnsxcli=/var/vcap/packages/pks-nsx-t-cli/bin/pksnsxcli
curl -X DELETE -sku 'admin:<password>' "https://<nsx manager>/policy/api/v1/infra/certificates/<policy-cert-id>" --header "X-Allow-Overwrite: true"
Issue commands similar to the following to recreate the cluster by using Bosh manifest, to register this certificate with NSX-T and push it to Kubernetes VMs:
bosh manifest -d service-instance_instance-id > service-instance_instance-id.yml
bosh deploy -d service-instance_instance-id service-instance_instance-id.yml
Note: This activity restarts only master VMs in order to update the tls-nsx-t certificate. There is no impact on worker nodes.