美文网首页
k8sv1.15证书过期处理

k8sv1.15证书过期处理

作者: Firetheworld | 来源:发表于2020-09-01 09:57 被阅读0次

证书的有效期为一年,每年进行k8s集群升级版本,以保证集群的安全性。当证书过期,也可以自行续期。

官方参考链接: “https://kubernetes.io/zh/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/

单节点操作如下:

环境: Centos7
k8s版本: k8sV1.15.3

单节点证书升级

一 查看证书的有效期:

kubeadm alpha certs check-expiration

[root@k8s-10 pki]# kubeadm  alpha certs check-expiration
CERTIFICATE                EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
admin.conf                 Oct 11, 2020 15:58 UTC   66d             no      
apiserver                  Oct 11, 2020 15:58 UTC   66d             no      
apiserver-etcd-client      Oct 11, 2020 15:58 UTC   66d             no      
apiserver-kubelet-client   Oct 11, 2020 15:58 UTC   66d             no      
controller-manager.conf    Oct 11, 2020 15:58 UTC   66d             no      
etcd-healthcheck-client    Oct 11, 2020 15:58 UTC   66d             no      
etcd-peer                  Oct 11, 2020 15:58 UTC   66d             no      
etcd-server                Oct 11, 2020 15:58 UTC   66d             no      
front-proxy-client         Oct 11, 2020 15:58 UTC   66d             no      
scheduler.conf             Oct 11, 2020 15:58 UTC   66d             no      
[root@k8s-10 pki]# kubectl cluster-info

该命令显示 /etc/kubernetes/pki 文件夹中的客户端证书以及 kubeadm 使用的 KUBECONFIG 文件中嵌入的客户端证书的到期时间/剩余时间。
说明: 上面的列表中没有包含kubelet.conf因为 kubeadm 将 kubelet 配置为自动更新证书

备份好原始证书:

cp -r /etc/kubernetes{,_bak}

二 更新/etc/kubernetes/pki 下的所有证书:

kubeadm alpha certs renew all

[root@k8s-10 pki]# kubeadm alpha certs renew all
certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed
certificate for serving the Kubernetes API renewed
certificate the apiserver uses to access etcd renewed
certificate for the API server to connect to kubelet renewed
certificate embedded in the kubeconfig file for the controller manager to use renewed
certificate for liveness probes to healtcheck etcd renewed
certificate for etcd nodes to communicate with each other renewed
certificate for serving etcd renewed
certificate for the front proxy client renewed
certificate embedded in the kubeconfig file for the scheduler manager to use renewed

警告: 如果您运行了一个 HA 集群,这个命令需要在所有控制面板节点上执行。

多主节点的方式:

备份:每个主节点进行备份,每个主节点进行证书创建,清理前次的kubectl权限信息,并重新配置kubectl权限信息:

cp -r /etc/kubernetes{,_bak}
kubeadm alpha certs renew all

rm -rf $HOME/.kube
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

kubeadmin参数如下:

[root@k8s-10 ~]# kubeadm  alpha certs renew --help
This command is not meant to be run on its own. See list of available subcommands.

Usage:
  kubeadm alpha certs renew [flags]
  kubeadm alpha certs renew [command]

Available Commands:
  admin.conf               Renew the certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself
  all                      Renew all available certificates
  apiserver                Renew the certificate for serving the Kubernetes API
  apiserver-etcd-client    Renew the certificate the apiserver uses to access etcd
  apiserver-kubelet-client Renew the certificate for the API server to connect to kubelet
  controller-manager.conf  Renew the certificate embedded in the kubeconfig file for the controller manager to use
  etcd-healthcheck-client  Renew the certificate for liveness probes to healtcheck etcd
  etcd-peer                Renew the certificate for etcd nodes to communicate with each other
  etcd-server              Renew the certificate for serving etcd
  front-proxy-client       Renew the certificate for the front proxy client
  scheduler.conf           Renew the certificate embedded in the kubeconfig file for the scheduler manager to use

如果只需要更新admin.conf证书,命令如下:

kubeadm alpha certs renew admin.conf

再次查看结果:

[root@k8s-10 pki]# kubeadm alpha certs check-expiration
CERTIFICATE                EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
admin.conf                 Aug 06, 2021 07:30 UTC   364d            no      
apiserver                  Aug 06, 2021 07:30 UTC   364d            no      
apiserver-etcd-client      Aug 06, 2021 07:30 UTC   364d            no      
apiserver-kubelet-client   Aug 06, 2021 07:30 UTC   364d            no      
controller-manager.conf    Aug 06, 2021 07:30 UTC   364d            no      
etcd-healthcheck-client    Aug 06, 2021 07:30 UTC   364d            no      
etcd-peer                  Aug 06, 2021 07:30 UTC   364d            no      
etcd-server                Aug 06, 2021 07:30 UTC   364d            no      
front-proxy-client         Aug 06, 2021 07:30 UTC   364d            no      
scheduler.conf             Aug 06, 2021 07:30 UTC   364d            no  

相关文章

  • k8sv1.15证书过期处理

    证书的有效期为一年,每年进行k8s集群升级版本,以保证集群的安全性。当证书过期,也可以自行续期。 官方参考链接: ...

  • IOS线上应用证书过期处理

    1、生产证书过期处理 2、推送证书过期处理 参考链接:http://blog.sina.com.cn/s/blog...

  • 证书过期处理

    首先讲一下证书过期对项目的影响 1 不影响线上的产品 2 对打新的版本会有影响 接下来 处理证书方法 第一步 点...

  • 苹果开发证书过期的解决办法

    一、显示已经过期的证书: 二、解决办法: 1.证书过期的处理: 2.下载证书的地址: https://develo...

  • kubernetes证书过期处理

    目录:1、证书过期时间查询2、证书过期处理2.1、客户端kubelet证书自动续期2.2、重新生成默认一年时长证书...

  • iOS 证书过期处理

    又到了每年一次的证书过期的日子了,每到这个时候就会想苹果为啥不能两年,三年或者更多年在过期一次呢?呃,貌似想太多了...

  • 推送证书过期处理

    1.删除钥匙串上的推送证书2.进入apple开发账号revoke掉老的push certificate,生成新的,...

  • kubeadm 证书过期处理

    依照https://github.com/strongit/kubeadm-ha/[https://github....

  • 极光证书过期处理

    最近收到极光推送发来的邮件 快过期了,只能重新配置。 1,登录苹果开发者网站https://developer.a...

  • iOS推送证书过期处理

    推送证书(生产Apple Push Services和开发APNs Development iOS)的有效期都是一...

网友评论

      本文标题:k8sv1.15证书过期处理

      本文链接:https://www.haomeiwen.com/subject/zvzzrktx.html