使用Terraform能夠在容器服務(wù)Kubernetes版中創(chuàng)建K8s集群并導(dǎo)入EDAS,然后在K8s集群中部署應(yīng)用。您可以參見(jiàn)文本查看可用的接口信息和配置示例。

接口說(shuō)明

Data Sources

Resources

配置示例

下文列出了在EDAS的K8s集群中部署應(yīng)用的操作示例。請(qǐng)根據(jù)您的實(shí)際情況修改配置參數(shù)。

  1. 在容器服務(wù)Kubernetes版中創(chuàng)建托管版K8s集群。
    說(shuō)明 Terraform支持在容器服務(wù)Kubernetes版中創(chuàng)建各種類(lèi)型集群,此處僅以托管版K8s集群為例。
    resource "alicloud_cs_managed_kubernetes" "default" {
      worker_instance_types = [data.alicloud_instance_types.default.instance_types.0.id]
      name = var.name
      worker_vswitch_ids = [alicloud_vswitch.default.id]
      worker_number = "1"
      password =                    "Test12345"
      pod_cidr =                   "172.20.0.0/16"
      service_cidr =               "172.21.0.0/20"
      worker_disk_size =            "50"
      worker_disk_category =         "cloud_ssd"
      worker_data_disk_size =       "20"
      worker_data_disk_category =   "cloud_ssd"
      worker_instance_charge_type = "PostPaid"
      slb_internet_enabled =        "true"
    }
  2. 將托管版K8s集群導(dǎo)入到EDAS中。
    resource "alicloud_edas_k8s_cluster" "default" {
      cs_cluster_id = "xxxx-xxx-xxx"
    }
  3. 在K8s集群中創(chuàng)建并部署應(yīng)用。
    resource "alicloud_edas_k8s_application" "default" {
      application_name = "shesheng-test-k8s"
      cluster_id = "45bc8232-3233-46be-ab20-6d4a9b506d5c"
      replicas = 1
      package_type = "Image"
      image_url = "cr.registry.cloud.ste2.com/test/gw-provider:1028"
      command = "/bin/sh"
      command_args = ["-c", "while true; do echo hello; sleep 1000;done"]
    }