https://github.com/kubesphere/kubekey/blob/master/docs/check-renew-certificate.md
查询证书
[root@master ~]# ls -l
total 9770232
-rw-------. 1 root root 1405 Jul 8 2021 anaconda-ks.cfg
-rw-r--r-- 1 root root 10026 Jun 9 16:30 cluster-configuration.yaml
-rw-r--r-- 1 root root 4748 Jun 6 16:50 config-sample.yaml
-rw-r--r--. 1 root root 1269 Jun 6 11:06 config-sample.yaml.ba
drwxrwxr-x 10 root root 244 Jun 17 15:30 kubegems-1.21.0
-rw-r--r-- 1 root root 1208820 Jun 23 13:45 kubegems-1.21.0.tar.gz
drwxr-xr-x. 13 root root 166 Jun 6 11:42 kubekey
-rw-r--r--. 1 root root 17716475 Jun 6 10:50 kubekey-v2.1.1-linux-64bit.rpm
-rw-r--r--. 1 root root 9985745698 Dec 17 2021 kubesphere-all-v3.1.0-offline-linux-amd64.tar.gz
-rw-r--r-- 1 root root 4555 Jun 9 16:30 kubesphere-installer.yaml
[root@master ~]# kk certs check-expiration
_ __ _ _ __
| | / / | | | | / /
| |/ / _ _| |__ ___| |/ / ___ _ _
| \| | | | '_ \ / _ \ \ / _ \ | | |
| |\ \ |_| | |_) | __/ |\ \ __/ |_| |
\_| \_/\__,_|_.__/ \___\_| \_/\___|\__, |
__/ |
|___/
14:03:57 CST [GreetingsModule] Greetings
14:03:58 CST message: [master]
Greetings, KubeKey!
14:03:58 CST success: [master]
14:03:58 CST [CheckCertsModule] Check cluster certs
14:04:00 CST success: [master]
14:04:00 CST [PrintClusterCertsModule] Display cluster certs form
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY NODE
apiserver.crt Jun 06, 2023 03:42 UTC 298d ca master
apiserver-kubelet-client.crt Jun 06, 2023 03:42 UTC 298d ca master
front-proxy-client.crt Jun 06, 2023 03:42 UTC 298d front-proxy-ca master
admin.conf Jun 06, 2023 03:42 UTC 298d master
controller-manager.conf Jun 06, 2023 03:42 UTC 298d master
scheduler.conf Jun 06, 2023 03:42 UTC 298d master
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME NODE
ca.crt Jun 03, 2032 03:42 UTC 9y master
front-proxy-ca.crt Jun 03, 2032 03:42 UTC 9y master
14:04:00 CST success: [LocalHost]
14:04:00 CST Pipeline[CheckCertsPipeline] execute successful
更新证书
[root@master ~]# kk certs renew
_ __ _ _ __
| | / / | | | | / /
| |/ / _ _| |__ ___| |/ / ___ _ _
| \| | | | '_ \ / _ \ \ / _ \ | | |
| |\ \ |_| | |_) | __/ |\ \ __/ |_| |
\_| \_/\__,_|_.__/ \___\_| \_/\___|\__, |
__/ |
|___/
14:04:11 CST [GreetingsModule] Greetings
14:04:11 CST message: [master]
Greetings, KubeKey!
14:04:11 CST success: [master]
14:04:11 CST [RenewCertsModule] Renew control-plane certs
14:04:12 CST stdout: [master]
v1.21.5
14:04:17 CST success: [master]
14:04:17 CST [RenewCertsModule] Copy admin.conf to ~/.kube/config
14:04:21 CST success: [master]
14:04:21 CST [RenewCertsModule] Fetch kube config file from control-plane
14:04:22 CST success: [master]
14:04:22 CST [RenewCertsModule] Synchronize kube config to worker
14:04:22 CST skipped: [master]
14:04:22 CST [CheckCertsModule] Check cluster certs
14:04:25 CST success: [master]
14:04:25 CST [PrintClusterCertsModule] Display cluster certs form
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY NODE
apiserver.crt Aug 11, 2023 06:04 UTC 364d ca master
apiserver-kubelet-client.crt Aug 11, 2023 06:04 UTC 364d ca master
front-proxy-client.crt Aug 11, 2023 06:04 UTC 364d front-proxy-ca master
admin.conf Aug 11, 2023 06:04 UTC 364d master
controller-manager.conf Aug 11, 2023 06:04 UTC 364d master
scheduler.conf Aug 11, 2023 06:04 UTC 364d master
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME NODE
ca.crt Jun 03, 2032 03:42 UTC 9y master
front-proxy-ca.crt Jun 03, 2032 03:42 UTC 9y master
14:04:25 CST success: [LocalHost]
14:04:25 CST Pipeline[RenewCertsPipeline] execute successful
[root@master ~]#
自动更换证书
[root@master ~]# find / admin.conf |grep admin.conf
/etc/kubernetes/admin.conf
/root/kubekey/master/admin.conf
/tmp/kubekey/admin.conf
find: ‘admin.conf’: No such file or directory
[root@master ~]#
[root@master ~]# ls -l /etc/kubernetes/admin.conf
-rw-------. 1 kube root 5611 Aug 11 14:04 /etc/kubernetes/admin.conf
[root@master ~]# ls -l /root/kubekey/master/admin.conf
-rw-r--r-- 1 root root 5611 Aug 11 14:04 /root/kubekey/master/admin.conf
[root@master ~]# ls -l /root/kubekey/master/admin.conf
-rw-r--r-- 1 root root 5611 Aug 11 14:04 /root/kubekey/master/admin.conf
[root@master ~]# ls -l /root/.kube/config
-rw-------. 1 root root 5611 Aug 11 14:04 /root/.kube/config
[root@master ~]#