使用Terraform能够在容器服务Kubernetes版中创建K8s集群并导入EDAS,然后在K8s集群中部署应用。您可以参见文本查看可用的接口信息和配置示例。
接口说明
Data Sources
Resources
配置示例
下文列出了在EDAS的K8s集群中部署应用的操作示例。请根据您的实际情况修改配置参数。
- 在容器服务Kubernetes版中创建托管版K8s集群。
说明 Terraform支持在容器服务Kubernetes版中创建各种类型集群,此处仅以托管版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"
}
- 将托管版K8s集群导入到EDAS中。
resource "alicloud_edas_k8s_cluster" "default" {
cs_cluster_id = "xxxx-xxx-xxx"
}
- 在K8s集群中创建并部署应用。
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"]
}