Skip to content

Commit a8e6e92

Browse files
authored
Merge pull request #2 from a-devops/internal/devops-3874-update-module
devops-3874 update module
2 parents 9f15edb + 6a6754a commit a8e6e92

File tree

4 files changed

+7
-44
lines changed

4 files changed

+7
-44
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ module "kubernetes" {
9191
| kms\_provider\_key\_id | KMS key ID. | `any` | `null` | no |
9292
| labels | A set of key/value label pairs to assign to the Kubernetes cluster. | `map(string)` | `{}` | no |
9393
| master\_auto\_upgrade | Boolean flag that specifies if master can be upgraded automatically. | `bool` | `true` | no |
94-
| master\_locations | List of locations where cluster will be created. If list contains only one<br>location, will be created zonal cluster, if more than one -- regional. | <pre>list(object({<br> zone = string<br> subnet_id = string<br>}))</pre> | n/a | yes |
94+
| master\_locations | List of locations where cluster will be created. | <pre>list(object({<br> zone = string<br> subnet_id = string<br>}))</pre> | n/a | yes |
9595
| master\_maintenance\_windows | List of structures that specifies maintenance windows, when auto update for master is allowed. | `list(map(string))` | `[]` | no |
9696
| master\_public\_ip | Boolean flag. When true, Kubernetes master will have visible ipv4 address. | `bool` | `true` | no |
9797
| master\_security\_group\_ids | List of security group IDs to which the Kubernetes cluster belongs. | `set(string)` | `null` | no |
98-
| master\_region | Name of region where cluster will be created. Required for regional cluster,<br>not used for zonal cluster. | `string` | `null` | no |
9998
| master\_version | Version of Kubernetes that will be used for master. | `string` | `null` | no |
10099
| name | Name of a specific Kubernetes cluster. | `string` | `null` | no |
101100
| network\_id | The ID of the cluster network. | `string` | n/a | yes |

examples/regional_cluster/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ data "yandex_client_config" "client" {}
2121
module "kubernetes" {
2222
source = "sport24ru/managed-kubernetes/yandex"
2323

24-
name = "regional-cluster"
24+
name = "example-cluster"
2525
folder_id = data.yandex_client_config.client.folder_id
2626
network_id = yandex_vpc_network.kubernetes.id
2727

28-
master_region = "ru-central1"
2928
master_locations = [for subnet in yandex_vpc_subnet.kubernetes : {
3029
subnet_id = subnet.id
3130
zone = subnet.zone

main.tf

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
locals {
2-
master_regions = length(var.master_locations) > 1 ? [{
3-
region = var.master_region
4-
locations = var.master_locations
5-
}] : []
6-
72
master_locations = length(var.master_locations) > 1 ? [] : var.master_locations
83

94
service_account_name = var.service_account_id == null ? var.service_account_name : null
@@ -96,29 +91,11 @@ resource "yandex_kubernetes_cluster" "cluster" {
9691
public_ip = var.master_public_ip
9792
security_group_ids = var.master_security_group_ids
9893

99-
dynamic "zonal" {
100-
for_each = local.master_locations
101-
102-
content {
103-
zone = zonal.value["zone"]
104-
subnet_id = zonal.value["subnet_id"]
105-
}
106-
}
107-
108-
dynamic "regional" {
109-
for_each = local.master_regions
110-
94+
dynamic "master_location" {
95+
for_each = var.master_locations
11196
content {
112-
region = regional.value["region"]
113-
114-
dynamic "location" {
115-
for_each = regional.value["locations"]
116-
117-
content {
118-
zone = location.value["zone"]
119-
subnet_id = location.value["subnet_id"]
120-
}
121-
}
97+
subnet_id = master_location.value["subnet_id"]
98+
zone = master_location.value["zone"]
12299
}
123100
}
124101

variables.tf

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,9 @@ variable "master_security_group_ids" {
180180
default = null
181181
}
182182

183-
variable "master_region" {
184-
description = <<-EOF
185-
Name of region where cluster will be created. Required for regional cluster,
186-
not used for zonal cluster.
187-
EOF
188-
189-
type = string
190-
191-
default = null
192-
}
193-
194183
variable "master_locations" {
195184
description = <<-EOF
196-
List of locations where cluster will be created. If list contains only one
197-
location, will be created zonal cluster, if more than one -- regional.
185+
List of locations where cluster will be created.
198186
EOF
199187

200188
type = list(object({

0 commit comments

Comments
 (0)