Skip to content

Latest commit

 

History

History
91 lines (69 loc) · 2.39 KB

Readme.md

File metadata and controls

91 lines (69 loc) · 2.39 KB

GCP Kubernetes Cluster with kOps

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.

Prerequisites

Before you begin, ensure you have the following installed:

Setup Instructions

  1. Initialize GCP Project

    # Enable required GCP APIs
    ./setup.sh
  2. Configure GCP Authentication

    gcloud auth application-default login
  3. Initialize Terraform

    terraform init

Available Scripts

setup.sh

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

up-cluster.sh

Creates the Kubernetes cluster with the following steps:

  1. Creates a GCS bucket for kOps state storage
  2. Generates cluster configuration
  3. Configures instance groups with spot instances
  4. Creates and validates the cluster

Usage:

./up-cluster.sh <project-id>

down-cluster.sh

Tears down the cluster and cleans up resources:

  1. Deletes the Kubernetes cluster
  2. Removes the GCS bucket

Usage:

./down-cluster.sh

Cluster Configuration

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

Working with Your Cluster

After the cluster is created, you can interact with it using kubectl. The up-cluster.sh script automatically configures your kubeconfig.

Cleanup

To delete the cluster and clean up all resources:

./down-cluster.sh

Important Notes

  • 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