1. Answers
  2. Deploying Helm Charts on Kubernetes Using Pulumi

How Do I Deploy a Helm Chart in Kubernetes Using Pulumi

Introduction

In this guide, we’ll explore how to deploy Helm charts on Kubernetes using Pulumi. Helm is a package manager for Kubernetes that simplifies the deployment of complex applications. We’ll focus on using the Chart resource, which offers enhanced visibility and control over the deployed resources.

Step-by-Step Explanation

Step 1: Prerequisites

Before starting, ensure you have:

  • Pulumi CLI installed
  • A Kubernetes cluster
  • kubectl configured
  • Helm installed locally

Step 2: Create a New Pulumi Project

  1. Create a new Pulumi project using the Kubernetes template:
pulumi new kubernetes-typescript

Step 3: Define the Helm Chart Deployment

The following example demonstrates deploying cert-manager using a Helm chart using TypeScript. Copy the following code into the index.ts file created in the previous step:

import * as pulumi from "@pulumi/pulumi";
import * as kubernetes from "@pulumi/kubernetes";

const applyPatchForceAnnotation = async (args: pulumi.ResourceTransformArgs) => {
    switch (args.type) {
        case "kubernetes:helm.sh/v4:Chart":
            break;
        default:
            args.props.metadata.annotations = {
                "cost-center": "12345",
                ...args.props.metadata.annotations,
            };
    }
    return {
        props: args.props,
        opts: args.opts,
    };
};

const ns = new kubernetes.core.v1.Namespace("cert-manager", {
    metadata: {
        name: "cert-manager",
    },
});

const certman = new kubernetes.helm.v4.Chart(
    "cert-manager",
    {
        namespace: "cert-manager",
        chart: "oci://registry-1.docker.io/bitnamicharts/cert-manager",
        version: "1.3.1",
    },
    { transforms: [applyPatchForceAnnotation] },
);

Step 4: Deploy the Resources

Run pulumi up to deploy the Helm chart to your cluster.

Benefits of Using the Chart Resource

The Chart resource offers several advantages:

  1. Direct visibility into all resources created by the chart
  2. Integration with Pulumi’s policy framework
  3. Ability to use transformations for resource manipulation
  4. Detailed previews and diffs for each Kubernetes resource

Limitations

Be aware of these limitations when using the Chart resource:

  1. No support for Helm Chart Hooks
  2. Cannot import existing Helm releases
  3. Limited interoperability with the Helm CLI

Summary

This guide demonstrated how to deploy Helm charts on Kubernetes using Pulumi’s Chart resource. This approach provides better visibility and control over your Kubernetes resources while maintaining the convenience of Helm charts. If you are interested in learning more, check out the Pulumi tutorial, Deploying Helm Charts on Kubernetes.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up