Create a kubernetes cluster on gcloud then deploy an app on that cluster using pulumi.
Based on following docs:
- pulumi GKE template
- pulumi kubernetes get started
- access a kubernetes cluster using a pulumi provider
-
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
andregion
pulumi gcp config valuespulumi config set gcp:project $(gcloud config get core/project) pulumi config set gcp:region <region>
pulumi up
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
curl $(pulumi stack output ip)