Deploy the argo-app-manager helm chart on Digital Ocean Kubernetes Service
TypeScriptIn order to deploy the Argo CD App Manager Helm chart on a Digital Ocean Kubernetes Service (DOKS) cluster using Pulumi, you'll need to complete a series of steps. Firstly, you will create a DOKS cluster, and then you will deploy the Helm chart onto that cluster.
Here's a high-level outline of what we will do:
- Install the necessary Pulumi packages for Digital Ocean and Kubernetes.
- Set up a new Pulumi project and stack.
- Use the
digitalocean.KubernetesCluster
resource to create a DOKS cluster. - Use the
kubernetes.helm.v3.Chart
resource to deploy the Argo CD App Manager Helm chart onto the DOKS cluster.
Below is a TypeScript program that accomplishes these steps. The program will assume that you have Digital Ocean access credentials configured in your environment or your Pulumi config.
import * as pulumi from "@pulumi/pulumi"; import * as digitalocean from "@pulumi/digitalocean"; import * as k8s from "@pulumi/kubernetes"; // Create a Digital Ocean Kubernetes cluster const cluster = new digitalocean.KubernetesCluster("do-cluster", { region: "nyc3", version: "latest", nodePool: { name: "default", size: "s-2vcpu-2gb", nodeCount: 1, }, }); // Once the cluster is created, we can obtain the kubeconfig const kubeconfig = pulumi. all([cluster.name, cluster.kubeConfigs]). apply(([name, kubeConfigs]) => kubeConfigs[0].rawConfig); // Create a Kubernetes provider instance using the kubeconfig from the DOKS cluster const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: kubeconfig, }); // Deploy the Argo CD App Manager Helm chart const argoAppManager = new k8s.helm.v3.Chart("argo-cd-app-manager", { chart: "argo-cd", version: "3.2.3", // specify the chart version you want to deploy fetchOpts: { repo: "https://argoproj.github.io/argo-helm", // official Argo CD Helm chart repository }, }, { provider: k8sProvider }); // Export the cluster's kubeconfig and the Argo CD Server endpoint export const kubeConfigOutput = kubeconfig; export const argoCdServerEndpoint = argoAppManager.getResource("v1/Service", "argo-cd/argocd-server").status.loadBalancer.ingress[0].hostname;
Explanation:
- We import the required modules from Pulumi for Digital Ocean and Kubernetes.
- We declare a Digital Ocean Kubernetes cluster with one node using a
s-2vcpu-2gb
size, which is a small and cost-efficient option suitable for learning and experimenting. - We obtain the
kubeconfig
from the newly created DOKS cluster, which is necessary to communicate with the Kubernetes cluster. - We create an instance of
Provider
from@pulumi/kubernetes
, which allows Pulumi to deploy resources onto the Kubernetes cluster using thekubeconfig
. - We deploy the Argo CD App Manager using its official Helm chart from the Argo Helm repository
https://argoproj.github.io/argo-helm
. - We export the kubeconfig for use with
kubectl
and other command-line tools, as well as the endpoint for the Argo CD server which will allow you to access the Argo CD UI.
To run this Pulumi program:
- Make sure Pulumi CLI and Node.js are installed on your system.
- Set up a new Pulumi project by running
pulumi new typescript
. - Replace the content of
index.ts
with the code provided above. - Run
npm install @pulumi/pulumi @pulumi/digitalocean @pulumi/kubernetes
to install the dependencies. - Set the required configuration for the DigitalOcean provider, either using the Pulumi CLI or environment variables.
- Run
pulumi up
to create the infrastructure.
Please adjust the
version
and any other chart settings to fit your specific use case for Argo CD. Also, be aware that this program will provision resources that may cost money.