https://github.com/kubesphere/kubekey/blob/master/docs/check-renew-certificate.md
查询证书

  1. [root@master ~]# ls -l
  2. total 9770232
  3. -rw-------. 1 root root 1405 Jul 8 2021 anaconda-ks.cfg
  4. -rw-r--r-- 1 root root 10026 Jun 9 16:30 cluster-configuration.yaml
  5. -rw-r--r-- 1 root root 4748 Jun 6 16:50 config-sample.yaml
  6. -rw-r--r--. 1 root root 1269 Jun 6 11:06 config-sample.yaml.ba
  7. drwxrwxr-x 10 root root 244 Jun 17 15:30 kubegems-1.21.0
  8. -rw-r--r-- 1 root root 1208820 Jun 23 13:45 kubegems-1.21.0.tar.gz
  9. drwxr-xr-x. 13 root root 166 Jun 6 11:42 kubekey
  10. -rw-r--r--. 1 root root 17716475 Jun 6 10:50 kubekey-v2.1.1-linux-64bit.rpm
  11. -rw-r--r--. 1 root root 9985745698 Dec 17 2021 kubesphere-all-v3.1.0-offline-linux-amd64.tar.gz
  12. -rw-r--r-- 1 root root 4555 Jun 9 16:30 kubesphere-installer.yaml
  13. [root@master ~]# kk certs check-expiration
  14. _ __ _ _ __
  15. | | / / | | | | / /
  16. | |/ / _ _| |__ ___| |/ / ___ _ _
  17. | \| | | | '_ \ / _ \ \ / _ \ | | |
  18. | |\ \ |_| | |_) | __/ |\ \ __/ |_| |
  19. \_| \_/\__,_|_.__/ \___\_| \_/\___|\__, |
  20. __/ |
  21. |___/
  22. 14:03:57 CST [GreetingsModule] Greetings
  23. 14:03:58 CST message: [master]
  24. Greetings, KubeKey!
  25. 14:03:58 CST success: [master]
  26. 14:03:58 CST [CheckCertsModule] Check cluster certs
  27. 14:04:00 CST success: [master]
  28. 14:04:00 CST [PrintClusterCertsModule] Display cluster certs form
  29. CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY NODE
  30. apiserver.crt Jun 06, 2023 03:42 UTC 298d ca master
  31. apiserver-kubelet-client.crt Jun 06, 2023 03:42 UTC 298d ca master
  32. front-proxy-client.crt Jun 06, 2023 03:42 UTC 298d front-proxy-ca master
  33. admin.conf Jun 06, 2023 03:42 UTC 298d master
  34. controller-manager.conf Jun 06, 2023 03:42 UTC 298d master
  35. scheduler.conf Jun 06, 2023 03:42 UTC 298d master
  36. CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME NODE
  37. ca.crt Jun 03, 2032 03:42 UTC 9y master
  38. front-proxy-ca.crt Jun 03, 2032 03:42 UTC 9y master
  39. 14:04:00 CST success: [LocalHost]
  40. 14:04:00 CST Pipeline[CheckCertsPipeline] execute successful

更新证书

  1. [root@master ~]# kk certs renew
  2. _ __ _ _ __
  3. | | / / | | | | / /
  4. | |/ / _ _| |__ ___| |/ / ___ _ _
  5. | \| | | | '_ \ / _ \ \ / _ \ | | |
  6. | |\ \ |_| | |_) | __/ |\ \ __/ |_| |
  7. \_| \_/\__,_|_.__/ \___\_| \_/\___|\__, |
  8. __/ |
  9. |___/
  10. 14:04:11 CST [GreetingsModule] Greetings
  11. 14:04:11 CST message: [master]
  12. Greetings, KubeKey!
  13. 14:04:11 CST success: [master]
  14. 14:04:11 CST [RenewCertsModule] Renew control-plane certs
  15. 14:04:12 CST stdout: [master]
  16. v1.21.5
  17. 14:04:17 CST success: [master]
  18. 14:04:17 CST [RenewCertsModule] Copy admin.conf to ~/.kube/config
  19. 14:04:21 CST success: [master]
  20. 14:04:21 CST [RenewCertsModule] Fetch kube config file from control-plane
  21. 14:04:22 CST success: [master]
  22. 14:04:22 CST [RenewCertsModule] Synchronize kube config to worker
  23. 14:04:22 CST skipped: [master]
  24. 14:04:22 CST [CheckCertsModule] Check cluster certs
  25. 14:04:25 CST success: [master]
  26. 14:04:25 CST [PrintClusterCertsModule] Display cluster certs form
  27. CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY NODE
  28. apiserver.crt Aug 11, 2023 06:04 UTC 364d ca master
  29. apiserver-kubelet-client.crt Aug 11, 2023 06:04 UTC 364d ca master
  30. front-proxy-client.crt Aug 11, 2023 06:04 UTC 364d front-proxy-ca master
  31. admin.conf Aug 11, 2023 06:04 UTC 364d master
  32. controller-manager.conf Aug 11, 2023 06:04 UTC 364d master
  33. scheduler.conf Aug 11, 2023 06:04 UTC 364d master
  34. CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME NODE
  35. ca.crt Jun 03, 2032 03:42 UTC 9y master
  36. front-proxy-ca.crt Jun 03, 2032 03:42 UTC 9y master
  37. 14:04:25 CST success: [LocalHost]
  38. 14:04:25 CST Pipeline[RenewCertsPipeline] execute successful
  39. [root@master ~]#

自动更换证书

  1. [root@master ~]# find / admin.conf |grep admin.conf
  2. /etc/kubernetes/admin.conf
  3. /root/kubekey/master/admin.conf
  4. /tmp/kubekey/admin.conf
  5. find: admin.conf’: No such file or directory
  6. [root@master ~]#
  7. [root@master ~]# ls -l /etc/kubernetes/admin.conf
  8. -rw-------. 1 kube root 5611 Aug 11 14:04 /etc/kubernetes/admin.conf
  9. [root@master ~]# ls -l /root/kubekey/master/admin.conf
  10. -rw-r--r-- 1 root root 5611 Aug 11 14:04 /root/kubekey/master/admin.conf
  11. [root@master ~]# ls -l /root/kubekey/master/admin.conf
  12. -rw-r--r-- 1 root root 5611 Aug 11 14:04 /root/kubekey/master/admin.conf
  13. [root@master ~]# ls -l /root/.kube/config
  14. -rw-------. 1 root root 5611 Aug 11 14:04 /root/.kube/config
  15. [root@master ~]#