in alibabacloudstack/resource_apsarastack_ack_cluster.go [40:617]
func resourceAlibabacloudStackCSKubernetes() *schema.Resource {
resource := &schema.Resource{
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(90 * time.Minute),
Update: schema.DefaultTimeout(60 * time.Minute),
Delete: schema.DefaultTimeout(60 * time.Minute),
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringLenBetween(1, 63),
},
"master_disk_size": {
Type: schema.TypeInt,
Optional: true,
Default: 40,
ValidateFunc: validation.IntBetween(40, 500),
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
"master_disk_category": {
Type: schema.TypeString,
Optional: true,
Default: DiskCloudSSD,
ValidateFunc: validation.StringInSlice([]string{
string(DiskCloudEfficiency), string(DiskCloudSSD), string(DiskCloudPPERF), string(DiskCloudSPERF)}, false),
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
"delete_protection": {
Type: schema.TypeBool,
Default: false,
Optional: true,
},
"num_of_nodes": {
Type: schema.TypeInt,
Required: true,
},
"worker_disk_size": {
Type: schema.TypeInt,
Optional: true,
Default: 40,
ValidateFunc: validation.IntBetween(20, 32768),
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
"worker_disk_category": {
Type: schema.TypeString,
Optional: true,
Default: DiskCloudSSD,
ValidateFunc: validation.StringInSlice([]string{
string(DiskCloudEfficiency), string(DiskCloudSSD), string(DiskCloudPPERF), string(DiskCloudSPERF)}, false),
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
// "worker_data_disk_size": {
// Type: schema.TypeInt,
// Optional: true,
// Default: 40,
// ValidateFunc: validation.IntBetween(20, 32768),
// DiffSuppressFunc: workerDataDiskSizeSuppressFunc,
// },
// "worker_data_disk_category": {
// Type: schema.TypeString,
// Optional: true,
// ValidateFunc: validation.StringInSlice([]string{
// string(DiskCloudEfficiency), string(DiskCloudSSD), string(DiskCloudPPERF), string(DiskCloudSPERF)}, false),
// DiffSuppressFunc: csForceUpdateSuppressFunc,
// },
"worker_data_disks": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"size": {
Type: schema.TypeInt,
Default: "flannel",
Optional: true,
},
"encrypted": {
Type: schema.TypeBool,
Optional: true,
},
"auto_snapshot_policy_id": {
Type: schema.TypeString,
Optional: true,
},
"performance_level": {
Type: schema.TypeString,
Optional: true,
},
"category": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
"master_storage_set_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"master_storage_set_partition_number": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.IntBetween(1, 2000),
},
"worker_storage_set_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"worker_storage_set_partition_number": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.IntBetween(1, 2000),
},
// "exclude_autoscaler_nodes": {
// Type: schema.TypeBool,
// Default: false,
// Optional: true,
// },
//"worker_data_disk": {
// Type: schema.TypeBool,
// Default: false,
// Optional: true,
//},
// global configurations
// Terway network
"pod_vswitch_ids": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^vsw-[a-z0-9]*$`), "should start with 'vsw-'."),
},
MaxItems: 10,
DiffSuppressFunc: csForceUpdateSuppressFunc,
ConflictsWith: []string{"pod_cidr"},
},
// Flannel network
"pod_cidr": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
"service_cidr": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
"node_cidr_mask": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
"new_nat_gateway": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"password": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
ConflictsWith: []string{"kms_encrypted_password"},
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
// "key_name": {
// Type: schema.TypeString,
// Optional: true,
// ConflictsWith: []string{"password", "kms_encrypted_password"},
// DiffSuppressFunc: csForceUpdateSuppressFunc,
// },
"kms_encrypted_password": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"password"},
},
"kms_encryption_context": {
Type: schema.TypeMap,
Optional: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return d.Get("kms_encrypted_password").(string) == ""
},
Elem: schema.TypeString,
},
// "user_ca": {
// Type: schema.TypeString,
// Optional: true,
// DiffSuppressFunc: csForceUpdateSuppressFunc,
// },
"enable_ssh": {
Type: schema.TypeBool,
Optional: true,
Default: false,
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
"node_port_range": {
Type: schema.TypeString,
Optional: true,
Default: PortRange,
},
"image_id": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: imageIdSuppressFunc,
},
// "install_cloud_monitor": {
// Type: schema.TypeBool,
// Optional: true,
// Default: true,
// DiffSuppressFunc: csForceUpdateSuppressFunc,
// },
"version": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"cluster_type": {
Type: schema.TypeString,
Optional: true,
Default: ClusterType,
},
"os_type": {
Type: schema.TypeString,
Optional: true,
Default: OsType,
},
"platform": {
Type: schema.TypeString,
Optional: true,
Default: Platform,
},
// cpu policy options of kubelet
"cpu_policy": {
Type: schema.TypeString,
Optional: true,
Default: "none",
ValidateFunc: validation.StringInSlice([]string{"none", "static"}, false),
},
"proxy_mode": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"iptables", "ipvs"}, false),
},
"addons": {
Type: schema.TypeList,
Optional: true,
MinItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Default: "flannel",
Optional: true,
},
"config": {
Type: schema.TypeString,
Optional: true,
},
//"disabled": {
// Type: schema.TypeBool,
// Optional: true,
// Default: false,
//},
},
},
},
"slb_internet_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
DiffSuppressFunc: csForceUpdateSuppressFunc,
},
// computed parameters
"kube_config": {
Type: schema.TypeString,
Optional: true,
},
"client_cert": {
Type: schema.TypeString,
Optional: true,
},
"client_key": {
Type: schema.TypeString,
Optional: true,
},
"cluster_ca_cert": {
Type: schema.TypeString,
Optional: true,
},
// "connections": {
// Type: schema.TypeList,
// Computed: true,
// Elem: &schema.Resource{
// Schema: map[string]*schema.Schema{
// "api_server_internet": {
// Type: schema.TypeString,
// Computed: true,
// },
// "api_server_intranet": {
// Type: schema.TypeString,
// Computed: true,
// },
// "master_public_ip": {
// Type: schema.TypeString,
// Computed: true,
// },
// "service_domain": {
// Type: schema.TypeString,
// Computed: true,
// },
// },
// },
// },
// "slb_id": {
// Type: schema.TypeString,
// Computed: true,
// Deprecated: "Field 'slb_id' has been deprecated from provider version 1.9.2. New field 'slb_internet' replaces it.",
// },
// "slb_internet": {
// Type: schema.TypeString,
// Computed: true,
// },
"slb_intranet": {
Type: schema.TypeString,
Computed: true,
},
"security_group_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"master_system_disk_performance_level": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"worker_system_disk_performance_level": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"is_enterprise_security_group": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"cloud_monitor_flags": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"nat_gateway_id": {
Type: schema.TypeString,
Computed: true,
},
"vpc_id": {
Type: schema.TypeString,
Required: true,
},
"runtime": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Optional: true,
Default: RuntimeName,
},
"version": {
Type: schema.TypeString,
Optional: true,
Default: RuntimeVersion,
},
},
},
},
"master_nodes": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"private_ip": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"worker_nodes": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"private_ip": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
// remove parameters below
// mix vswitch_ids between master and worker is not a good guidance to create cluster
// "worker_instance_type": {
// Type: schema.TypeString,
// Optional: true,
// },
"master_instance_types": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Required: true,
},
"master_vswitch_ids": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Required: true,
},
"worker_instance_types": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
ConflictsWith: []string{"instances"},
Optional: true,
},
"worker_vswitch_ids": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
ConflictsWith: []string{"instances"},
Optional: true,
},
"instances": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
ConflictsWith: []string{"worker_instance_types", "worker_vswitch_ids", "worker_disk_category"},
Optional: true,
},
"format_disk": {
Type: schema.TypeBool,
Optional: true,
},
"keep_instance_name": {
Type: schema.TypeBool,
Optional: true,
},
// "vswitch_ids": {
// Type: schema.TypeList,
// Optional: true,
// Elem: &schema.Schema{
// Type: schema.TypeString,
// ValidateFunc: validation.StringMatch(regexp.MustCompile(`^vsw-[a-z0-9]*$`), "should start with 'vsw-'."),
// },
// MinItems: 3,
// MaxItems: 5,
// DiffSuppressFunc: csForceUpdateSuppressFunc,
// //Removed: "Field 'vswitch_ids' has been removed from provider version 1.75.0. New field 'master_vswitch_ids' and 'worker_vswitch_ids' replace it.",
// },
"master_count": {
Type: schema.TypeInt,
Optional: true,
Default: 3,
},
// single instance type would cause extra troubles
// "master_instance_type": {
// Type: schema.TypeString,
// Optional: true,
// },
// force update is a high risk operation
// "force_update": {
// Type: schema.TypeBool,
// Optional: true,
// Default: false,
// //Removed: "Field 'force_update' has been removed from provider version 1.75.0.",
// },
"availability_zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
// single az would be never supported.
//"vswitch_id": {
// Type: schema.TypeString,
// Required: true,
// //Removed: "Field 'vswitch_id' has been removed from provider version 1.75.0. New field 'master_vswitch_ids' and 'worker_vswitch_ids' replaces it.",
//},
"timeout_mins": {
Type: schema.TypeInt,
Optional: true,
Default: 60,
},
"nodes": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
// too hard to use this config
// "log_config": {
// Type: schema.TypeList,
// Optional: true,
// MaxItems: 1,
// Elem: &schema.Resource{
// Schema: map[string]*schema.Schema{
// "type": {
// Type: schema.TypeString,
// ValidateFunc: validation.StringInSlice([]string{KubernetesClusterLoggingTypeSLS}, false),
// Required: true,
// },
// "project": {
// Type: schema.TypeString,
// Optional: true,
// },
// },
// },
// DiffSuppressFunc: csForceUpdateSuppressFunc,
// //Removed: "Field 'log_config' has been removed from provider version 1.75.0. New field 'addons' replaces it.",
// },
"user_data": {
Type: schema.TypeString,
Optional: true,
},
// "node_name_mode": {
// Type: schema.TypeString,
// Optional: true,
// ValidateFunc: validation.StringMatch(regexp.MustCompile(`^customized,[a-z0-9]([-a-z0-9\.])*,([5-9]|[1][0-2]),([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`), "Each node name consists of a prefix, an IP substring, and a suffix. For example, if the node IP address is 192.168.0.55, the prefix is aliyun.com, IP substring length is 5, and the suffix is test, the node name will be aliyun.com00055test."),
// },
"worker_ram_role_name": {
Type: schema.TypeString,
Computed: true,
},
// "service_account_issuer": {
// Type: schema.TypeString,
// Optional: true,
// ForceNew: true,
// },
// "api_audiences": {
// Type: schema.TypeList,
// Optional: true,
// Elem: &schema.Schema{
// Type: schema.TypeString,
// },
// ForceNew: true,
// },
"nodepool_id": {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
},
}
setResourceFunc(resource, resourceAlibabacloudStackCSKubernetesCreate,
resourceAlibabacloudStackCSKubernetesRead, resourceAlibabacloudStackCSKubernetesUpdate,
resourceAlibabacloudStackCSKubernetesDelete)
return resource
}