Skip to content

Commit a9dd634

Browse files
Merge pull request #3573 from ankitkinra/hotfix-fix-container-gcluster-kubectl
Revert PR 3406
2 parents 79299a1 + fcc2d8d commit a9dd634

File tree

26 files changed

+120
-170
lines changed

26 files changed

+120
-170
lines changed

community/modules/compute/gke-topology-scheduler/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ No resources.
4545
4646
| Name | Description | Type | Default | Required |
4747
|------|-------------|------|---------|:--------:|
48-
| <a name="input_gke_cluster_exists"></a> [gke\_cluster\_exists](#input\_gke\_cluster\_exists) | A static flag that signals to modules that a cluster has been created. | `bool` | `false` | no |
48+
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | projects/{{project}}/locations/{{location}}/clusters/{{cluster}} | `string` | n/a | yes |
49+
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | The project ID to host the cluster in. | `string` | n/a | yes |
4950

5051
## Outputs
5152

community/modules/compute/gke-topology-scheduler/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
module "kubectl_apply" {
1616
source = "../../../../modules/management/kubectl-apply"
1717

18-
gke_cluster_exists = var.gke_cluster_exists
18+
cluster_id = var.cluster_id
19+
project_id = var.project_id
1920

2021
apply_manifests = [
2122
{ source = "${path.module}/manifests/topology-scheduler-scripts.yaml" },

community/modules/compute/gke-topology-scheduler/variables.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
variable "gke_cluster_exists" {
16-
description = "A static flag that signals to modules that a cluster has been created."
17-
type = bool
18-
default = false
15+
variable "project_id" {
16+
description = "The project ID to host the cluster in."
17+
type = string
18+
}
19+
20+
variable "cluster_id" {
21+
description = "projects/{{project}}/locations/{{location}}/clusters/{{cluster}}"
22+
type = string
1923
}

modules/compute/gke-node-pool/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ limitations under the License.
323323
| <a name="input_disk_type"></a> [disk\_type](#input\_disk\_type) | Disk type for each node. | `string` | `null` | no |
324324
| <a name="input_enable_gcfs"></a> [enable\_gcfs](#input\_enable\_gcfs) | Enable the Google Container Filesystem (GCFS). See [restrictions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#gcfs_config). | `bool` | `false` | no |
325325
| <a name="input_enable_secure_boot"></a> [enable\_secure\_boot](#input\_enable\_secure\_boot) | Enable secure boot for the nodes. Keep enabled unless custom kernel modules need to be loaded. See [here](https://cloud.google.com/compute/shielded-vm/docs/shielded-vm#secure-boot) for more info. | `bool` | `true` | no |
326-
| <a name="input_gke_cluster_exists"></a> [gke\_cluster\_exists](#input\_gke\_cluster\_exists) | A static flag that signals to modules that a cluster has been created. | `bool` | `false` | no |
327326
| <a name="input_gke_version"></a> [gke\_version](#input\_gke\_version) | GKE version | `string` | n/a | yes |
328327
| <a name="input_guest_accelerator"></a> [guest\_accelerator](#input\_guest\_accelerator) | List of the type and count of accelerator cards attached to the instance. | <pre>list(object({<br/> type = optional(string)<br/> count = optional(number, 0)<br/> gpu_driver_installation_config = optional(object({<br/> gpu_driver_version = string<br/> }), { gpu_driver_version = "DEFAULT" })<br/> gpu_partition_size = optional(string)<br/> gpu_sharing_config = optional(object({<br/> gpu_sharing_strategy = string<br/> max_shared_clients_per_gpu = number<br/> }))<br/> }))</pre> | `[]` | no |
329328
| <a name="input_host_maintenance_interval"></a> [host\_maintenance\_interval](#input\_host\_maintenance\_interval) | Specifies the frequency of planned maintenance events. | `string` | `""` | no |

modules/compute/gke-node-pool/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ resource "null_resource" "enable_tcpxo_in_workload" {
375375
module "kubectl_apply" {
376376
source = "../../management/kubectl-apply"
377377

378-
gke_cluster_exists = var.gke_cluster_exists
378+
cluster_id = var.cluster_id
379+
project_id = var.project_id
379380

380381
apply_manifests = flatten([
381382
for manifest in local.gpu_direct_setting.gpu_direct_manifests : [

modules/compute/gke-node-pool/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ variable "cluster_id" {
2424
type = string
2525
}
2626

27-
variable "gke_cluster_exists" {
28-
description = "A static flag that signals to modules that a cluster has been created."
29-
type = bool
30-
default = false
31-
}
32-
3327
variable "zones" {
3428
description = "A list of zones to be used. Zones must be in region of cluster. If null, cluster zones will be inherited. Note `zones` not `zone`; does not work with `zone` deployment variable."
3529
type = list(string)

modules/file-system/gke-persistent-volume/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,15 @@ limitations under the License.
121121
| Name | Version |
122122
|------|---------|
123123
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
124+
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 4.42 |
124125
| <a name="requirement_kubectl"></a> [kubectl](#requirement\_kubectl) | >= 1.7.0 |
125126
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 2.0.0 |
126127

127128
## Providers
128129

129130
| Name | Version |
130131
|------|---------|
132+
| <a name="provider_google"></a> [google](#provider\_google) | >= 4.42 |
131133
| <a name="provider_kubectl"></a> [kubectl](#provider\_kubectl) | >= 1.7.0 |
132134
| <a name="provider_local"></a> [local](#provider\_local) | >= 2.0.0 |
133135

@@ -142,15 +144,17 @@ No modules.
142144
| [kubectl_manifest.pv](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/resources/manifest) | resource |
143145
| [kubectl_manifest.pvc](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/resources/manifest) | resource |
144146
| [local_file.debug_file](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource |
147+
| [google_client_config.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config) | data source |
148+
| [google_container_cluster.gke_cluster](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/container_cluster) | data source |
145149

146150
## Inputs
147151

148152
| Name | Description | Type | Default | Required |
149153
|------|-------------|------|---------|:--------:|
150154
| <a name="input_capacity_gb"></a> [capacity\_gb](#input\_capacity\_gb) | The storage capacity with which to create the persistent volume. | `number` | n/a | yes |
155+
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | An identifier for the GKE cluster in the format `projects/{{project}}/locations/{{location}}/clusters/{{cluster}}` | `string` | n/a | yes |
151156
| <a name="input_filestore_id"></a> [filestore\_id](#input\_filestore\_id) | An identifier for a filestore with the format `projects/{{project}}/locations/{{location}}/instances/{{name}}`. | `string` | `null` | no |
152157
| <a name="input_gcs_bucket_name"></a> [gcs\_bucket\_name](#input\_gcs\_bucket\_name) | The gcs bucket to be used with the persistent volume. | `string` | `null` | no |
153-
| <a name="input_gke_cluster_exists"></a> [gke\_cluster\_exists](#input\_gke\_cluster\_exists) | A static flag that signals to modules that a cluster has been created. | `bool` | `false` | no |
154158
| <a name="input_labels"></a> [labels](#input\_labels) | GCE resource labels to be applied to resources. Key-value pairs. | `map(string)` | n/a | yes |
155159
| <a name="input_network_storage"></a> [network\_storage](#input\_network\_storage) | Network attached storage mount to be configured. | <pre>object({<br/> server_ip = string,<br/> remote_mount = string,<br/> local_mount = string,<br/> fs_type = string,<br/> mount_options = string,<br/> client_install_runner = map(string)<br/> mount_runner = map(string)<br/> })</pre> | n/a | yes |
156160

modules/file-system/gke-persistent-volume/main.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ locals {
7777
capacity = "${var.capacity_gb}Gi"
7878
}
7979
)
80+
81+
cluster_name = split("/", var.cluster_id)[5]
82+
cluster_location = split("/", var.cluster_id)[3]
8083
}
8184

8285
resource "local_file" "debug_file" {
@@ -87,8 +90,21 @@ resource "local_file" "debug_file" {
8790
filename = "${path.root}/pv-pvc-debug-file-${local.filestore_name}.yaml"
8891
}
8992

93+
data "google_container_cluster" "gke_cluster" {
94+
name = local.cluster_name
95+
location = local.cluster_location
96+
}
97+
98+
data "google_client_config" "default" {}
99+
100+
provider "kubectl" {
101+
host = "https://${data.google_container_cluster.gke_cluster.endpoint}"
102+
cluster_ca_certificate = base64decode(data.google_container_cluster.gke_cluster.master_auth[0].cluster_ca_certificate)
103+
token = data.google_client_config.default.access_token
104+
load_config_file = false
105+
}
106+
90107
resource "kubectl_manifest" "pv" {
91-
count = var.gke_cluster_exists ? 1 : 0
92108
yaml_body = local.is_gcs ? local.gcs_pv_contents : local.filestore_pv_contents
93109

94110
lifecycle {

modules/file-system/gke-persistent-volume/variables.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
variable "gke_cluster_exists" {
18-
description = "A static flag that signals to modules that a cluster has been created."
19-
type = bool
20-
default = false
17+
variable "cluster_id" {
18+
description = "An identifier for the GKE cluster in the format `projects/{{project}}/locations/{{location}}/clusters/{{cluster}}`"
19+
type = string
2120
}
2221

2322
variable "network_storage" {

modules/file-system/gke-persistent-volume/versions.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
terraform {
1616
required_version = ">= 1.0"
1717
required_providers {
18+
google = {
19+
source = "hashicorp/google"
20+
version = ">= 4.42"
21+
}
1822
kubectl = {
1923
source = "gavinbunney/kubectl"
2024
version = ">= 1.7.0"

0 commit comments

Comments
 (0)