Kubernetes Cluster on Google Cloud
The Google Cloud Kubernetes Cluster template scaffolds a Pulumi project that provisions a managed Google Kubernetes Engine (GKE) cluster and a node pool inside a new VPC network with a subnet. Worker nodes are deployed with private IP addresses for improved security.


Using this template#
To use this template to deploy your own Kubernetes cluster, make sure you’ve installed Pulumi and configured your Google Cloud credentials, then create a new project using the template in the language of your choice:
mkdir my-k8s-cluster && cd my-k8s-clusterpulumi new kubernetes-gcp-typescriptAlternatively, you can create and configure a new project with this template (kubernetes-gcp-typescript) in Pulumi Cloud.
mkdir my-k8s-cluster && cd my-k8s-clusterpulumi new kubernetes-gcp-pythonAlternatively, you can create and configure a new project with this template (kubernetes-gcp-python) in Pulumi Cloud.
mkdir my-k8s-cluster && cd my-k8s-clusterpulumi new kubernetes-gcp-goAlternatively, you can create and configure a new project with this template (kubernetes-gcp-go) in Pulumi Cloud.
mkdir my-k8s-cluster && cd my-k8s-clusterpulumi new kubernetes-gcp-csharpAlternatively, you can create and configure a new project with this template (kubernetes-gcp-csharp) in Pulumi Cloud.
mkdir my-k8s-cluster && cd my-k8s-clusterpulumi new kubernetes-gcp-yamlAlternatively, you can create and configure a new project with this template (kubernetes-gcp-yaml) in Pulumi Cloud.
mkdir my-k8s-cluster && cd my-k8s-clusterpulumi new kubernetes-gcp-hclAlternatively, you can create and configure a new project with this template (kubernetes-gcp-hcl) in Pulumi Cloud.
Follow the prompts to complete the new-project wizard. When it’s done, you’ll have a complete Pulumi project that’s ready to deploy and configured with the most common settings. Feel free to inspect the code in index.tsindex.js__main__.pymain.goProgram.csProgram.fsProgram.vbApp.javaPulumi.yaml for a closer look.
Deploying the project#
You must supply an existing Google Cloud project ID to deploy the cluster. You can input it through the new-project wizard. Once the project is created, you can deploy it with pulumi up:
You must supply an existing Google Cloud project ID to deploy the cluster. You can input it through the new-project wizard. Once the project is created, you can deploy it with pulumi up:
You must supply an existing Google Cloud project ID to deploy the cluster. You can input it through the new-project wizard. Once the project is created, you can deploy it with pulumi up:
You must supply an existing Google Cloud project ID to deploy the cluster. You can input it through the new-project wizard. Once the project is created, you can deploy it with pulumi up:
You must supply an existing Google Cloud project ID to deploy the cluster. You can input it through the new-project wizard. Once the project is created, you can deploy it with pulumi up:
The template deploys into your active Google Cloud project (read from your gcloud credentials) and defaults to the us-central1 region, which you can change with the region setting. Once the new project is created, you can deploy it with pulumi up:
pulumi upWhen the deployment completes, Pulumi exports the following stack output values:
- networkName
The name of the VPC network containing the Kubernetes cluster resources.
- networkId
The unique ID of the VPC network containing the Kubernetes cluster resources.
- clusterName
The name of the GKE cluster.
- clusterId
The unique ID of the GKE cluster.
- kubeconfig
The cluster’s kubeconfig file, which you can use with
kubectlto access and communicate with your cluster.
- networkName
The name of the VPC network containing the Kubernetes cluster resources.
- networkId
The unique ID of the VPC network containing the Kubernetes cluster resources.
- clusterName
The name of the GKE cluster.
- clusterId
The unique ID of the GKE cluster.
- kubeconfig
The cluster’s kubeconfig file, which you can use with
kubectlto access and communicate with your cluster.
- networkName
The name of the VPC network containing the Kubernetes cluster resources.
- networkId
The unique ID of the VPC network containing the Kubernetes cluster resources.
- clusterName
The name of the GKE cluster.
- clusterId
The unique ID of the GKE cluster.
- kubeconfig
The cluster’s kubeconfig file, which you can use with
kubectlto access and communicate with your cluster.
- networkName
The name of the VPC network containing the Kubernetes cluster resources.
- networkId
The unique ID of the VPC network containing the Kubernetes cluster resources.
- clusterName
The name of the GKE cluster.
- clusterId
The unique ID of the GKE cluster.
- kubeconfig
The cluster’s kubeconfig file, which you can use with
kubectlto access and communicate with your cluster.
- networkName
The name of the VPC network containing the Kubernetes cluster resources.
- networkId
The unique ID of the VPC network containing the Kubernetes cluster resources.
- clusterName
The name of the GKE cluster.
- clusterId
The unique ID of the GKE cluster.
- kubeconfig
The cluster’s kubeconfig file, which you can use with
kubectlto access and communicate with your cluster.
- network_name
The name of the VPC network containing the Kubernetes cluster resources.
- cluster_name
The name of the GKE cluster.
- kubeconfig
The cluster’s kubeconfig file, which you can use with
kubectlto access and communicate with your cluster.
Output values like these are useful in many ways, most commonly as inputs for other stacks or related cloud resources.
Customizing the project#
Projects created with the Kubernetes Cluster template expose the following configuration settings:
- gcp:project
The Google Cloud project ID to deploy into.
- gcp:region
The Google Cloud region to deploy into. Defaults to
us-central1.- nodesPerZone
The desired number of nodes per zone in the node pool. Defaults to
1.
- gcp:project
The Google Cloud project ID to deploy into.
- gcp:region
The Google Cloud region to deploy into. Defaults to
us-central1.- nodesPerZone
The desired number of nodes per zone in the node pool. Defaults to
1.
- gcp:project
The Google Cloud project ID to deploy into.
- gcp:region
The Google Cloud region to deploy into. Defaults to
us-central1.- nodesPerZone
The desired number of nodes per zone in the node pool. Defaults to
1.
- gcp:project
The Google Cloud project ID to deploy into.
- gcp:region
The Google Cloud region to deploy into. Defaults to
us-central1.- nodesPerZone
The desired number of nodes per zone in the node pool. Defaults to
1.
- gcp:project
The Google Cloud project ID to deploy into.
- gcp:region
The Google Cloud region to deploy into. Defaults to
us-central1.- nodesPerZone
The desired number of nodes per zone in the node pool. Defaults to
1.
- region
The Google Cloud region to deploy into. Defaults to
us-central1.- nodes_per_zone
The desired number of nodes per zone in the node pool. Defaults to
1.
All of these settings are optional and may be adjusted either by editing the stack configuration file directly (by default, Pulumi.dev.yaml) or by changing their values with pulumi config set:
pulumi config set nodesPerZone 2pulumi uppulumi config set nodesPerZone 2pulumi uppulumi config set nodesPerZone 2pulumi uppulumi config set nodesPerZone 2pulumi uppulumi config set nodesPerZone 2pulumi uppulumi config set nodes_per_zone 2pulumi upCleaning up#
You can cleanly destroy the stack and all of its infrastructure with pulumi destroy:
pulumi destroyLearn more#
- Browse other architecture templates in the Templates gallery.
- Explore the Google Cloud provider API docs in the Pulumi Registry.
- Walk through Pulumi from the ground up in Pulumi Tutorials.
- Read the latest Google Cloud posts on the Pulumi blog.