kubernetes - 阿里云托管 Kubernetes Terraform

标签 kubernetes terraform alibaba-cloud

我想使用 Terraform 创建 Kubernetes 集群,

关于此处的文档页面:https://www.terraform.io/docs/providers/alicloud/r/cs_managed_kubernetes.html

variable "name" {
default = "my-first-k8s"
}
data "alicloud_zones" main {
  available_resource_creation = "VSwitch"
}

data "alicloud_instance_types" "default" {
    availability_zone = "${data.alicloud_zones.main.zones.0.id}"
    cpu_core_count = 1
    memory_size = 2
} 

在哪里插入 vswitch id?以及如何设置区域id?

最佳答案

您可以在资源定义中插入vswitch ID:

resource "alicloud_cs_managed_kubernetes" "k8s" {
  name = "${var.name}"
  availability_zone = "${data.alicloud_zones.main.zones.0.id}"
  new_nat_gateway = true
  worker_instance_types = ["${data.alicloud_instance_types.default.instance_types.0.id}"]
  worker_numbers = [2]
  password = "Test12345"
  pod_cidr = "172.20.0.0/16"
  service_cidr = "172.21.0.0/20"
  install_cloud_monitor = true
  worker_disk_category  = "cloud_efficiency"
  vswitch_ids = ["your-alibaba-vswitch-id"]
}

对于基于 this 的区域(如果您想覆盖默认值)和 docs ,你需要做这样的事情:

data "alicloud_zones" main {
  available_resource_creation = "VSwitch"

  zones = [
     {
       id = "..."
       local_name = "..."
       ...
     },
     {
       id = "..."
       local_name = "..."
       ...
     },
     ...
  ]
}

关于kubernetes - 阿里云托管 Kubernetes Terraform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53945471/

相关文章:

kubernetes - cloudflared 出现 "failed to sufficiently increase receive buffer size"错误

kubernetes - 没有 Google 云存储的 Kubeflow

Terraform如何获取aws_lb的IP地址

python - 如何使用阿里巴巴ODPS python SDK中的Schema.from_lists方法创建schema?

alibaba-cloud - 使用阿里巴巴的OSS图像处理加入图像

Kubernetes RS Controller - 查找服务帐户 k8s-tiller/k8s-tiller : serviceaccount "k8s-tiller" not found 时出错

kubernetes - kubectl : Unable to connect to the server : dial tcp 192. 168.214.136:6443:连接:主机没有路由

azure - 动态部署私有(private)端点

azure - 无法使用 RDP(远程桌面)连接到虚拟机

kubernetes pod 被禁止 : User "user1" cannot list pods in the namespace "stage"