This repository contains scripts and configurations to set up a Kubernetes cluster on Google Cloud Platform (GCP) using kOps (Kubernetes Operations).
If you use just, you can configure the environment variables inside the justfile, run just init
to initialize terraform and then run just up
to create the cluster.
If you don't use just, you can run the scripts manually.
Before you begin, ensure you have the following installed:
- Terraform (v1.9.0+)
- kOps (v1.31.0+)
- kubectl
- Google Cloud SDK
-
Initialize GCP Project
# Enable required GCP APIs ./setup.sh
-
Configure GCP Authentication
gcloud auth application-default login
-
Initialize Terraform
terraform init
Enables the required Google Cloud APIs for the project:
- Cloud Resource Manager API
- Compute Engine API
- Identity and Access Management (IAM) API
- Kubernetes Engine API
- Cloud Storage API
Creates the Kubernetes cluster with the following steps:
- Creates a GCS bucket for kOps state storage
- Generates cluster configuration
- Configures instance groups with spot instances
- Creates and validates the cluster
Usage:
./up-cluster.sh <project-id>
Tears down the cluster and cleans up resources:
- Deletes the Kubernetes cluster
- Removes the GCS bucket
Usage:
./down-cluster.sh
The cluster is configured with:
- Region: europe-west1-b
- Control plane: 1 node (e2-standard-2)
- Worker nodes: 3 nodes (e2-standard-2)
- Networking: Cilium
- Instance type: Spot instances for cost optimization
After the cluster is created, you can interact with it using kubectl
. The up-cluster.sh
script automatically configures your kubeconfig.
To delete the cluster and clean up all resources:
./down-cluster.sh
- The cluster uses spot instances to optimize costs
- The GCS bucket has a 2-day retention policy
- All nodes are in a single zone for simplicity
- The cluster uses Cilium for networking