This terraform repo will deploy a single node (by default) GKE cluster for quick LAB purposes. Available in 2 versions:
- Plain GKE cluster
- GKE cluster with Gitlab K8s agent integration
The following tools must exist on the machine where the terraform will be executed:
- gcloud CLI
- gke-gcloud-auth-plugin
For lazy hands:
# Install Gcloud for Debian/Ubuntu
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-cli kubectl jq -y
sudo gcloud components install gke-gcloud-auth-plugin
To authenticate to Gcloud:
# Using your user
gcloud init
# Then
gcloud auth application-default login
- Authenticate
gcloud
- Create a
terraform.tfvars
file (example) and fill the required input variables - Do
terraform init
- Plan and apply
- Create a Gitlab Agent for Kubernetes, and retrieve the token.
- Same steps with the GKE Only
terraform.tfvars
project_id = "default-project"
region = "asia-southeast2"
zone = "asia-southeast2-a"
machine_type = "e2-small"
For Gitlab K8s agent setup, include the required variables:
agent_namespace = "gitlab-agent"
agent_token = abcdef123456789
agent_kas_address = wss://gitlab.com/-/kubernetes-agent/"
Name | Description | Type | Default | Required |
---|---|---|---|---|
project_id | GCP Project ID | string | n/a | yes |
region | GCP Project region | string | "asia-southeast2" | yes |
zone | GCP Project zone | string | "asia-southeast2-b" | yes |
machine_type | GKE Node Machine type | string | "e2-medium" | yes |
node_count | GKE node count | int | 1 | yes |
is_preemptible_node_pool | Whether the nodepool is preemptible or not | bool | true | yes |
agent_namespace | Gitlab agent namespace | string | "gitlab-agent" | yes in gitlab k8s agent |
agent_token | Gitlab agent token | string | n/a | yes in gitlab k8s agent |
kas_address | KAS address | string | n/a | yes in gitlab k8s agent |