Alibaba Cloud Managed Kubernetes Terraform

时间:2018-12-27 12:55:55

标签: kubernetes terraform alibaba-cloud

I want to create Kubernetes cluster with Terraform,

Regarding the doc page here: 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
} 

Where do I insert vswitch id? and how to set the region id?

2 个答案:

答案 0 :(得分:2)

您可以在./dist定义中插入vswitch ID:

moduleA

对于基于thisdocs的区域(如果要覆盖默认值),您需要执行以下操作:

main

答案 1 :(得分:2)

要设置区域:

在Terraform本身中配置Alicloud提供程序时,您可以设置区域:

provider "alicloud" {
  access_key = "${var.access_key}"
  secret_key = "${var.secret_key}"
  region     = "${var.region}"
}

例如,让我考虑将北京作为区域:

provider "alicloud" {
      access_key = "accesskey"
      secret_key = "secretkey"
      region     = "cn-beijing"
    }

设置虚拟交换机ID:

在定义resource部分时,我们可以插入所需的vswitchs

resource "alicloud_instance"{
  # ...
  instance_name = "in-the-vpc"
  vswitch_id = "${data.alicloud_vswitches.vswitches_ds.vswitches.0.id}"
  # ...
}

例如,让我考虑将 vsw-25naue4gz 作为vswitch ID:

resource "alicloud_instance"{
      # ...
      vswitch_id = "vsw-25naue4gz"
      # ...
    }