Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.96 KB

README.md

File metadata and controls

59 lines (43 loc) · 1.96 KB

Pulumi gcloud k8s

Create a kubernetes cluster on gcloud then deploy an app on that cluster using pulumi.

Based on following docs:

Setup

  • gcloud and pulumi CLIs (I install them with asdf, namely asdf-pulumi, asdf-gcloud)

  • gcloud setup: need to set project and default application credentials, and enable some apis

    google auth application-default login
    google config set account <mail address>
    google project create --name <project name>
    google config set project <project id>
    
    gcloud services enable container.googleapis.com
    gcloud services enable compute.googleapis.com
    gcloud services enable compute.networks.create
  • set project and region pulumi gcp config values

    pulumi config set gcp:project $(gcloud config get core/project)
    pulumi config set gcp:region <region>

Deploy

pulumi up

Kubeconfig

A pulumi provider is created for our newly created k8s cluster by passing the kubeconfig to it.
So theoretically, no need to export kubeconfig locally unless you want to use kubectl directly. In this case you can export kubeconfig locally: To export kubeconfig nonetheless, run:

pulumi stack output --show-secrets kubeconfig > .kubeconfig

Then make sure this file is part of your $KUBECONFIG because pulumi looks for a kubeconfig file at the location defined by $KUBECONFIG first.
Ex:

export KUBECONFIG=$KUBECONFIG:.kubeconfig

Access/Test the app

curl $(pulumi stack output ip)