1. Deploy the argo-cr helm chart on Digital Ocean Kubernetes Service

    TypeScript

    To deploy the Argo CD Helm chart on a Digital Ocean Kubernetes Service (DOKS), we will follow these steps:

    1. Create a DOKS cluster using the digitalocean.KubernetesCluster resource.
    2. Deploy the Argo CD Helm chart using the kubernetes.helm.v3.Chart resource.

    We will use Pulumi's TypeScript SDK to write the deployment script. You will first need to set up Pulumi, have access to DigitalOcean and have Pulumi configured to use DigitalOcean.

    Prerequisites:

    Before you begin, make sure you have:

    • Installed Pulumi: You can follow the installation instructions.
    • Set up your DigitalOcean token: Configure your DigitalOcean token as described here.

    The Program:

    The following TypeScript program will create a new Kubernetes cluster in Digital Ocean and deploy Argo CD on it via a Helm chart.

    import * as pulumi from "@pulumi/pulumi"; import * as digitalocean from "@pulumi/digitalocean"; import * as kubernetes from "@pulumi/kubernetes"; // Create a DigitalOcean Kubernetes cluster const cluster = new digitalocean.KubernetesCluster("do-cluster", { region: digitalocean.Regions.NYC1, version: "latest", nodePool: { name: "default", size: digitalocean.DropletSlugs.DropletS4VCPU8GB, nodeCount: 1, }, }); // Once the cluster is provisioned, we use the Kubeconfig from the cluster to interact with it const k8sProvider = new kubernetes.Provider("do-k8s", { kubeconfig: cluster.kubeConfigs[0].rawConfig, }); // Deploy Argo CD using the official Helm chart const argoCDChart = new kubernetes.helm.v3.Chart("argo-cd", { chart: "argo-cd", version: "4.5.5", // Specify the version of the chart if needed fetchOpts: { repo: "https://argoproj.github.io/argo-helm" }, namespace: "argocd", }, { provider: k8sProvider }); // Export the kubeconfig to access the cluster export const kubeconfig = cluster.kubeConfigs[0].rawConfig; // Export the Argo CD server URL export const argoCdServer = argoCDChart.getResourceProperty("v1/Service", "argocd/argo-cd-argocd-server", "status") .apply(status => `http://${status.loadBalancer.ingress[0].ip}`);

    Explanation:

    • We begin by importing the required Pulumi and provider-specific packages.
    • A DigitalOcean Kubernetes cluster is created (digitalocean.KubernetesCluster) in the NYC1 region, with one node that is 8GB in size. You can adapt the region, version, and size according to your needs.
    • We create a Kubernetes provider that knows how to interact with our newly created DOKS (kubernetes.Provider) with the kubeconfig obtained from the cluster.
    • The Argo CD Helm chart is deployed (kubernetes.helm.v3.Chart) using the Helm chart from Argo's Helm repository. This installation defaults to deploying Argo CD in the "argocd" namespace. We also specify the provider which should be used to deploy the chart, which is our DOKS cluster.
    • Finally, we export two things:
      • The kubeconfig so you can interact with your Kubernetes cluster using kubectl or other Kubernetes tools.
      • The argoCdServer URL to access the Argo CD dashboard, once the LoadBalancer service is assigned an external IP address.

    To execute this Pulumi program, save the code in a file named index.ts, and run pulumi up from the same directory. The Pulumi CLI will take care of understanding the changes (if you rerun it) and applying them to your cloud provider. Once you confirm the changes, Pulumi will provision a DOKS cluster and deploy Argo CD on it.