Skip to content

A sample project for creating a Kubernetes Cluster in Google Cloud using Pulumi

License

Notifications You must be signed in to change notification settings

d0-labs/pulumi-gke-example

Repository files navigation

Pulumi GKE Sample

The purpose of this repo is to use the Pulumi Python runtime (>= Python 3.7) to create a GKE cluster in Google Cloud.

It is based on the instructions found here.

NOTE: The Pulumi docs are based on the Terraform docs, so that comes in very handy if you can't make heads or tails of the crappy Pulumi docs. See references section below for more info.

Pre-requisites

Getting Started

  1. Install Pulumi and Python using Homebrew:

    brew install pulumi
    brew install python
  2. Set up the Python virtual environment:

    pip install --upgrade --force-reinstall virtualenv
    virtualenv venv
    source  venv/bin/activate
    python -m pip install --upgrade pip
    pip install --upgrade --force-reinstall -r requirements.txt
  3. Create the new Pulumi stack using the Pulumi service:

    This example assumes that you're using app.pulumi.com to store your stack. As a pre-requisite, you'll get set up here. The service is free for personal use.

    pulumi stack init dev

    This will create a new file named Pulumi.dev.yaml.

  4. Set up Pulumi configs for Google Cloud

    pulumi config set gcp:project <your_project_name>
    pulumi config set gcp:region <region>
    pulumi config set gcp:zone <zone>

    These will be added to Pulumi.dev.yaml

  5. Set up the gcloud service account:

    This section assumes that you already have a GCP service account set up:

    # Login to gcloud using the service account
    gcloud auth activate-service-account <service_account_name>@<gcp_project_name>.iam.gserviceaccount.com --key-file=<service_account_key>.json
    
    # Set the GOOGLE_CREDENTIALS environment variable - Pulumi uses this for service account auth
    export GOOGLE_CREDENTIALS=$(cat <service_account_key>.json)

    References:

  6. Run Pulumi to provision/destroy your infrastructure

    # Create cluster
    pulumi up
    
    # Preview changes
    pulumi preview
    
    # Destroy cluster
    pulumi destroy
    
    # Destroy the stack
    pulumi stack rm

References

About

A sample project for creating a Kubernetes Cluster in Google Cloud using Pulumi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages