A GitHub template that could be used to get started with Google Kubernetes Engine(GKE) using terraform.
- Google Cloud Account
- With a Service Account with roles
Kubernetes Engine Admin
- to create GKE clusterService Account User
- to use other needed service accountsCompute Network Admin
- to create the VPC networks
- With a Service Account with roles
- Google Cloud SDK
- terraform
- helm(Optional)
- kustomize(Optional)
- direnv(Optional)
On browser navigate to the repo https://github.com/kameshsampath/gke-tf and click Use Template, follow the wizard to create your repository based on the template.
Using github cli
gh repo create --public --description="My GKE Demos and Examples" --template https://github.com/kameshsampath/gke-tf my-gke-demos
gh repo clone my-gke-demos
When working with Google Cloud the following environment variables helps in setting the right Google Cloud context like Service Account Key file, project etc., You can use direnv or set the following variables on your shell,
export GOOGLE_APPLICATION_CREDENTIALS="the google cloud service account key json file to use"
export CLOUDSDK_ACTIVE_CONFIG_NAME="the google cloud cli profile to use"
You can find more information about gcloud cli configurations at https://cloud.google.com/sdk/docs/configurations.
As you may need to override few terraform variables that you don't want to check in to VCS, add them to a file called <name>.local.tfvars
and set the following environment variable to be picked up by terraform runs,
export TFVARS_FILE=<name>.local.tfvars
NOTE: All
.local.tfvars
file are git ignored by this template.
Name | Description | Type | Default | Required |
---|---|---|---|---|
cluster_name | the gke cluster name | string |
"my-demos" |
no |
gke_num_nodes | number of gke nodes | number |
2 |
no |
kubernetes_version | the kubernetes versions of the GKE clusters | string |
"1.24." |
no |
machine_type | the google cloud machine types for each cluster node | string |
"e2-standard-4" |
no |
project_id | project id | any |
n/a | yes |
region | the region or zone where the cluster will be created | string |
"asia-south1" |
no |
release_channel | the GKE release channel to use | string |
"stable" |
no |
Name | Description |
---|---|
kubeconfig_path | Kubeconfig file |
kubernetes_cluster_host | GKE Cluster Host |
kubernetes_cluster_name | GKE Cluster Name |
project_id | GCloud Project ID |
region | GCloud Region |
zone | GCloud Zone |
Name | Version |
---|---|
4.47.0 | |
local | 2.2.3 |
random | 3.4.3 |
Name | Version |
---|---|
terraform | >= 0.14 |
>= 4.47.0 | |
helm | 2.8.0 |
kubernetes | 2.16.1 |
local | 2.2.3 |
random | 3.4.3 |
Name | Type |
---|---|
google_compute_network.vpc | resource |
google_compute_subnetwork.subnet | resource |
google_container_cluster.primary | resource |
google_container_node_pool.primary_nodes | resource |
local_file.kubeconfig | resource |
random_shuffle.az | resource |
google_compute_zones.available | data source |
google_container_engine_versions.supported | data source |