Deploy the argocd-config helm chart on Kubernetes
TypeScriptDeploying a Helm chart on a Kubernetes cluster using Pulumi is a common scenario when you want to manage your Kubernetes resources in a declarative way. The
argocd-config
Helm chart would typically be used to set up and configure Argo CD, a declarative, GitOps continuous delivery tool for Kubernetes.In this example, we will create a Pulumi program using TypeScript that deploys the
argocd-config
Helm chart to a Kubernetes cluster. We'll use thekubernetes.helm.v3.Chart
class from the@pulumi/kubernetes
package which allows us to deploy Helm charts.Here's the step-by-step explanation of what we're doing:
- We begin by importing the necessary Pulumi and Kubernetes packages.
- We create a new Helm chart resource using
new kubernetes.helm.v3.Chart
, passing the required parameters such as:chart
: The name of the chart (argocd-config
).version
: The chart version to deploy (optional).fetchOpts
: Additional options for fetching the Helm chart like repository or version (optional).values
: Overrides for the default chart values (optional).
- We set the namespace to deploy the chart to, which is typically
argocd
for Argo CD but it can be customized as needed.
Now, let's dive into the code:
import * as pulumi from '@pulumi/pulumi'; import * as kubernetes from '@pulumi/kubernetes'; const namespace = 'argocd'; const chartName = 'argocd-config'; const chartVersion = 'x.y.z'; // Replace with the actual chart version you wish to deploy // Assuming that the Kubernetes cluster is already set up and the context is configured. // Deploy the argocd-config Helm chart. const argocdConfigChart = new kubernetes.helm.v3.Chart(chartName, { // If the Helm chart is from a custom repository, specify the 'repo' field in 'fetchOpts'. // Otherwise, Pulumi will use the default Helm chart repositories. chart: chartName, // Specify the chart version. Omit this field or set to 'undefined' for the latest version. version: chartVersion, // Set the namespace where the chart will be installed. // Create the namespace if it does not exist, or make sure it exists beforehand. namespace: namespace, // Custom values for the Helm chart can be set here. // This is an example of setting the service type for the Argo CD server. values: { server: { service: { type: 'LoadBalancer', }, }, }, // Define other chart parameters if necessary, such as dependencies. // Make sure the Kubernetes context is correctly set to the target cluster where you want to deploy. }, { dependsOn: [] }); // Optional: Export any relevant resources or endpoints that might be useful to external clients. export const argoCdServerServiceType = argocdConfigChart.getResourceProperty('v1/Service', `${namespace}/${chartName}-server`, 'spec.type');
In this code:
- We're creating a
Chart
resource namedargocdConfigChart
. - We're exporting a property
argoCdServerServiceType
which could be useful to know outside of Pulumi, like when querying the type of the Argo CD server service through the Pulumi stack.
Before running this code, make sure that:
- You have access to a Kubernetes cluster and your
kubeconfig
file is properly set up. - You have installed the Pulumi CLI and logged in.
- You have initialized a new Pulumi project or are working within an existing one.
To deploy this Helm chart using Pulumi, run the following commands in your terminal:
pulumi up
These commands will apply the Pulumi configuration and deploy the Helm chart on your Kubernetes cluster. Pulumi CLI will show you a preview of the resources that will be created and prompt for confirmation before proceeding.