我通过以下方式使用 kops 和 terraform 在 AWS 上部署 k8s 集群:
kops toolbox template --template my_template.yaml --values values.yaml | kops replace --force -f -
kops update cluster performance.my_domain.com --target=terraform --out=.
terraform apply
集群已创建并按预期运行。由于这是我的测试集群,我想从 AWS 中删除它并在每次需要时重新创建,但是我需要它使用相同的证书,因此我不需要在 Jenkins 等外部工具中更新我的凭证。< /p>
但是当我这样做时:
集群无法正常启动 - 我可以看到 kube-apiserver 无法在主节点上启动,因为它无法连接到 etcd 服务(端口 4001)。 etcd 的日志显示如下。是选举问题吗?如何解决这个问题?
I0127 12:25:31.518158 2477 controller.go:173] starting controller iteration
I0127 12:25:31.518203 2477 controller.go:198] we are not leader
I0127 12:25:39.933312 2477 volumes.go:86] AWS API Request: ec2/DescribeVolumes
I0127 12:25:40.029403 2477 volumes.go:86] AWS API Request: ec2/DescribeInstances
I0127 12:25:40.085829 2477 hosts.go:84] hosts update: primary=map[], fallbacks=map[etcd-a-0.internal.performance.my_domain.com:[10.41.101.173 10.41.101.173] etcd-a-1.internal.performance.my_domain.com:[10.41.101.114 10.41.101.114] etcd-b-2.internal.performance.my_domain.com:[10.41.102.7 10.41.102.7]], final=map[10.41.101.114:[etcd-a-1.internal.performance.my_domain.com etcd-a-1.internal.performance.my_domain.com] 10.41.101.173:[etcd-a-0.internal.performance.my_domain.com etcd-a-0.internal.performance.my_domain.com] 10.41.102.7:[etcd-b-2.internal.performance.my_domain.com etcd-b-2.internal.performance.my_domain.com]]
I0127 12:25:40.085918 2477 hosts.go:181] skipping update of unchanged /etc/hosts
I0127 12:25:41.519402 2477 controller.go:173] starting controller iteration
I0127 12:25:41.519448 2477 controller.go:198] we are not leader
I0127 12:25:51.520663 2477 controller.go:173] starting controller iteration
I0127 12:25:51.520840 2477 controller.go:198] we are not leader
I0127 12:26:01.522046 2477 controller.go:173] starting controller iteration
I0127 12:26:01.522091 2477 controller.go:198] we are not leader