in alicloud/resource_alicloud_cs_kubernetes_node_pool.go [874:1601]
func resourceAliCloudAckNodepoolCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
ClusterId := d.Get("cluster_id")
action := fmt.Sprintf("/clusters/%s/nodepools", ClusterId)
var request map[string]interface{}
var response map[string]interface{}
query := make(map[string]*string)
body := make(map[string]interface{})
var err error
request = make(map[string]interface{})
objectDataLocalMap := make(map[string]interface{})
if v, ok := d.GetOk("resource_group_id"); ok {
objectDataLocalMap["resource_group_id"] = v
}
objectDataLocalMap["name"] = d.Get("name")
if v, ok := d.GetOk("node_pool_name"); ok {
objectDataLocalMap["name"] = v
}
request["nodepool_info"] = objectDataLocalMap
objectDataLocalMap1 := make(map[string]interface{})
if v, ok := d.GetOk("node_count"); ok {
request["count"] = v
}
if v, ok := d.GetOk("security_group_ids"); ok {
securityGroupIds, _ := jsonpath.Get("$", v)
if securityGroupIds != nil && securityGroupIds != "" {
objectDataLocalMap1["security_group_ids"] = securityGroupIds
}
}
if v, ok := d.GetOk("period"); ok {
objectDataLocalMap1["period"] = v
}
if v, ok := d.GetOk("platform"); ok {
objectDataLocalMap1["platform"] = v
}
if v := d.Get("data_disks"); !IsNil(v) {
if v, ok := d.GetOk("data_disks"); ok {
localData, err := jsonpath.Get("$", v)
if err != nil {
localData = make([]interface{}, 0)
}
localMaps := make([]interface{}, 0)
for _, dataLoop := range localData.([]interface{}) {
dataLoopTmp := make(map[string]interface{})
if dataLoop != nil {
dataLoopTmp = dataLoop.(map[string]interface{})
}
dataLoopMap := make(map[string]interface{})
dataLoopMap["category"] = dataLoopTmp["category"]
if dataLoopMap["category"] == "cloud_auto" {
dataLoopMap["bursting_enabled"] = dataLoopTmp["bursting_enabled"]
}
dataLoopMap["performance_level"] = dataLoopTmp["performance_level"]
dataLoopMap["auto_snapshot_policy_id"] = dataLoopTmp["auto_snapshot_policy_id"]
if dataLoopTmp["provisioned_iops"].(int) > 0 {
dataLoopMap["provisioned_iops"] = dataLoopTmp["provisioned_iops"]
}
dataLoopMap["encrypted"] = dataLoopTmp["encrypted"]
if dataLoopTmp["size"].(int) > 0 {
dataLoopMap["size"] = dataLoopTmp["size"]
}
dataLoopMap["kms_key_id"] = dataLoopTmp["kms_key_id"]
dataLoopMap["disk_name"] = dataLoopTmp["name"]
dataLoopMap["device"] = dataLoopTmp["device"]
dataLoopMap["snapshot_id"] = dataLoopTmp["snapshot_id"]
if autoFormatRaw, ok := dataLoopTmp["auto_format"]; ok && autoFormatRaw != "" {
autoFormat, _ := strconv.ParseBool(autoFormatRaw.(string))
dataLoopMap["auto_format"] = autoFormat
}
dataLoopMap["file_system"] = dataLoopTmp["file_system"]
dataLoopMap["mount_target"] = dataLoopTmp["mount_target"]
localMaps = append(localMaps, dataLoopMap)
}
objectDataLocalMap1["data_disks"] = localMaps
}
}
if v, ok := d.GetOk("deployment_set_id"); ok {
objectDataLocalMap1["deploymentset_id"] = v
}
if v, ok := d.GetOk("compensate_with_on_demand"); ok {
objectDataLocalMap1["compensate_with_on_demand"] = v
}
if v, ok := d.GetOk("auto_renew"); ok {
objectDataLocalMap1["auto_renew"] = v
}
if v, ok := d.GetOk("auto_renew_period"); ok {
objectDataLocalMap1["auto_renew_period"] = v
}
if v, ok := d.GetOk("desired_size"); ok {
if v != nil && v != "" {
desiredSize, _ := strconv.ParseInt(v.(string), 10, 64)
objectDataLocalMap1["desired_size"] = desiredSize
}
}
if v, ok := d.GetOk("image_id"); ok {
objectDataLocalMap1["image_id"] = v
}
if v, ok := d.GetOk("image_type"); ok {
objectDataLocalMap1["image_type"] = v
}
if v, ok := d.GetOk("instance_charge_type"); ok {
objectDataLocalMap1["instance_charge_type"] = v
}
if v, ok := d.GetOk("internet_charge_type"); ok {
objectDataLocalMap1["internet_charge_type"] = v
}
if v, ok := d.GetOk("internet_max_bandwidth_out"); ok {
objectDataLocalMap1["internet_max_bandwidth_out"] = v
}
if v, ok := d.GetOk("key_name"); ok {
objectDataLocalMap1["key_pair"] = v
}
if v, ok := d.GetOk("multi_az_policy"); ok {
objectDataLocalMap1["multi_az_policy"] = v
}
if v, ok := d.GetOk("on_demand_base_capacity"); ok {
if v != nil && v != "" {
onDemandBaseCapacity, _ := strconv.ParseInt(v.(string), 10, 64)
objectDataLocalMap1["on_demand_base_capacity"] = onDemandBaseCapacity
}
}
if v, ok := d.GetOk("on_demand_percentage_above_base_capacity"); ok {
if v != nil && v != "" {
onDemandPercentageAboveBaseCapacity, _ := strconv.ParseInt(v.(string), 10, 64)
objectDataLocalMap1["on_demand_percentage_above_base_capacity"] = onDemandPercentageAboveBaseCapacity
}
}
if v, ok := d.GetOk("period_unit"); ok {
objectDataLocalMap1["period_unit"] = v
}
if v, ok := d.GetOk("scaling_policy"); ok {
objectDataLocalMap1["scaling_policy"] = v
}
if v, ok := d.GetOk("security_group_id"); ok {
objectDataLocalMap1["security_group_id"] = v
}
if v, ok := d.GetOk("spot_instance_pools"); ok {
objectDataLocalMap1["spot_instance_pools"] = v
}
if v, ok := d.GetOk("spot_instance_remedy"); ok {
objectDataLocalMap1["spot_instance_remedy"] = v
}
if v := d.Get("spot_price_limit"); !IsNil(v) {
if v, ok := d.GetOk("spot_price_limit"); ok {
localData1, err := jsonpath.Get("$", v)
if err != nil {
localData1 = make([]interface{}, 0)
}
localMaps1 := make([]interface{}, 0)
for _, dataLoop1 := range localData1.([]interface{}) {
dataLoop1Tmp := make(map[string]interface{})
if dataLoop1 != nil {
dataLoop1Tmp = dataLoop1.(map[string]interface{})
}
dataLoop1Map := make(map[string]interface{})
dataLoop1Map["instance_type"] = dataLoop1Tmp["instance_type"]
dataLoop1Map["price_limit"] = dataLoop1Tmp["price_limit"]
localMaps1 = append(localMaps1, dataLoop1Map)
}
objectDataLocalMap1["spot_price_limit"] = localMaps1
}
}
if v, ok := d.GetOk("spot_strategy"); ok {
objectDataLocalMap1["spot_strategy"] = v
}
if v, ok := d.GetOk("system_disk_bursting_enabled"); ok {
objectDataLocalMap1["system_disk_bursting_enabled"] = v
}
if v, ok := d.GetOk("system_disk_category"); ok {
objectDataLocalMap1["system_disk_category"] = v
}
if v, ok := d.GetOk("system_disk_performance_level"); ok {
objectDataLocalMap1["system_disk_performance_level"] = v
}
if v, ok := d.GetOk("vswitch_ids"); ok {
vswitchIds, _ := jsonpath.Get("$", v)
if vswitchIds != nil && vswitchIds != "" {
objectDataLocalMap1["vswitch_ids"] = vswitchIds
}
}
if v := d.Get("tags"); !IsNil(v) {
tagsMap := ConvertTags(v.(map[string]interface{}))
objectDataLocalMap1["tags"] = tagsMap
}
if v, ok := d.GetOk("system_disk_size"); ok {
objectDataLocalMap1["system_disk_size"] = v
}
if v, ok := d.GetOk("system_disk_provisioned_iops"); ok {
objectDataLocalMap1["system_disk_provisioned_iops"] = v
}
if v, ok := d.GetOk("password"); ok {
objectDataLocalMap1["login_password"] = v
}
if v := d.Get("private_pool_options"); !IsNil(v) {
private_pool_options := make(map[string]interface{})
privatePoolOptionsMatchCriteria, _ := jsonpath.Get("$[0].private_pool_options_match_criteria", v)
if privatePoolOptionsMatchCriteria != nil && privatePoolOptionsMatchCriteria != "" {
private_pool_options["match_criteria"] = privatePoolOptionsMatchCriteria
}
privatePoolOptionsId, _ := jsonpath.Get("$[0].private_pool_options_id", v)
if privatePoolOptionsId != nil && privatePoolOptionsId != "" {
private_pool_options["id"] = privatePoolOptionsId
}
objectDataLocalMap1["private_pool_options"] = private_pool_options
}
password := d.Get("password").(string)
if password == "" {
if v := d.Get("kms_encrypted_password").(string); v != "" {
kmsService := KmsService{client}
decryptResp, err := kmsService.Decrypt(v, d.Get("kms_encryption_context").(map[string]interface{}))
if err != nil {
return WrapError(err)
}
objectDataLocalMap1["login_password"] = decryptResp
}
}
if v, ok := d.GetOk("cis_enabled"); ok {
objectDataLocalMap1["cis_enabled"] = v
}
if v, ok := d.GetOk("soc_enabled"); ok {
objectDataLocalMap1["soc_enabled"] = v
}
if v, ok := d.GetOk("system_disk_encrypt_algorithm"); ok {
objectDataLocalMap1["system_disk_encrypt_algorithm"] = v
}
if v, ok := d.GetOk("login_as_non_root"); ok {
objectDataLocalMap1["login_as_non_root"] = v
}
if v, ok := d.GetOk("system_disk_encrypted"); ok {
objectDataLocalMap1["system_disk_encrypted"] = v
}
if v, ok := d.GetOk("system_disk_categories"); ok {
systemDiskCategories, _ := jsonpath.Get("$", v)
if systemDiskCategories != nil && systemDiskCategories != "" {
objectDataLocalMap1["system_disk_categories"] = systemDiskCategories
}
}
if v, ok := d.GetOk("instance_types"); ok {
instanceTypes, _ := jsonpath.Get("$", v)
if instanceTypes != nil && instanceTypes != "" {
objectDataLocalMap1["instance_types"] = instanceTypes
}
}
if v, ok := d.GetOk("rds_instances"); ok {
rdsInstances, _ := jsonpath.Get("$", v)
if rdsInstances != nil && rdsInstances != "" {
objectDataLocalMap1["rds_instances"] = rdsInstances
}
}
if v, ok := d.GetOk("system_disk_kms_key"); ok {
objectDataLocalMap1["system_disk_kms_key_id"] = v
}
if v, ok := d.GetOk("system_disk_snapshot_policy_id"); ok {
objectDataLocalMap1["worker_system_disk_snapshot_policy_id"] = v
}
if v, ok := d.GetOk("security_hardening_os"); ok {
objectDataLocalMap1["security_hardening_os"] = v
}
if v, ok := d.GetOk("ram_role_name"); ok {
objectDataLocalMap1["ram_role_name"] = v
}
request["scaling_group"] = objectDataLocalMap1
objectDataLocalMap2 := make(map[string]interface{})
if v, ok := d.GetOk("cpu_policy"); ok {
objectDataLocalMap2["cpu_policy"] = v
}
if v, ok := d.GetOk("install_cloud_monitor"); ok {
objectDataLocalMap2["cms_enabled"] = v
}
if v, ok := d.GetOk("runtime_version"); ok {
objectDataLocalMap2["runtime_version"] = v
}
if v, ok := d.GetOk("user_data"); ok {
objectDataLocalMap2["user_data"] = v
if v := d.Get("user_data").(string); v != "" {
_, base64DecodeError := base64.StdEncoding.DecodeString(v)
if base64DecodeError == nil {
objectDataLocalMap2["user_data"] = tea.String(v)
} else {
objectDataLocalMap2["user_data"] = tea.String(base64.StdEncoding.EncodeToString([]byte(v)))
}
}
}
if v := d.Get("taints"); !IsNil(v) {
if v, ok := d.GetOk("taints"); ok {
localData3, err := jsonpath.Get("$", v)
if err != nil {
localData3 = make([]interface{}, 0)
}
localMaps3 := make([]interface{}, 0)
for _, dataLoop3 := range localData3.([]interface{}) {
dataLoop3Tmp := make(map[string]interface{})
if dataLoop3 != nil {
dataLoop3Tmp = dataLoop3.(map[string]interface{})
}
dataLoop3Map := make(map[string]interface{})
dataLoop3Map["key"] = dataLoop3Tmp["key"]
dataLoop3Map["effect"] = dataLoop3Tmp["effect"]
dataLoop3Map["value"] = dataLoop3Tmp["value"]
localMaps3 = append(localMaps3, dataLoop3Map)
}
objectDataLocalMap2["taints"] = localMaps3
}
}
if v, ok := d.GetOk("node_name_mode"); ok {
objectDataLocalMap2["node_name_mode"] = v
}
if v, ok := d.GetOk("unschedulable"); ok {
objectDataLocalMap2["unschedulable"] = v
}
if v, ok := d.GetOk("runtime_name"); ok {
objectDataLocalMap2["runtime"] = v
}
if v := d.Get("labels"); !IsNil(v) {
if v, ok := d.GetOk("labels"); ok {
localData4, err := jsonpath.Get("$", v)
if err != nil {
localData4 = make([]interface{}, 0)
}
localMaps4 := make([]interface{}, 0)
for _, dataLoop4 := range localData4.([]interface{}) {
dataLoop4Tmp := make(map[string]interface{})
if dataLoop4 != nil {
dataLoop4Tmp = dataLoop4.(map[string]interface{})
}
dataLoop4Map := make(map[string]interface{})
dataLoop4Map["key"] = dataLoop4Tmp["key"]
dataLoop4Map["value"] = dataLoop4Tmp["value"]
localMaps4 = append(localMaps4, dataLoop4Map)
}
objectDataLocalMap2["labels"] = localMaps4
}
}
if v, ok := d.GetOk("pre_user_data"); ok {
objectDataLocalMap2["pre_user_data"] = v
}
request["kubernetes_config"] = objectDataLocalMap2
objectDataLocalMap3 := make(map[string]interface{})
if v := d.Get("scaling_config"); !IsNil(v) {
type1, _ := jsonpath.Get("$[0].type", v)
if type1 != nil && type1 != "" {
objectDataLocalMap3["type"] = type1
}
maxSize, _ := jsonpath.Get("$[0].max_size", v)
if maxSize != nil && maxSize != "" {
objectDataLocalMap3["max_instances"] = maxSize
}
minSize, _ := jsonpath.Get("$[0].min_size", v)
if minSize != nil && minSize != "" {
objectDataLocalMap3["min_instances"] = minSize
}
isBondEip, _ := jsonpath.Get("$[0].is_bond_eip", v)
if isBondEip != nil && isBondEip != "" {
objectDataLocalMap3["is_bond_eip"] = isBondEip
}
enable1, _ := jsonpath.Get("$[0].enable", v)
if enable1 != nil && enable1 != "" {
objectDataLocalMap3["enable"] = enable1
}
eipInternetChargeType, _ := jsonpath.Get("$[0].eip_internet_charge_type", v)
if eipInternetChargeType != nil && eipInternetChargeType != "" {
objectDataLocalMap3["eip_internet_charge_type"] = eipInternetChargeType
}
eipBandwidth, _ := jsonpath.Get("$[0].eip_bandwidth", v)
if eipBandwidth != nil && eipBandwidth != "" && eipBandwidth.(int) > 0 {
objectDataLocalMap3["eip_bandwidth"] = eipBandwidth
}
request["auto_scaling"] = objectDataLocalMap3
}
objectDataLocalMap4 := make(map[string]interface{})
if v := d.Get("management"); !IsNil(v) {
enable3, _ := jsonpath.Get("$[0].enable", v)
if enable3 != nil && enable3 != "" {
objectDataLocalMap4["enable"] = enable3
}
autoRepair, _ := jsonpath.Get("$[0].auto_repair", v)
if autoRepair != nil && autoRepair != "" {
objectDataLocalMap4["auto_repair"] = autoRepair
}
auto_repair_policy := make(map[string]interface{})
restartNode, _ := jsonpath.Get("$[0].auto_repair_policy[0].restart_node", v)
if restartNode != nil && restartNode != "" {
auto_repair_policy["restart_node"] = restartNode
}
objectDataLocalMap4["auto_repair_policy"] = auto_repair_policy
autoVulFix, _ := jsonpath.Get("$[0].auto_vul_fix", v)
if autoVulFix != nil && autoVulFix != "" {
objectDataLocalMap4["auto_vul_fix"] = autoVulFix
}
auto_vul_fix_policy := make(map[string]interface{})
restartNode1, _ := jsonpath.Get("$[0].auto_vul_fix_policy[0].restart_node", v)
if restartNode1 != nil && restartNode1 != "" {
auto_vul_fix_policy["restart_node"] = restartNode1
}
vulLevel, _ := jsonpath.Get("$[0].auto_vul_fix_policy[0].vul_level", v)
if vulLevel != nil && vulLevel != "" {
auto_vul_fix_policy["vul_level"] = vulLevel
}
objectDataLocalMap4["auto_vul_fix_policy"] = auto_vul_fix_policy
autoUpgrade, _ := jsonpath.Get("$[0].auto_upgrade", v)
if autoUpgrade != nil && autoUpgrade != "" {
objectDataLocalMap4["auto_upgrade"] = autoUpgrade
}
auto_upgrade_policy := make(map[string]interface{})
autoUpgradeKubelet, _ := jsonpath.Get("$[0].auto_upgrade_policy[0].auto_upgrade_kubelet", v)
if autoUpgradeKubelet != nil && autoUpgradeKubelet != "" {
auto_upgrade_policy["auto_upgrade_kubelet"] = autoUpgradeKubelet
}
objectDataLocalMap4["auto_upgrade_policy"] = auto_upgrade_policy
upgrade_config := make(map[string]interface{})
surge1, _ := jsonpath.Get("$[0].surge", v)
if surge1 != nil && surge1 != "" {
upgrade_config["surge"] = surge1
}
surgePercentage, _ := jsonpath.Get("$[0].surge_percentage", v)
if surgePercentage != nil && surgePercentage != "" {
upgrade_config["surge_percentage"] = surgePercentage
}
maxUnavailable, _ := jsonpath.Get("$[0].max_unavailable", v)
if maxUnavailable != nil && maxUnavailable != "" && maxUnavailable.(int) > 0 {
upgrade_config["max_unavailable"] = maxUnavailable
}
objectDataLocalMap4["upgrade_config"] = upgrade_config
request["management"] = objectDataLocalMap4
}
objectDataLocalMap5 := make(map[string]interface{})
if v := d.Get("tee_config"); !IsNil(v) {
teeEnable, _ := jsonpath.Get("$[0].tee_enable", v)
if teeEnable != nil && teeEnable != "" {
objectDataLocalMap5["tee_enable"] = teeEnable
}
request["tee_config"] = objectDataLocalMap5
}
objectDataLocalMap6 := make(map[string]interface{})
if v := d.Get("kubelet_configuration"); !IsNil(v) {
kubelet_configuration := make(map[string]interface{})
registryPullQpsRaw, _ := jsonpath.Get("$[0].registry_pull_qps", v)
if registryPullQpsRaw != nil && registryPullQpsRaw != "" {
registryPullQps, _ := strconv.ParseInt(registryPullQpsRaw.(string), 10, 64)
kubelet_configuration["registryPullQPS"] = registryPullQps
}
registryBurst1Raw, _ := jsonpath.Get("$[0].registry_burst", v)
if registryBurst1Raw != nil && registryBurst1Raw != "" {
registryBurst1, _ := strconv.ParseInt(registryBurst1Raw.(string), 10, 64)
kubelet_configuration["registryBurst"] = registryBurst1
}
eventRecordQpsRaw, _ := jsonpath.Get("$[0].event_record_qps", v)
if eventRecordQpsRaw != nil && eventRecordQpsRaw != "" {
eventRecordQps, _ := strconv.ParseInt(eventRecordQpsRaw.(string), 10, 64)
kubelet_configuration["eventRecordQPS"] = eventRecordQps
}
eventBurst1Raw, _ := jsonpath.Get("$[0].event_burst", v)
if eventBurst1Raw != nil && eventBurst1Raw != "" {
eventBurst1, _ := strconv.ParseInt(eventBurst1Raw.(string), 10, 64)
kubelet_configuration["eventBurst"] = eventBurst1
}
kubeApiQpsRaw, _ := jsonpath.Get("$[0].kube_api_qps", v)
if kubeApiQpsRaw != nil && kubeApiQpsRaw != "" {
kubeApiQps, _ := strconv.ParseInt(kubeApiQpsRaw.(string), 10, 64)
kubelet_configuration["kubeAPIQPS"] = kubeApiQps
}
serializeImagePulls1Raw, _ := jsonpath.Get("$[0].serialize_image_pulls", v)
if serializeImagePulls1Raw != nil && serializeImagePulls1Raw != "" {
serializeImagePulls1, _ := strconv.ParseBool(serializeImagePulls1Raw.(string))
kubelet_configuration["serializeImagePulls"] = serializeImagePulls1
}
cpuManagerPolicy1, _ := jsonpath.Get("$[0].cpu_manager_policy", v)
if cpuManagerPolicy1 != nil && cpuManagerPolicy1 != "" {
kubelet_configuration["cpuManagerPolicy"] = cpuManagerPolicy1
}
allowedUnsafeSysctls1, _ := jsonpath.Get("$[0].allowed_unsafe_sysctls", v)
if allowedUnsafeSysctls1 != nil && allowedUnsafeSysctls1 != "" {
kubelet_configuration["allowedUnsafeSysctls"] = allowedUnsafeSysctls1
}
featureGates1, _ := jsonpath.Get("$[0].feature_gates", v)
if featureGates1 != nil && featureGates1 != "" {
kubelet_configuration["featureGates"] = featureGates1
}
containerLogMaxFiles1Raw, _ := jsonpath.Get("$[0].container_log_max_files", v)
if containerLogMaxFiles1Raw != nil && containerLogMaxFiles1Raw != "" {
containerLogMaxFiles1, _ := strconv.ParseInt(containerLogMaxFiles1Raw.(string), 10, 64)
kubelet_configuration["containerLogMaxFiles"] = containerLogMaxFiles1
}
containerLogMaxSize1, _ := jsonpath.Get("$[0].container_log_max_size", v)
if containerLogMaxSize1 != nil && containerLogMaxSize1 != "" {
kubelet_configuration["containerLogMaxSize"] = containerLogMaxSize1
}
maxPods1Raw, _ := jsonpath.Get("$[0].max_pods", v)
if maxPods1Raw != nil && maxPods1Raw != "" {
maxPods1, _ := strconv.ParseInt(maxPods1Raw.(string), 10, 64)
kubelet_configuration["maxPods"] = maxPods1
}
readOnlyPort1Raw, _ := jsonpath.Get("$[0].read_only_port", v)
if readOnlyPort1Raw != nil && readOnlyPort1Raw != "" {
readOnlyPort1, _ := strconv.ParseInt(readOnlyPort1Raw.(string), 10, 64)
kubelet_configuration["readOnlyPort"] = readOnlyPort1
}
kubeReserved1, _ := jsonpath.Get("$[0].kube_reserved", v)
if kubeReserved1 != nil && kubeReserved1 != "" {
kubelet_configuration["kubeReserved"] = kubeReserved1
}
systemReserved1, _ := jsonpath.Get("$[0].system_reserved", v)
if systemReserved1 != nil && systemReserved1 != "" {
kubelet_configuration["systemReserved"] = systemReserved1
}
evictionSoftGracePeriod1, _ := jsonpath.Get("$[0].eviction_soft_grace_period", v)
if evictionSoftGracePeriod1 != nil && evictionSoftGracePeriod1 != "" {
kubelet_configuration["evictionSoftGracePeriod"] = evictionSoftGracePeriod1
}
evictionSoft1, _ := jsonpath.Get("$[0].eviction_soft", v)
if evictionSoft1 != nil && evictionSoft1 != "" {
kubelet_configuration["evictionSoft"] = evictionSoft1
}
evictionHard1, _ := jsonpath.Get("$[0].eviction_hard", v)
if evictionHard1 != nil && evictionHard1 != "" {
kubelet_configuration["evictionHard"] = evictionHard1
}
kubeApiBurstRaw, _ := jsonpath.Get("$[0].kube_api_burst", v)
if kubeApiBurstRaw != nil && kubeApiBurstRaw != "" {
kubeApiBurst, _ := strconv.ParseInt(kubeApiBurstRaw.(string), 10, 64)
kubelet_configuration["kubeAPIBurst"] = kubeApiBurst
}
cpuCfsQuotaRaw, _ := jsonpath.Get("$[0].cpu_cfs_quota", v)
if cpuCfsQuotaRaw != nil && cpuCfsQuotaRaw != "" {
cpuCfsQuota, _ := strconv.ParseBool(cpuCfsQuotaRaw.(string))
kubelet_configuration["cpuCFSQuota"] = cpuCfsQuota
}
cpuCfsQuotaPeriod, _ := jsonpath.Get("$[0].cpu_cfs_quota_period", v)
if cpuCfsQuotaPeriod != nil && cpuCfsQuotaPeriod != "" {
kubelet_configuration["cpuCFSQuotaPeriod"] = cpuCfsQuotaPeriod
}
imageGcHighThresholdPercentRaw, _ := jsonpath.Get("$[0].image_gc_high_threshold_percent", v)
if imageGcHighThresholdPercentRaw != nil && imageGcHighThresholdPercentRaw != "" {
imageGcHighThresholdPercent, _ := strconv.ParseInt(imageGcHighThresholdPercentRaw.(string), 10, 64)
kubelet_configuration["imageGCHighThresholdPercent"] = imageGcHighThresholdPercent
}
imageGcLowThresholdPercentRaw, _ := jsonpath.Get("$[0].image_gc_low_threshold_percent", v)
if imageGcLowThresholdPercentRaw != nil && imageGcLowThresholdPercentRaw != "" {
imageGcLowThresholdPercent, _ := strconv.ParseInt(imageGcLowThresholdPercentRaw.(string), 10, 64)
kubelet_configuration["imageGCLowThresholdPercent"] = imageGcLowThresholdPercent
}
podPidsLimit1Raw, _ := jsonpath.Get("$[0].pod_pids_limit", v)
if podPidsLimit1Raw != nil && podPidsLimit1Raw != "" {
podPidsLimit1, _ := strconv.ParseInt(podPidsLimit1Raw.(string), 10, 64)
kubelet_configuration["podPidsLimit"] = podPidsLimit1
}
topologyManagerPolicy1, _ := jsonpath.Get("$[0].topology_manager_policy", v)
if topologyManagerPolicy1 != nil && topologyManagerPolicy1 != "" {
kubelet_configuration["topologyManagerPolicy"] = topologyManagerPolicy1
}
clusterDns, _ := jsonpath.Get("$[0].cluster_dns", v)
if clusterDns != nil && clusterDns != "" {
kubelet_configuration["clusterDNS"] = clusterDns
}
memoryManagerPolicy1, _ := jsonpath.Get("$[0].memory_manager_policy", v)
if memoryManagerPolicy1 != nil && memoryManagerPolicy1 != "" {
kubelet_configuration["memoryManagerPolicy"] = memoryManagerPolicy1
}
if v, ok := d.GetOk("kubelet_configuration"); ok {
localData5, err := jsonpath.Get("$[0].reserved_memory", v)
if err != nil {
localData5 = make([]interface{}, 0)
}
localMaps5 := make([]interface{}, 0)
for _, dataLoop5 := range localData5.([]interface{}) {
dataLoop5Tmp := make(map[string]interface{})
if dataLoop5 != nil {
dataLoop5Tmp = dataLoop5.(map[string]interface{})
}
dataLoop5Map := make(map[string]interface{})
dataLoop5Map["limits"] = dataLoop5Tmp["limits"]
dataLoop5Map["numaNode"] = dataLoop5Tmp["numa_node"]
localMaps5 = append(localMaps5, dataLoop5Map)
}
kubelet_configuration["reservedMemory"] = localMaps5
}
containerLogMaxWorkers1Raw, _ := jsonpath.Get("$[0].container_log_max_workers", v)
if containerLogMaxWorkers1Raw != nil && containerLogMaxWorkers1Raw != "" {
containerLogMaxWorkers1, _ := strconv.ParseInt(containerLogMaxWorkers1Raw.(string), 10, 64)
kubelet_configuration["containerLogMaxWorkers"] = containerLogMaxWorkers1
}
containerLogMonitorInterval1, _ := jsonpath.Get("$[0].container_log_monitor_interval", v)
if containerLogMonitorInterval1 != nil && containerLogMonitorInterval1 != "" {
kubelet_configuration["containerLogMonitorInterval"] = containerLogMonitorInterval1
}
tracing := make(map[string]interface{})
endpoint1, _ := jsonpath.Get("$[0].tracing[0].endpoint", v)
if endpoint1 != nil && endpoint1 != "" {
tracing["endpoint"] = endpoint1
}
samplingRatePerMillion1Raw, _ := jsonpath.Get("$[0].tracing[0].sampling_rate_per_million", v)
if samplingRatePerMillion1Raw != nil && samplingRatePerMillion1Raw != "" {
samplingRatePerMillion1, _ := strconv.ParseInt(samplingRatePerMillion1Raw.(string), 10, 64)
tracing["samplingRatePerMillion"] = samplingRatePerMillion1
}
kubelet_configuration["tracing"] = tracing
objectDataLocalMap6["kubelet_configuration"] = kubelet_configuration
request["node_config"] = objectDataLocalMap6
}
body = request
wait := incrementalWait(3*time.Second, 5*time.Second)
err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
response, err = client.RoaPost("CS", "2015-12-15", action, query, nil, body, true)
if err != nil {
if NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
addDebug(action, response, request)
if err != nil {
return WrapErrorf(err, DefaultErrorMsg, "alicloud_cs_kubernetes_node_pool", action, AlibabaCloudSdkGoERROR)
}
nodepool_idVar, _ := jsonpath.Get("$.nodepool_id", response)
d.SetId(fmt.Sprintf("%v:%v", ClusterId, nodepool_idVar))
ackServiceV2 := AckServiceV2{client}
stateConf := BuildStateConf([]string{}, []string{"success"}, d.Timeout(schema.TimeoutCreate), 5*time.Second, ackServiceV2.DescribeAsyncAckNodepoolStateRefreshFunc(d, response, "$.state", []string{"fail", "failed"}))
if jobDetail, err := stateConf.WaitForState(); err != nil {
return WrapErrorf(err, IdMsg, d.Id(), jobDetail)
}
if v, ok := d.GetOk("instances"); ok && v != nil {
if err := attachExistingInstance(d, meta, expandStringList(v.([]interface{}))); err != nil {
return WrapErrorf(err, DefaultErrorMsg, "alicloud_cs_kubernetes_node_pool", action, AlibabaCloudSdkGoERROR)
}
}
return resourceAliCloudAckNodepoolRead(d, meta)
}