0%

客户案例

此文章记录客户遇到的问题以及解决方案

Kubernetes证书过期

集群描述:3master、10+node、Kubernetes v1.14、二进制搭建

客户描述:证书过期,在更新后,Pod处于不可创建状态

Q:不可创建状态具体是什么状态。

A:创建失败,Pod ERR为cni failed to set up pod.

远程过去后,发现客户CNI Plugin为Calico 3.3,是使用YAML创建的,查看calico报错Failed to start error=failed to build Calico client: context deadline exceeded,根据客户描述更新证书后就变成这样了,猜测是因为calico访问etcd的证书未替换成功。

查看YAML文件calico使用挂载Secret方式将证书挂载到Pod中,我们只需要重建Secret后重建Deployment此问题便解决了。

calico.yaml 一小段

# The following contains k8s Secrets for use with a TLS enabled etcd cluster.
# For information on populating Secrets, see http://kubernetes.io/docs/user-guide/secrets/
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: calico-etcd-secrets
namespace: kube-system
data:
# Populate the following files with etcd TLS configuration if desired, but leave blank if
# not using TLS for etcd.
# This self-hosted install expects three files with the following names. The values
# should be base64 encoded strings of the entire contents of each file.
etcd-key: "xxx"
etcd-cert: "xxx"
etcd-ca: "xxx"

然而在实际解决过程中,并没有这么顺利,客户说已经在图形化(kubeboard)中替换了key、cert、ca证书,相当于kubectl edit secrets xxxx ,edit编辑的对象会立即发生更改,但是Deployment引用的Secrets并不会立即更改,必须重建Deployment。Deployment和原来的Secrets是写在一个文件(calico.yaml)的,当我们使用kubectl delete -f calico.yaml删除calico时,将secret也删除了,当kubectl delete -f calico.yaml时,Secret保存的还是原来的证书文件。