Skip to content

Latest commit

 

History

History
115 lines (86 loc) · 5.23 KB

File metadata and controls

115 lines (86 loc) · 5.23 KB

Description

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.

Example

- 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 and region settings would be inferred from the deployment variables of the same name, but they are included here for clarity.

Multi-networking

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)

License

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.

Requirements

Name Version
terraform >= 1.3
google > 5.0

Providers

Name Version
google > 5.0

Modules

Name Source Version
kubectl_apply ../../management/kubectl-apply n/a

Resources

Name Type
google_container_cluster.existing_gke_cluster data source

Inputs

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({
network = string
subnetwork = string
subnetwork_project = string
network_ip = string
nic_type = string
stack_type = string
queue_count = number
access_config = list(object({
nat_ip = string
network_tier = string
}))
ipv6_access_config = list(object({
network_tier = string
}))
alias_ip_range = list(object({
ip_cidr_range = string
subnetwork_range_name = string
}))
}))
[] 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

Outputs

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.