gpt4 book ai didi

kubernetes - Kubeadm无法在升级时签署证书

转载 作者:行者123 更新时间:2023-12-02 11:53:39 71 4
gpt4 key购买 nike

在使用kubespray将Kubernetes从1.14升级到1.15的过程中,我的团队在“Upgrade first master”步骤中遇到了以下消息的阻塞问题:

[upgrade/apply] FATAL: couldn''t upgrade control plane.
kubeadm has tried to recover everything into the earlier state.
Errors faced: [failed to renew certificates for component "kube-apiserver":
failed to renew certificate apiserver-kubelet-client:
unable to sign certificate:
must specify at least one ExtKeyUsage,
rename /etc/kubernetes/tmp/kubeadm
-backup-manifests-2019-09-19-09-06-27/kube-apiserver.yaml /etc/kubernetes/manifests/kube-apiserver.yaml: no such file or directory]'

尝试隔离任务并手动运行kubeadm命令行会导致相同的错误消息:
#/usr/local/bin/kubeadm upgrade apply -y v1.15.3 --config=/etc/kubernetes/kubeadm-config.yaml --ignore-preflight-errors=all --allow-experimental-upgrades --allow-release-candidate-upgrades --etcd-upgrade=false -v 6 

甚至尝试手动更新证书:
/etc/kubernetes/pki# kubeadm alpha certs renew apiserver-kubelet-client -v 9
I0919 14:42:11.515503 18597 initconfiguration.go:105] detected and using CRI socket: /var/run/dockershim.sock
I0919 14:42:11.515897 18597 interface.go:384] Looking for default routes with IPv4 addresses
I0919 14:42:11.515916 18597 interface.go:389] Default route transits interface “eth0”
I0919 14:42:11.516284 18597 interface.go:196] Interface eth0 is up
(...)
I0919 14:42:11.516835 18597 feature_gate.go:216] feature gates: &{map[]}
failed to renew certificate apiserver-kubelet-client: unable to sign certificate: must specify at least one ExtKeyUsage

最终找到了解决方案并将其发布在下面。

最佳答案

问题出在kubeadm,它在必须更新旧证书时使用旧证书。但是,如果这些初始证书太旧或是手动生成的,则它们可能不包含某些必填字段。

在错误消息中,ExtKeyUsage指的是X509v3 Extended Key Usage字段。

您可以通过查看证书来进行检查:涉及2个证书:apiserver-kubelet-client.crtfront-proxy-client.crt
它们位于/etc/kubernetes/pki的主主机上。

你可以用
# openssl x509 -in apiserver-kubelet-client.crt -text -noout
如果它们不包含以下内容(接近结尾),则kubeadm将完全无法更新证书

(...)
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Client Authentication

TL; DR;

解决方案只是按照以下步骤创建全新的证书
######### Backup your certificates (just in case)
master01:/etc/kubernetes/pki# cp -a /etc/kubernetes/pki /root/backup_cert/
######### Delete incomplete certificates
master01:/etc/kubernetes/pki# rm apiserver-kubelet-client.*
master01:/etc/kubernetes/pki# rm front-proxy-client.*
######### Then recreate them
master01:/etc/kubernetes/pki# kubeadm init phase certs apiserver-kubelet-client
master01:/etc/kubernetes/pki# kubeadm init phase certs front-proxy-client

现在,您可以重新启动升级过程,这应该没问题。 (注意:如果您的集群处于第一个主节点处于SchedulingDisabled状态的状态,则不要忘记取消托管主机,因为kubespray剧本无法解决该问题)

关于kubernetes - Kubeadm无法在升级时签署证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58026882/

71 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com