Skip to content

Commit 1b1ee27

Browse files
committed
Create ASK cluster
1 parent cb41495 commit 1b1ee27

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Providers
3+
4+
| Name | Version |
5+
|------|---------|
6+
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | n/a |
7+
8+
## Modules
9+
10+
No modules.
11+
12+
## Resources
13+
14+
| Name | Type |
15+
|------|------|
16+
| [alicloud_cs_serverless_kubernetes.serverless](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/cs_serverless_kubernetes) | resource |
17+
| [alicloud_security_group.group](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/security_group) | resource |
18+
| [alicloud_vpc.vpc](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vpc) | resource |
19+
| [alicloud_vswitch.vsw](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vswitch) | resource |
20+
| [alicloud_eci_zones.default](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/eci_zones) | data source |
21+
22+
## Inputs
23+
24+
| Name | Description | Type | Default | Required |
25+
|------|-------------|------|---------|:--------:|
26+
| <a name="input_k8s_name_prefix"></a> [k8s\_name\_prefix](#input\_k8s\_name\_prefix) | The name prefix used to create ASK cluster. | `string` | `"ask-example"` | no |
27+
| <a name="input_k8s_version"></a> [k8s\_version](#input\_k8s\_version) | allowd values are [1.31.1-aliyun.1、1.30.1-aliyun.1、1.28.9-aliyun.1、1.26.15-aliyun.1、1.24.6-aliyun.1、1.22.15-aliyun.1、1.20.11-aliyun.1] | `string` | `"1.31.1-aliyun.1"` | no |
28+
<!-- END_TF_DOCS -->
29+
## Documentation
30+
<!-- docs-link -->
31+
32+
The template is based on Aliyun document: [Create ASK cluster](http://help.aliyun.com/document_detail/2391966.htm)
33+
34+
<!-- docs-link -->
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
provider "alicloud" {
2+
}
3+
4+
variable "k8s_name_prefix" {
5+
description = "The name prefix used to create ASK cluster."
6+
default = "ask-example"
7+
}
8+
9+
variable "k8s_version" {
10+
description = "allowd values are [1.31.1-aliyun.1、1.30.1-aliyun.1、1.28.9-aliyun.1、1.26.15-aliyun.1、1.24.6-aliyun.1、1.22.15-aliyun.1、1.20.11-aliyun.1]"
11+
default = "1.31.1-aliyun.1"
12+
}
13+
14+
# 默认资源名称。
15+
locals {
16+
k8s_name_ask = substr(join("-", [var.k8s_name_prefix, "ask"]), 0, 63)
17+
new_vpc_name = "tf-vpc-172-16"
18+
new_vsw_name = "tf-vswitch-172-16-0"
19+
new_sg_name = "tf-sg-172-16"
20+
}
21+
22+
data "alicloud_eci_zones" "default" {}
23+
24+
resource "alicloud_vpc" "vpc" {
25+
vpc_name = local.new_vpc_name
26+
cidr_block = "172.16.0.0/12"
27+
}
28+
29+
resource "alicloud_vswitch" "vsw" {
30+
vswitch_name = local.new_vsw_name
31+
vpc_id = alicloud_vpc.vpc.id
32+
cidr_block = cidrsubnet(alicloud_vpc.vpc.cidr_block, 8, 8)
33+
zone_id = data.alicloud_eci_zones.default.zones.0.zone_ids.1
34+
}
35+
36+
resource "alicloud_security_group" "group" {
37+
name = local.new_sg_name
38+
vpc_id = alicloud_vpc.vpc.id
39+
}
40+
41+
resource "alicloud_cs_serverless_kubernetes" "serverless" {
42+
name = local.k8s_name_ask
43+
version = var.k8s_version # 替换为您所需创建的集群版本。
44+
cluster_spec = "ack.pro.small"
45+
vpc_id = alicloud_vpc.vpc.id
46+
vswitch_ids = split(",", join(",", alicloud_vswitch.vsw.*.id))
47+
new_nat_gateway = true
48+
endpoint_public_access_enabled = true
49+
deletion_protection = false
50+
security_group_id = alicloud_security_group.group.id
51+
# 通过RRSA配置ServiceAccount。
52+
enable_rrsa = true
53+
time_zone = "Asia/Shanghai"
54+
service_cidr = "10.13.0.0/16"
55+
service_discovery_types = ["CoreDNS"]
56+
57+
# tags
58+
tags = {
59+
"cluster" = "ack-serverless"
60+
}
61+
# addons
62+
addons {
63+
name = "nginx-ingress-controller"
64+
# 使用Internet。
65+
config = "{\"IngressSlbNetworkType\":\"internet\",\"IngressSlbSpec\":\"slb.s2.small\"}"
66+
# 如果使用Intranet, 配置如下。
67+
# config = "{\"IngressSlbNetworkType\":\"intranet\",\"IngressSlbSpec\":\"slb.s2.small\"}"
68+
}
69+
addons {
70+
name = "metrics-server"
71+
}
72+
addons {
73+
name = "knative"
74+
}
75+
addons {
76+
name = "managed-arms-prometheus"
77+
}
78+
addons {
79+
name = "logtail-ds"
80+
# 指定具体的sls_project_name
81+
# config = "{\"sls_project_name\":\"<YOUR-SLS-PROJECT-NAME>}\"}"
82+
}
83+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
terraform {
2+
required_providers {
3+
alicloud = {
4+
source = "aliyun/alicloud"
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)