|
| 1 | +resource "huaweicloud_vpc" "test" { |
| 2 | + name = var.random_resource_name |
| 3 | + cidr = "192.168.0.0/16" |
| 4 | +} |
| 5 | + |
| 6 | +resource "huaweicloud_vpc_subnet" "test" { |
| 7 | + vpc_id = huaweicloud_vpc.test.id |
| 8 | + |
| 9 | + name = var.random_resource_name |
| 10 | + cidr = cidrsubnet(huaweicloud_vpc.test.cidr, 8, 0) |
| 11 | + gateway_ip = cidrhost(cidrsubnet(huaweicloud_vpc.test.cidr, 8, 0), 1) |
| 12 | + |
| 13 | + primary_dns = "100.125.1.250" |
| 14 | + secondary_dns = "100.125.21.250" |
| 15 | +} |
| 16 | + |
| 17 | +resource "huaweicloud_vpc_subnet" "eni_network" { |
| 18 | + vpc_id = huaweicloud_vpc.test.id |
| 19 | + |
| 20 | + name = format("%s_eni_usage", var.random_resource_name) |
| 21 | + cidr = cidrsubnet(huaweicloud_vpc.test.cidr, 8, 2) |
| 22 | + gateway_ip = cidrhost(cidrsubnet(huaweicloud_vpc.test.cidr, 8, 2), 1) |
| 23 | + |
| 24 | + availability_zone = var.iec_availability_zone |
| 25 | +} |
| 26 | + |
| 27 | +resource "huaweicloud_cce_cluster" "test" { |
| 28 | + name = var.random_resource_name |
| 29 | + flavor_id = "cce.s1.small" |
| 30 | + vpc_id = huaweicloud_vpc.test.id |
| 31 | + subnet_id = huaweicloud_vpc_subnet.test.id |
| 32 | + container_network_type = "eni" |
| 33 | + |
| 34 | + enable_distribute_management = true |
| 35 | + |
| 36 | + eni_subnet_id = join(",", [ |
| 37 | + huaweicloud_vpc_subnet.test.ipv4_subnet_id, |
| 38 | + ]) |
| 39 | + |
| 40 | + lifecycle { |
| 41 | + ignore_changes = [ |
| 42 | + eni_subnet_id, |
| 43 | + ] |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +resource "huaweicloud_cce_partition" "test" { |
| 48 | + cluster_id = huaweicloud_cce_cluster.test.id |
| 49 | + |
| 50 | + name = var.iec_availability_zone |
| 51 | + category = "HomeZone" |
| 52 | + public_border_group = var.iec_partition_border_group |
| 53 | + partition_subnet_id = huaweicloud_vpc_subnet.eni_network.id |
| 54 | + container_subnet_ids = [huaweicloud_vpc_subnet.eni_network.ipv4_subnet_id] |
| 55 | +} |
| 56 | + |
| 57 | +data "huaweicloud_compute_flavors" "test" { |
| 58 | + availability_zone = var.iec_availability_zone |
| 59 | + performance_type = "computingv3" |
| 60 | + cpu_core_count = 2 |
| 61 | + memory_size = 4 |
| 62 | +} |
| 63 | + |
| 64 | +resource "huaweicloud_cce_node" "test" { |
| 65 | + cluster_id = huaweicloud_cce_cluster.test.id |
| 66 | + name = var.random_resource_name |
| 67 | + flavor_id = try(data.huaweicloud_compute_flavors.test.flavors[0].id, "") |
| 68 | + availability_zone = var.iec_availability_zone |
| 69 | + partition = huaweicloud_cce_partition.test.id |
| 70 | + password = "Overlord!!52259" |
| 71 | + |
| 72 | + root_volume { |
| 73 | + size = 40 |
| 74 | + volumetype = "SSD" |
| 75 | + } |
| 76 | + |
| 77 | + data_volumes { |
| 78 | + size = 100 |
| 79 | + volumetype = "SSD" |
| 80 | + } |
| 81 | +} |
0 commit comments