当前位置:网站首页>Kubernetes 证书可用年限修改
Kubernetes 证书可用年限修改
2022-07-31 05:09:00 【hunheidaode】
证书可用年限修改
[[email protected] pki]# openssl x509 -in apiserver.crt -text -noout
先下载kubeadm的源码,针对apiserver一年年限证书分发的函数进行修改,由1年改为10年。(需要go语言的环境)
1.go语言环境
[[email protected] data]# tar -zxvf go1.16.5.linux-amd64.tar.gz -C /usr/local
[[email protected] data]# vim /etc/profile
export PATH=$PATH:/usr/local/go/bin
[[email protected] data]# source /etc/profile
[[email protected] data]# go version
- 1
- 2
- 3
- 4
- 5

2.下载kubernetes源码
[[email protected] data]# git clone https://github.com/kubernetes/kubernetes.git
[[email protected] data]# cd kubernetes
[[email protected] kubernetes]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"15", GitVersion:"v1.21.2",
[[email protected] kubernetes]# git checkout -b remotes/origin/release-1.21.2 v1.21.2
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
3.修改Kubeadm源码包更新证书策略
[[email protected] kubernetes]# vim staging/src/k8s.io/client-go/util/cert/cert.go
# kubeadm 1.14 版本之前
vi cmd/kubeadm/app/constants/constants.go
# kubeadm 1.21.2 至今
// NewSignedCert {
const duration365d = time.Hour * 24 * 365 * 100
NotAfter: time.Now().Add(duration365d).UTC(),
}
[[email protected] kubernetes]# make WHAT=cmd/kubeadm GOFLAGS=-v
[[email protected] kubernetes]# cp /usr/bin/kubeadm /usr/bin/kubeadm.old
[[email protected] kubernetes]# cp _output/bin/kubeadm /usr/bin/kubeadm
[[email protected] kubernetes]# chmod a+x /usr/bin/kubeadm
[[email protected] kubernetes]# cd /etc/kubernetes/
[[email protected] kubernetes]# cp -r pki /pki.old
新证书生成
[[email protected] ~]# kubeadm certs renew all --config=/root/kubeadm_init/kubeadm-config.yaml
--config是当初安装k8s集群的yaml文件
[[email protected] ~]# cd /etc/kubernetes/pki
查看证书年限
[[email protected] pki]# openssl x509 -in apiserver.crt -text -noout
查看kubeadm-config.yaml位置
[[email protected] pki]# cd /etc/kubernetes/pki/
openssl x509 -in apiserver.crt -text -noout
k8sv1.19.10版本:
需要加alpha命令才行
kubeadm alpha certs renew all --config=/root/kubeadm_init/kubeadm-config.yaml
查看全部证书过期时间也需要加alpha
kubeadm alpha certs check-expiration
边栏推荐
猜你喜欢
随机推荐
Shell重油常压塔模拟仿真与控制
Heavyweight | The Open Atomic School Source Line activity was officially launched
[Detailed explanation of ORACLE Explain]
a different object with the same identifier value was already associated with the session
信息系统项目管理师核心考点(五十五)配置管理员(CMO)的工作
matlab simulink欠驱动水面船舶航迹自抗扰控制研究
The MySQL database installed configuration nanny level tutorial for 8.0.29 (for example) have hands
一文了解大厂的DDD领域驱动设计
Information System Project Manager Core Test Site (55) Configuration Manager (CMO) Work
Puzzle Game Level Design: Reverse Method--Explaining Puzzle Game Level Design
SQL行列转换
TOGAF之架构标准规范(一)
DVWA之SQL注入
质量小议12 -- 以测代评
有了MVC,为什么还要DDD?
Unity手机游戏性能优化系列:针对CPU端的性能调优
为什么要用Flink,怎么入门使用Flink?
Three oj questions on leetcode
ERROR 1819 (HY000) Your password does not satisfy the current policy requirements
Sun Wenlong, Secretary General of the Open Atom Open Source Foundation |



![[C language] Detailed explanation of operators](/img/fa/dce3da39f19b51c6d1b682128da36b.png)




