Helm Chart on Kubernetes
The Helm Chart template scaffolds a Pulumi project that deploys a Helm chart to an existing Kubernetes cluster using Pulumi’s Kubernetes provider. The template creates a new namespace in the cluster and installs an Nginx ingress controller as the default chart, so the project deploys end to end out of the box.
Before you begin#
- The Pulumi CLI
- Access to a Kubernetes cluster. No cluster yet? Run one locally with kind, minikube or Docker Desktop's built-in Kubernetes, or create a managed one with a Kubernetes cluster template
- kubectl installed and configured for your cluster
- The Pulumi CLI
- Access to a Kubernetes cluster. No cluster yet? Run one locally with kind, minikube or Docker Desktop's built-in Kubernetes, or create a managed one with a Kubernetes cluster template
- kubectl installed and configured for your cluster
- The Pulumi CLI
- Access to a Kubernetes cluster. No cluster yet? Run one locally with kind, minikube or Docker Desktop's built-in Kubernetes, or create a managed one with a Kubernetes cluster template
- kubectl installed and configured for your cluster
- Go installed locally
- The Pulumi CLI
- Access to a Kubernetes cluster. No cluster yet? Run one locally with kind, minikube or Docker Desktop's built-in Kubernetes, or create a managed one with a Kubernetes cluster template
- kubectl installed and configured for your cluster
- .NET installed locally
- The Pulumi CLI
- Access to a Kubernetes cluster. No cluster yet? Run one locally with kind, minikube or Docker Desktop's built-in Kubernetes, or create a managed one with a Kubernetes cluster template
- kubectl installed and configured for your cluster
- The Pulumi CLI v3.256.0 or later; Pulumi HCL needs no separate language runtime
- Access to a Kubernetes cluster. No cluster yet? Run one locally with kind, minikube or Docker Desktop's built-in Kubernetes, or create a managed one with a Kubernetes cluster template
- kubectl installed and configured for your cluster
Create a new project#
Create a new project using the template in the language of your choice:
mkdir my-k8s-app && cd my-k8s-apppulumi new helm-kubernetes-typescriptmkdir my-k8s-app && cd my-k8s-apppulumi new helm-kubernetes-pythonmkdir my-k8s-app && cd my-k8s-apppulumi new helm-kubernetes-gomkdir my-k8s-app && cd my-k8s-apppulumi new helm-kubernetes-csharpmkdir my-k8s-app && cd my-k8s-apppulumi new helm-kubernetes-yamlmkdir my-k8s-app && cd my-k8s-apppulumi new helm-kubernetes-hclpulumi new walks you through creating and configuring a new project and stack. A stack is an instance of a project and you can have many of them — dev, staging, prod — each with its own configuration settings.
Then it asks for the template’s setting:
| Key | Description | Default |
|---|---|---|
| k8sNamespace | The Kubernetes namespace to deploy into | nginx-ingress |
pulumi config set:
pulumi config set k8sNamespace <value>| Key | Description | Default |
|---|---|---|
| k8sNamespace | The Kubernetes namespace to deploy into | nginx-ingress |
pulumi config set:
pulumi config set k8sNamespace <value>| Key | Description | Default |
|---|---|---|
| k8sNamespace | The Kubernetes namespace to deploy into | nginx-ingress |
pulumi config set:
pulumi config set k8sNamespace <value>| Key | Description | Default |
|---|---|---|
| k8sNamespace | The Kubernetes namespace to deploy into | nginx-ingress |
pulumi config set:
pulumi config set k8sNamespace <value>| Key | Description | Default |
|---|---|---|
| k8sNamespace | The Kubernetes namespace to deploy into | nginx-ingress |
pulumi config set:
pulumi config set k8sNamespace <value>| Key | Description | Default |
|---|---|---|
| k8s_namespace | The Kubernetes namespace to deploy into | nginx-ingress |
pulumi config set:
pulumi config set k8s_namespace <value>When setup completes, you’ll see a few key files:
Pulumi.yamlnames the project and the language it’s written in.Pulumi.dev.yamlholds thedevstack’s settings, including the values you just entered.index.tsindex.js__main__.pymain.goProgram.csProgram.fsProgram.vbApp.javaPulumi.yamlmain.tfis the program: the code that declares your Kubernetes resources.
When setup completes, you’ll see a few key files:
Pulumi.yamlnames the project and the language it’s written in.Pulumi.dev.yamlholds thedevstack’s settings, including the values you just entered.index.tsindex.js__main__.pymain.goProgram.csProgram.fsProgram.vbApp.javaPulumi.yamlmain.tfis the program: the code that declares your Kubernetes resources.
When setup completes, you’ll see a few key files:
Pulumi.yamlnames the project and the language it’s written in.Pulumi.dev.yamlholds thedevstack’s settings, including the values you just entered.index.tsindex.js__main__.pymain.goProgram.csProgram.fsProgram.vbApp.javaPulumi.yamlmain.tfis the program: the code that declares your Kubernetes resources.
When setup completes, you’ll see a few key files:
Pulumi.yamlnames the project and the language it’s written in.Pulumi.dev.yamlholds thedevstack’s settings, including the values you just entered.index.tsindex.js__main__.pymain.goProgram.csProgram.fsProgram.vbApp.javaPulumi.yamlmain.tfis the program: the code that declares your Kubernetes resources.
When setup completes, you’ll see a few key files:
Pulumi.yamlnames the project and holds the program: the resources it declares.Pulumi.dev.yamlholds thedevstack’s settings, including the values you just entered.
When setup completes, you’ll see a few key files:
Pulumi.yamlnames the project and the language it’s written in.Pulumi.dev.yamlholds thedevstack’s settings, including the values you just entered.index.tsindex.js__main__.pymain.goProgram.csProgram.fsProgram.vbApp.javaPulumi.yamlmain.tfis the program: the code that declares your Kubernetes resources.
Deploy the project#
The program installs the chart into the cluster your current kubeconfig context points at. Check which cluster that is before you deploy:
kubectl config current-contextDeploy with pulumi up. It starts with a preview of what it’s about to create and asks before it changes anything. Choose yes to deploy.
pulumi upPulumi adds a random suffix to most resource names, so the Helm release ingresscontroller becomes something like ingresscontroller-4f8a2c1d. This is autonaming. It lets you deploy the same program to more than one stack, and lets Pulumi create a replacement before it deletes the old resource, without names colliding. The namespace is the exception: the program names it from k8sNamespace, so it’s called exactly what you entered (nginx-ingress by default).
Pulumi adds a random suffix to most resource names, so the Helm release ingresscontroller becomes something like ingresscontroller-4f8a2c1d. This is autonaming. It lets you deploy the same program to more than one stack, and lets Pulumi create a replacement before it deletes the old resource, without names colliding. The namespace is the exception: the program names it from k8sNamespace, so it’s called exactly what you entered (nginx-ingress by default).
Pulumi adds a random suffix to most resource names, so the Helm release ingresscontroller becomes something like ingresscontroller-4f8a2c1d. This is autonaming. It lets you deploy the same program to more than one stack, and lets Pulumi create a replacement before it deletes the old resource, without names colliding. The namespace is the exception: the program names it from k8sNamespace, so it’s called exactly what you entered (nginx-ingress by default).
Pulumi adds a random suffix to most resource names, so the Helm release ingresscontroller becomes something like ingresscontroller-4f8a2c1d. This is autonaming. It lets you deploy the same program to more than one stack, and lets Pulumi create a replacement before it deletes the old resource, without names colliding. The namespace is the exception: the program names it from k8sNamespace, so it’s called exactly what you entered (nginx-ingress by default).
Pulumi adds a random suffix to most resource names, so the Helm release ingresscontroller becomes something like ingresscontroller-4f8a2c1d. This is autonaming. It lets you deploy the same program to more than one stack, and lets Pulumi create a replacement before it deletes the old resource, without names colliding. The namespace is the exception: the program names it from k8sNamespace, so it’s called exactly what you entered (nginx-ingress by default).
Pulumi usually adds a random suffix to resource names, called autonaming, so the same program can deploy to more than one stack without names colliding. This program sets both names itself: the namespace is named from k8s_namespace and the Helm release is called ingresscontroller. To run a second stack in the same cluster, give it a different namespace.
When it finishes, Pulumi prints the stack’s outputs, values it only knows once the resources exist:
- name
The name of your new Helm chart deployment.
Read one any time with pulumi stack output <name>, or pass it to another command. To check the result, list the pods in the namespace (use yours if you didn’t keep nginx-ingress). The ingress controller’s pod shows Running once it’s up:
kubectl get pods -n nginx-ingressCustomize the project#
Projects created with the Helm Chart template expose the following configuration settings:
- k8sNamespace
The name of the namespace to be created in your existing cluster. Defaults to
nginx-ingress.
- k8sNamespace
The name of the namespace to be created in your existing cluster. Defaults to
nginx-ingress.
- k8sNamespace
The name of the namespace to be created in your existing cluster. Defaults to
nginx-ingress.
- k8sNamespace
The name of the namespace to be created in your existing cluster. Defaults to
nginx-ingress.
- k8sNamespace
The name of the namespace to be created in your existing cluster. Defaults to
nginx-ingress.
- k8s_namespace
The name of the namespace to be created in your existing cluster. Defaults to
nginx-ingress.
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. For example, move the chart to a namespace called my-namespace:
pulumi config set k8sNamespace my-namespacepulumi uppulumi config set k8sNamespace my-namespacepulumi uppulumi config set k8sNamespace my-namespacepulumi uppulumi config set k8sNamespace my-namespacepulumi uppulumi config set k8sNamespace my-namespacepulumi uppulumi config set k8s_namespace my-namespacepulumi upPulumi installs the chart in the new namespace and deletes the old one. The controller’s pod now runs in my-namespace:
kubectl get pods -n my-namespaceYou can customize the Helm chart by passing values to it in your Pulumi code. An example of passing a few values to the chart is included in the template for reference.
To see what else you can add, browse the Kubernetes provider in the Pulumi Registry.
Cleaning 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 Kubernetes provider API docs in the Pulumi Registry.
- Walk through Pulumi from the ground up in Pulumi Tutorials.
- Read the latest Kubernetes posts on the Pulumi blog.