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.
-
Install Pulumi and Python using Homebrew:
brew install pulumi brew install python
-
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
-
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
. -
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
-
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:
-
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