容器与云原生

因为证书过期的原因导致vCenter界面中[TKG服务]中[默认CNI]和[Tanzu Mission Control]菜单显示502

· 355 字 · 约 1 分钟

vSphere 与 Tanzu 的网络图

需要先获取到 Supervisor Control Plane VMs 的 Root 密码

ssh 到 vCenter 服务器

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
root@vcenter [ ~ ]# /usr/lib/vmware-wcp/decryptK8Pwd.py
Read key from file

Connected to PSQL

Cluster: domain-c8:rg64l2-ghkl-256l-a32c-3b85d0b5a1d5
IP: 10.10.10.10
PWD: UPvd82Jc8buR9nsceMbg=
------------------------------------------------------------

root@vcenter [ ~ ]#

The TKG plugin should help configuring some options from the vCenter UI under Hosts and Clusters > Cluster > Configure > TKG Service, such as setting the Default Tanzu Kubernetes cluster CNI plugin and register clusters in Tanzu Mission Control. It communicates with tkgs-plugin-server pod in the backend through a masterproxy-tkgs-plugin pod, which acts as a reverse proxy to ensure that calls from that TKG interface in the vSphere client are properly routed to the tkgs-plugin-server.

When the TLS certificate in tkgs-plugin-tls-secret expires, this communication fails with status code 502 Bad Gateway. The masterproxy-tkgs-plugin logs should report this error:

1
2023-03-01T11:45:30.846010245Z stderr F 2023/02/08 11:45:30 [error] 8#0: *5167 upstream SSL certificate verify error: (10:certificate has expired) while SSL handshaking to upstream, client: 127.0.0.1, server: localhost, request: "GET /plugin.json HTTP/1.0", upstream: "https://10.96.0.77:8099/plugin.json", host: "127.0.0.1:9900"

The tkgs-plugin-tls-secret should contain an expired TLS certificate:

Check the expiry date of the TLS certificate for TKG plugin:

通过上边在 vCenter 数据库中获取到的 IP 和密码 SSH 到 Control Plane VMs

检查证书的有效期间

1
2
# kubectl get secret -n vmware-system-tkg tkgs-plugin-tls-secret -o jsonpath='{.data.tls\.crt}' |base64 -d |openssl x509 -noout -text |grep After
            Not After : Dec 20 11:12:12 2022 GMT <---- expired

重新生成证书

1- Access the supervisor cluster as instructed above. 2- Go to the directory in which TKGs plugin deployment is stored:

1
cd /usr/lib/vmware-wcp/objects/PodVM-GuestCluster/13-tkgs-plugin

3- Force replace the deployment of the TKG plugin using the definition file:

1
kubectl replace -f tkgs-plugin-deployment.yaml --force

4- Ensure the certificate is now rotated:

1
2
kubectl get secret -n vmware-system-tkg tkgs-plugin-tls-secret -o jsonpath='{.data.tls\.crt}' |base64 -d |openssl x509 -noout -text |grep After
            Not After : Mar  2 08:46:17 2024 GMT