博客
关于我
Kubernetes 证书有效期更改
阅读量:634 次
发布时间:2019-03-14

本文共 4081 字,大约阅读时间需要 13 分钟。

Kubernetes相关证书详细介绍:

在更新证书之前先查看一下当前证书的过期时间

[root@k8s-master01 ~]# kubeadm alpha certs check-expirationCERTIFICATE                EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGEDadmin.conf                 Feb 20, 2022 05:57 UTC   363d            no      apiserver                  Feb 20, 2022 05:57 UTC   363d            no      apiserver-etcd-client      Feb 20, 2022 05:57 UTC   363d            no      apiserver-kubelet-client   Feb 20, 2022 05:57 UTC   363d            no      controller-manager.conf    Feb 20, 2022 05:57 UTC   363d            no      etcd-healthcheck-client    Feb 20, 2022 05:57 UTC   363d            no      etcd-peer                  Feb 20, 2022 05:57 UTC   363d            no      etcd-server                Feb 20, 2022 05:57 UTC   363d            no      front-proxy-client         Feb 20, 2022 05:57 UTC   363d            no      scheduler.conf             Feb 20, 2022 05:57 UTC   363d            no

Go环境部署:

[root@k8s-master01 ~]# wget https://dl.google.com/go/go1.15.6.linux-amd64.tar.gz[root@k8s-master01 ~]# tar -zxvf go1.15.6.linux-amd64.tar.gz -C /usr/local[root@k8s-master01 ~]# vim /etc/profile添加:    export PATH=$PATH:/usr/local/go/bin[root@k8s-master01 ~]# source /etc/profile

下载Kubernetes源码

[root@k8s-master01 ~]# cd /home && git clone https://github.com/kubernetes/kubernetes.git[root@k8s-master01 ~]# git clone -b 1.15.1 --depth=1 https://github.com/kubernetes/kubernetes.git	#  下载执行版本[root@k8s-master01 home]# git checkout -b remotes/origin/release-1.15.1 v1.15.1	# 切换当前Kubernetes 版本

修改 Kubeadm 源码包更新证书策略

[root@k8s-master01 home]# vim staging/src/k8s.io/client-go/util/cert/cert.go  # kubeadm 1.14 版本之前[root@k8s-master01 home]# vim cmd/kubeadm/app/util/pkiutil/pki_helpers.go # kubeadm 1.14 至今	const duration365d = time.Hour * 24 * 365	NotAfter:     time.Now().Add(duration365d).UTC(),[root@k8s-master01 home]# makeWHAT=cmd/kubeadm GOFLAGS=-v[root@k8s-master01 home]# cp _output/bin/kubeadm /root/kubeadm-new

更新 kubeadm

# 将 kubeadm 进行替换[root@k8s-master01 home]# cp /usr/bin/kubeadm /usr/bin/kubeadm.old[root@k8s-master01 home]# cp /root/kubeadm-new /usr/bin/kubeadm[root@k8s-master01 home]# chmod a+x /usr/bin/kubeadm

更新各节点证书至 Master 节点

[root@k8s-master01 home]# cp-r /etc/kubernetes/pki /etc/kubernetes/pki.old[root@k8s-master01 home]# cd /etc/kubernetes/pki[root@k8s-master01 pki]# kubeadm alpha certs renew all --config=/root/kubeadm-config.yaml[root@k8s-master01 pki]# openssl x509 -in apiserver.crt -text-noout | grep Not

HA集群其余 mater 节点证书更新

#!/bin/bashmasterNode="192.168.66.20 192.168.66.21"# for host in ${masterNode}; do#    scp /etc/kubernetes/pki/{ca.crt,ca.key,sa.key,sa.pub,front-proxy-ca.crt,front-proxy-ca.key}"${USER}"@$host:/etc/kubernetes/pki/#    scp /etc/kubernetes/pki/etcd/{ca.crt,ca.key} "root"@$host:/etc/kubernetes/pki/etcd#    scp /etc/kubernetes/admin.conf "root"@$host:/etc/kubernetes/#donefor host in${CONTROL_PLANE_IPS}; do    scp /etc/kubernetes/pki/{ca.crt,ca.key,sa.key,sa.pub,front-proxy-ca.crt,front-proxy-ca.key}"${USER}"@$host:/root/pki/    scp /etc/kubernetes/pki/etcd/{ca.crt,ca.key} "root"@$host:/root/etcd    scp /etc/kubernetes/admin.conf "root"@$host:/root/kubernetes/done

再次再看证书过期时间

[root@k8s-master01 ~]# kubeadm alpha certs check-expirationCERTIFICATE                EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGEDadmin.conf                 Feb 20, 2032 05:57 UTC   363d            no      apiserver                  Feb 20, 2032 05:57 UTC   363d            no      apiserver-etcd-client      Feb 20, 2032 05:57 UTC   363d            no      apiserver-kubelet-client   Feb 20, 2032 05:57 UTC   363d            no      controller-manager.conf    Feb 20, 2032 05:57 UTC   363d            no      etcd-healthcheck-client    Feb 20, 2032 05:57 UTC   363d            no      etcd-peer                  Feb 20, 2022 05:57 UTC   363d            no      etcd-server                Feb 20, 2022 05:57 UTC   363d            no      front-proxy-client         Feb 20, 2022 05:57 UTC   363d            no      scheduler.conf             Feb 20, 2032 05:57 UTC   363d            no

转载地址:http://txqoz.baihongyu.com/

你可能感兴趣的文章
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>
mysql 死锁(先delete 后insert)日志分析
查看>>
MySQL 死锁了,怎么办?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 添加列,修改列,删除列
查看>>
mysql 添加索引
查看>>
MySQL 添加索引,删除索引及其用法
查看>>
mysql 状态检查,备份,修复
查看>>