This module discovers a Google Kubernetes Engine (GKE) cluster that already exists in Google Cloud and outputs cluster attributes that uniquely identify it for use by other modules. The module outputs are aligned with the gke-cluster module so that it can be used as a drop-in substitute when a GKE cluster already exists.
The below sample blueprint discovers the existing GKE cluster named "my-gke-cluster" in "us-central1" region. With the use
keyword, the
gke-node-pool module accepts the cluser_id
input variable that uniquely identifies the existing GKE cluster in which the
GKE node pool will be created.
- id: existing-gke-cluster
source: modules/scheduler/pre-existing-gke-cluster
settings:
project_id: $(vars.project_id)
cluster_name: my-gke-cluster
region: us-central1
- id: compute_pool
source: modules/compute/gke-node-pool
use: [existing-gke-cluster]
NOTE: The
project_id
andregion
settings would be inferred from the deployment variables of the same name, but they are included here for clarity.
To create network objects in GKE cluster, you can pass a multivpc module to a pre-existing-gke-cluster module instead of applying a manifest manually.
- id: network
source: modules/network/vpc
- id: multinetwork
source: modules/network/multivpc
settings:
network_name_prefix: multivpc-net
network_count: 8
global_ip_address_range: 172.16.0.0/12
subnetwork_cidr_suffix: 16
- id: existing-gke-cluster ## multinetworking must be enabled in advance when cluster creation
source: modules/scheduler/pre-existing-gke-cluster
use: [multinetwork]
settings:
cluster_name: $(vars.deployment_name)
Copyright 2024 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Name | Version |
---|---|
terraform | >= 1.3 |
> 5.0 |
Name | Version |
---|---|
> 5.0 |
Name | Source | Version |
---|---|---|
kubectl_apply | ../../management/kubectl-apply | n/a |
Name | Type |
---|---|
google_container_cluster.existing_gke_cluster | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
additional_networks | Additional network interface details for GKE, if any. Providing additional networks creates relevat network objects on the cluster. | list(object({ |
[] |
no |
cluster_name | Name of the existing cluster | string |
n/a | yes |
project_id | Project that hosts the existing cluster | string |
n/a | yes |
region | Region in which to search for the cluster | string |
n/a | yes |
Name | Description |
---|---|
cluster_id | An identifier for the gke cluster with format projects/{{project_id}}/locations/{{region}}/clusters/{{name}}. |
gke_cluster_exists | A static flag that signals to downstream modules that a cluster exists. |
gke_version | GKE cluster's version. |