【发布时间】:2019-05-22 16:16:05
【问题描述】:
场景:
我有一种情况,我无权使用任何市场上可用的 Kubernetes 升级工具,例如 KOps 或 KubeSpray。因此,我不得不使用 Terraform 来配置实例,并且 kubernetes 是作为使用配置器进行引导的一部分安装的。现在,吸引人的部分是,我的 K8s 集群在 1.11.6 版本上运行,我想将它升级到 1.12.3。
我做了什么:
在 terraform 脚本中,我将节点数增加了一倍并更新了 K8s 版本。然后进行 Terraform 部署。我成功升级了新节点(加倍计数后形成的节点)。我终止了在 K8s 上运行旧版本的实例。现在我只有运行新版本 K8s 的新节点。然后运行terraform refresh 以便将状态文件与AWS 上远程存在的真实资源同步。
问题
为了验证状态文件和远程是否同步,我运行了terraform plan,它显示了一些要创建的资源。基本上,该计划表明它将再次创建新节点。无法理解为什么会这样!!
请有人能澄清一下这里出了什么问题吗?提前致谢。
更新:
我的K8s版本图
type = "map"
default = {
kubernetes = "1.11.5"
etcd = "3.3.1"
dockerCE = "18.06.1.ce-3.el7"
cfssl = "1.2"
kube-dns = "1.14.10"
core-dns = "1.2.0"
helm = "2.9.1"
calico-node = "3.0.6"
calico-cni = "2.0.5"
calico-kube-controller = "2.0.4"
nginx-ingress-controller = "0.19.0"
}
我的节点数(对于下面的 master,但对于所有节点,如 etcd、ca、worker 等都是一样的)
variable "MASTER_COUNT" {
type = "map"
default = {
#bastion
dev = "1"
prod = "3"
}
Terraform 计划仍显示以下要创建的资源。基本上它会尝试使用旧版本的 K8s 重新创建节点,这不应该是因为我已经运行了 terraform refresh,它应该同步我的本地和远程。
Terraform will perform the following actions:
+ module.master.aws_instance.ec2-master[0]
id: <computed>
ami: "ami-######"
arn: <computed>
associate_public_ip_address: <computed>
availability_zone: <computed>
cpu_core_count: <computed>
cpu_threads_per_core: <computed>
ebs_block_device.#: "2"
+ module.master.aws_instance.ec2-master[1]
id: <computed>
ami: "ami-#######"
arn: <computed>
associate_public_ip_address: <computed>
availability_zone: <computed>
cpu_core_count: <computed>
cpu_threads_per_core: <computed>
ebs_block_device.#: "2"
+ module.master.aws_instance.ec2-master[2]
id: <computed>
ami: "ami-######"
arn: <computed>
associate_public_ip_address: <computed>
availability_zone: <computed>
cpu_core_count: <computed>
cpu_threads_per_core: <computed>
ebs_block_device.#: "2"
- module.master.aws_instance.ec2-master[3]
- module.master.aws_instance.ec2-master[4]
- module.master.aws_instance.ec2-master[5]
# some other re-creations like Auto scaling group, Load balancer changes etc
Plan: 10 to add, 1 to change, 16 to destroy.
【问题讨论】:
-
您应该显示您的(最小)Terraform 代码和计划输出,以便人们能够了解您现在所处的状态。
-
@ydaetskcoR 按要求添加了 Terraform 代码。
标签: amazon-web-services kubernetes terraform