Skip to content

Commit 444bc98

Browse files
committed
Initial implementation of the base platform (#24)
1 parent 974f2ef commit 444bc98

File tree

139 files changed

+6006
-0
lines changed

Some content is hidden

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

139 files changed

+6006
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# IDEs
2+
.vscode/
23
*.code-workspace
34

45
# Python
@@ -7,6 +8,7 @@ __pycache__/
78
venv/
89

910
# Terraform
11+
**/tfplan
1012
*.terraform/
1113
*.terraform-*/
1214
*.terraform.lock.hcl

platforms/gke/base/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Base GKE Accelerated Platform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Copyright 2024 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+
#
16+
# Configuration dependencies
17+
# - shared_config/platform_variables.tf
18+
#
19+
20+
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
26+
cluster_name = local.unique_identifier_prefix
27+
28+
kubeconfig_directory = abspath("${path.module}/../kubeconfig")
29+
kubeconfig_file = abspath("${local.kubeconfig_directory}/${var.cluster_project_id}-${local.unique_identifier_prefix}")
30+
}
31+
32+
variable "cluster_binary_authorization_evaluation_mode" {
33+
default = "DISABLED"
34+
description = "Mode of operation for Binary Authorization policy evaluation. Valid values are DISABLED and PROJECT_SINGLETON_POLICY_ENFORCE."
35+
type = string
36+
37+
validation {
38+
condition = contains(
39+
[
40+
"DISABLED",
41+
"PROJECT_SINGLETON_POLICY_ENFORCE",
42+
],
43+
var.cluster_binary_authorization_evaluation_mode
44+
)
45+
error_message = "'cluster_binary_authorization_evaluation_mode' value is invalid"
46+
}
47+
}
48+
49+
variable "cluster_confidential_nodes_enabled" {
50+
default = false
51+
description = "Enable Confidential GKE Nodes for this node pool, to enforce encryption of data in-use"
52+
type = bool
53+
}
54+
55+
variable "cluster_database_encryption_state" {
56+
default = "DECRYPTED"
57+
description = "The desired state of etcd encryption. ENCRYPTED or DECRYPTED"
58+
type = string
59+
60+
validation {
61+
condition = contains(
62+
[
63+
"DECRYPTED",
64+
"ENCRYPTED",
65+
],
66+
var.cluster_database_encryption_state
67+
)
68+
error_message = "'cluster_database_encryption_state' value is invalid"
69+
}
70+
}
71+
72+
variable "cluster_database_encryption_key_name" {
73+
default = null
74+
description = "Name of CloudKMS key to use for the encryption of secrets in etcd. Ex. projects/my-project/locations/global/keyRings/my-ring/cryptoKeys/my-key"
75+
type = string
76+
}
77+
78+
variable "cluster_enable_private_endpoint" {
79+
default = true
80+
description = "When true, the cluster's private endpoint is used as the cluster endpoint and access through the public endpoint is disabled. When false, either endpoint can be used. This field only applies to private clusters, when enable_private_nodes is true."
81+
type = bool
82+
}
83+
84+
variable "cluster_gateway_api_config_channel" {
85+
default = "CHANNEL_STANDARD"
86+
description = "Which Gateway Api channel should be used. CHANNEL_DISABLED, CHANNEL_EXPERIMENTAL or CHANNEL_STANDARD"
87+
type = string
88+
89+
validation {
90+
condition = contains(
91+
[
92+
"CHANNEL_DISABLED",
93+
"CHANNEL_EXPERIMENTAL",
94+
"CHANNEL_STANDARD",
95+
],
96+
var.cluster_gateway_api_config_channel
97+
)
98+
error_message = "'cluster_gateway_api_config_channel' value is invalid"
99+
}
100+
}
101+
102+
variable "cluster_gpu_driver_version" {
103+
default = "LATEST"
104+
description = "Mode for how the GPU driver is installed."
105+
type = string
106+
107+
validation {
108+
condition = contains(
109+
[
110+
"DEFAULT",
111+
"GPU_DRIVER_VERSION_UNSPECIFIED",
112+
"INSTALLATION_DISABLED",
113+
"LATEST"
114+
],
115+
var.cluster_gpu_driver_version
116+
)
117+
error_message = "'gpu_driver_version' value is invalid"
118+
}
119+
}
120+
121+
variable "cluster_master_global_access_enabled" {
122+
default = false
123+
description = "Whether the cluster master is accessible globally or not."
124+
type = bool
125+
}
126+
127+
variable "cluster_project_id" {
128+
description = "The GCP project where the cluster resources will be created"
129+
type = string
130+
131+
validation {
132+
condition = var.cluster_project_id != ""
133+
error_message = "'cluster_project_id' was not set, please set the value in the mlp.auto.tfvars file"
134+
}
135+
}
136+
137+
variable "cluster_region" {
138+
default = "us-central1"
139+
description = "Region where cluster resources will be created."
140+
type = string
141+
142+
validation {
143+
condition = contains(
144+
[
145+
"us-central1",
146+
"us-east4",
147+
],
148+
var.cluster_region)
149+
error_message = "'cluster_region' must be one of ['us-central1', 'us-east4']"
150+
}
151+
}
152+
153+
variable "cluster_use_connect_gateway" {
154+
default = true
155+
description = "UsevConnect gateway to connect to the cluster, require GKE Enterprise."
156+
type = bool
157+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2024 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+
#
16+
# Configuration dependencies
17+
# - shared_config/platform_variables.tf
18+
#
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2024 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+
#
16+
# Configuration dependencies
17+
# - shared_config/platform_variables.tf
18+
#
19+
20+
locals {
21+
network_name = var.network_name != null ? var.network_name : local.unique_identifier_prefix
22+
subnetwork_name = var.subnetwork_name != null ? var.subnetwork_name : local.unique_identifier_prefix
23+
}
24+
25+
variable "dynamic_routing_mode" {
26+
default = "GLOBAL"
27+
description = "VPC dynamic routing mode"
28+
type = string
29+
}
30+
31+
variable "network_name" {
32+
default = null
33+
description = "Name of the VPC network"
34+
type = string
35+
}
36+
37+
variable "subnet_cidr_range" {
38+
default = "10.40.0.0/22"
39+
description = "CIDR range for the regional subnet"
40+
type = string
41+
}
42+
43+
variable "subnetwork_name" {
44+
default = null
45+
description = "Name of the regional subnet"
46+
type = string
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2024 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+
output "cluster_name" {
16+
value = local.cluster_name
17+
}
18+
19+
output "cluster_project_id" {
20+
value = var.cluster_project_id
21+
}
22+
23+
output "platform_name" {
24+
value = var.platform_name
25+
}
26+
27+
output "terraform_bucket_name" {
28+
value = local.terraform_bucket_name
29+
}
30+
31+
output "terraform_project_id" {
32+
value = var.terraform_project_id
33+
}
34+
35+
output "resource_name_prefix" {
36+
value = var.resource_name_prefix
37+
}
38+
39+
output "unique_identifier_prefix" {
40+
value = local.unique_identifier_prefix
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2024 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+
#
16+
# Configuration dependencies
17+
# - shared_config/platform_variables.tf
18+
#
19+
20+
locals {
21+
unique_identifier_prefix = "${var.resource_name_prefix}-${var.platform_name}"
22+
}
23+
24+
variable "platform_name" {
25+
default = "dev"
26+
description = "Name of the environment"
27+
type = string
28+
}
29+
30+
variable "resource_name_prefix" {
31+
default = "acp"
32+
description = "The prefix to add before each resource's name"
33+
type = string
34+
}

0 commit comments

Comments
 (0)