Skip to content

Commit 366a940

Browse files
committed
Refactored workloads and Kubernetes manifest actions (#119)
1 parent da6d336 commit 366a940

File tree

90 files changed

+2562
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2562
-133
lines changed

.github/workflows/dictionary/terraform.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
abspath
22
cidrhost
3+
direxists
34
endfor
45
filemd
56
fileset

platforms/gke/base/_shared_config/cluster_variables.tf

+7-10
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
#
1919

2020
locals {
21-
cluster_credentials_command_private = "gcloud container clusters get-credentials ${local.cluster_name} --internal-ip --location ${var.cluster_region} --project ${var.cluster_project_id}"
22-
cluster_credentials_command_public = "gcloud container clusters get-credentials ${local.cluster_name} --location ${var.cluster_region} --project ${var.cluster_project_id}"
23-
cluster_credentials_command_gke = var.cluster_enable_private_endpoint ? local.cluster_credentials_command_private : local.cluster_credentials_command_public
24-
cluster_credentials_command_gkee = "gcloud container fleet memberships get-credentials ${local.cluster_name} --project ${var.cluster_project_id}"
25-
cluster_credentials_command = var.cluster_use_connect_gateway ? local.cluster_credentials_command_gkee : local.cluster_credentials_command_gke
21+
cluster_credentials_command_gke = "gcloud container clusters get-credentials ${local.cluster_name} --dns-endpoint --location ${var.cluster_region} --project ${var.cluster_project_id}"
22+
cluster_credentials_command_gkee = "gcloud container fleet memberships get-credentials ${local.cluster_name} --project ${var.cluster_project_id}"
23+
cluster_credentials_command = var.cluster_use_connect_gateway ? local.cluster_credentials_command_gkee : local.cluster_credentials_command_gke
2624

2725
cluster_name = local.unique_identifier_prefix
2826

@@ -31,9 +29,6 @@ locals {
3129
cluster_node_pool_service_account_id = var.cluster_node_pool_default_service_account_id != null ? var.cluster_node_pool_default_service_account_id : "vm-${local.cluster_name}"
3230
cluster_node_pool_service_account_project_id = var.cluster_node_pool_default_service_account_project_id != null ? var.cluster_node_pool_default_service_account_project_id : var.cluster_project_id
3331

34-
kubeconfig_directory = abspath("${path.module}/../kubeconfig")
35-
kubeconfig_file = abspath("${local.kubeconfig_directory}/${var.cluster_project_id}-${local.unique_identifier_prefix}")
36-
3732
# Minimal roles for nodepool SA https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#use_least_privilege_sa
3833
cluster_sa_roles = [
3934
"roles/artifactregistry.reader",
@@ -44,6 +39,8 @@ locals {
4439
"roles/serviceusage.serviceUsageConsumer",
4540
"roles/stackdriver.resourceMetadata.writer",
4641
]
42+
43+
kubeconfig_file_name = "${var.cluster_project_id}-${local.cluster_name}"
4744
}
4845

4946
variable "cluster_binary_authorization_evaluation_mode" {
@@ -231,7 +228,7 @@ variable "cluster_system_node_pool_machine_type" {
231228
}
232229

233230
variable "cluster_use_connect_gateway" {
234-
default = true
235-
description = "Use Connect gateway to connect to the cluster, require GKE Enterprise. (https://cloud.google.com/kubernetes-engine/enterprise/multicluster-management/gateway)"
231+
default = false
232+
description = "Use Connect gateway to connect to the cluster, requires GKE Enterprise. (https://cloud.google.com/kubernetes-engine/enterprise/multicluster-management/gateway)"
236233
type = bool
237234
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
SHARED_CONFIG_DIRECTORY=${1}
22+
SHARED_CONFIG_NAME=${2}
23+
24+
if [[ ${SHARED_CONFIG_DIRECTORY} != \.* ]]; then
25+
echo "The shared config directory path must be a relative path!"
26+
exit 1
27+
fi
28+
29+
if test ! -d "${SHARED_CONFIG_DIRECTORY}"; then
30+
echo "Shared config directory '${SHARED_CONFIG_DIRECTORY}' does not exist!"
31+
exit 2
32+
fi
33+
34+
if test ! -f "${SHARED_CONFIG_DIRECTORY}/${SHARED_CONFIG_NAME}_variables.tf"; then
35+
echo "Shared config '${SHARED_CONFIG_NAME}' does not exist in '${SHARED_CONFIG_DIRECTORY}'!"
36+
exit 3
37+
fi
38+
39+
ln -s ${SHARED_CONFIG_DIRECTORY}/${SHARED_CONFIG_NAME}_variables.tf _${SHARED_CONFIG_NAME}_variables.tf
40+
ln -s ${SHARED_CONFIG_DIRECTORY}/${SHARED_CONFIG_NAME}.auto.tfvars _${SHARED_CONFIG_NAME}.auto.tfvars
41+
42+
echo "Successfully linked shared config '${SHARED_CONFIG_NAME}' from '${SHARED_CONFIG_DIRECTORY}'."

platforms/gke/base/_shared_config/workloads_variables.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
#
1818

1919
locals {
20-
manifests_directory = abspath("${path.module}/../manifests")
20+
manifests_directory_root = "${path.module}/../../../kubernetes/manifests"
2121
}
2222

2323
variable "kueue_version" {
24-
default = "0.10.0"
24+
default = "0.10.2"
2525
description = "Version of Kueue (https://kueue.sigs.k8s.io/) to install."
2626
type = string
2727
}

platforms/gke/base/core/deploy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ else
3535
"gke_enterprise/fleet_membership"
3636
# Disable gke_enterprise/servicemesh due to b/376312292
3737
# "gke_enterprise/servicemesh"
38+
"workloads/cluster_credentials"
3839
"workloads/kueue"
3940
)
4041
fi

platforms/gke/base/core/workloads/cluster_credentials/.terraform.lock.hcl

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../_shared_config/cluster.auto.tfvars
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../_shared_config/cluster_variables.tf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../_shared_config/platform.auto.tfvars
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../_shared_config/platform_variables.tf
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Google LLC
1+
# Copyright 2025 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,24 +12,34 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
resource "null_resource" "cluster_credentials" {
15+
locals {
16+
kubeconfig_directory = "${path.module}/../../../kubernetes/kubeconfig"
17+
kubeconfig_file = "${local.kubeconfig_directory}/${local.kubeconfig_file_name}"
18+
}
19+
20+
resource "terraform_data" "cluster_credentials" {
21+
input = {
22+
cluster_credentials_command = local.cluster_credentials_command
23+
kubeconfig_file = local.kubeconfig_file
24+
}
25+
1626
provisioner "local-exec" {
1727
command = <<EOT
18-
KUBECONFIG=${self.triggers.kubeconfig_file} ${local.cluster_credentials_command}
28+
mkdir -p $(dirname ${self.input.kubeconfig_file})
29+
KUBECONFIG=${self.input.kubeconfig_file} ${self.input.cluster_credentials_command}
1930
EOT
2031
interpreter = ["bash", "-c"]
2132
working_dir = path.module
2233
}
2334

2435
provisioner "local-exec" {
25-
command = "rm -rf ${self.triggers.kubeconfig_file}"
36+
command = "rm -rf ${self.input.kubeconfig_file}"
2637
interpreter = ["bash", "-c"]
2738
when = destroy
2839
working_dir = path.module
2940
}
3041

31-
triggers = {
32-
always_run = timestamp()
33-
kubeconfig_file = local.kubeconfig_file
42+
triggers_replace = {
43+
always_run = timestamp()
3444
}
3545
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
terraform {
16+
required_version = ">= 1.5.7"
17+
18+
required_providers {
19+
}
20+
21+
provider_meta "google" {
22+
module_name = "cloud-solutions/acp_gke_base_core_workloads_cluster-credentials_deploy-v1"
23+
}
24+
}

platforms/gke/base/core/workloads/kueue/.terraform.lock.hcl

+15-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platforms/gke/base/core/workloads/kueue/kueue.tf

-75
This file was deleted.

0 commit comments

Comments
 (0)