Deploy the gitops-operator helm chart on Kubernetes
TypeScriptIn order to deploy the
gitops-operator
Helm chart on a Kubernetes cluster using Pulumi, you will use thekubernetes.helm.v3.Chart
resource from Pulumi's Kubernetes package. This Pulumi resource represents a Helm chart and allows you to deploy that chart to a Kubernetes cluster as part of your Pulumi program.Below is a Pulumi TypeScript program that demonstrates how to deploy a Helm chart called
gitops-operator
. For the sake of this example, let's assume that this Helm chart is available in a public Helm repository. If the Helm chart requires a specific Helm repository, you will need to specify therepo
parameter. We will set thenamespace
in which the Helm chart will be deployed, and provide any necessaryvalues
that may be needed for customization as a TypeScript object.import * as kubernetes from "@pulumi/kubernetes"; // Create an instance of the Helm chart to deploy the gitops-operator. // Here you need to specify the namespace where you want to install the gitops-operator // and provide any additional configuration needed for the Helm chart in the `values` property. const gitopsOperatorChart = new kubernetes.helm.v3.Chart("gitops-operator", { chart: "gitops-operator", version: "1.0.0", // specify the chart version if required namespace: "gitops", // replace with the namespace where you want the operator installed repo: "https://charts.gitops-operator.io/", // replace with the Helm repository URL if needed // If the chart requires additional values, set them here. Example: values: { // These are made-up values and should mirror the actual values // required by the gitops-operator Helm chart. serviceAccount: { create: true, name: "gitops-operator" }, // ... other configurable values }, // In case you need to apply transformations or set any other additional options. // transformations: [...], // fetchOpts: { ... }, }); // To obtain information about the deployed resources (such as URLs, credentials, // or other output data), you might need to declare output properties. // For example, you can export the status of the deployment: export const gitopsOperatorStatus = gitopsOperatorChart.status;
This program starts by importing the necessary Pulumi Kubernetes package. It then declares a Helm chart resource named
gitops-operator
, specifying the name of the chart, the chart version, and the namespace in which the chart should be deployed. You can customize the installation by providing additional configuration in thevalues
property.To apply this Pulumi program:
- Ensure you have Pulumi CLI installed and configured with access to your Kubernetes cluster.
- Save the above code in a file named
index.ts
in a new directory. - Initialize a new Pulumi project in that directory via
pulumi new
and selecttypescript
as the language. - Install the required dependencies by running
npm install
. - Run
pulumi up
to preview and deploy the changes to your cluster.
When the program runs, Pulumi will call out to Helm to handle the chart installation. The process is declarative, and Pulumi maintains the state of your cluster resources, making it easy to track changes or roll back if necessary.