Deploy the argocd-workflows helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the Argo CD Workflows Helm chart on Azure Kubernetes Service (AKS), we will go through several steps. First, we need to provision an AKS cluster if one doesn't already exist. Then, we will install and configure Helm in our Pulumi program, which allows us to manage Kubernetes applications. After that, we will deploy the Argo CD Workflows Helm chart on the AKS cluster.
The main resources we'll create are as follows:
- An AKS cluster using the
azure-native
package which provides us direct access to Azure services. - A Helm chart resource to deploy Argo CD Workflows onto our AKS cluster which is available from the
kubernetes
package.
Before you run the following program, ensure you've installed Pulumi and configured it to use Azure via Azure CLI. Also, make sure you have the necessary permissions to create resources in your Azure subscription.
Here's a TypeScript program to achieve this goal:
import * as azure from "@pulumi/azure-native"; import * as kubernetes from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Step 1: Create an AKS cluster const resourceGroupName = new azure.resources.ResourceGroup("myResourceGroup"); const aksCluster = new azure.containerservice.ManagedCluster("myAksCluster", { resourceGroupName: resourceGroupName.name, agentPoolProfiles: [{ count: 1, vmSize: "Standard_DS2_v2", name: "agentpool" }], dnsPrefix: "myakscluster", }); // Export the kubeconfig for AKS cluster which will be used to configure kubectl export const kubeconfig = aksCluster.kubeConfigRaw; // Step 2: Install the Argo CD Workflows Helm chart on the AKS cluster // Ensure that Pulumi's provider uses the generated kubeconfig from AKS const provider = new kubernetes.Provider("k8sProvider", { kubeconfig: kubeconfig, }); // Step 3: Deploy the Argo CD Workflows Helm chart // Use "https://argoproj.github.io/argo-helm" as the repository for the Argo Workflows Helm chart const argoWorkflowsChart = new kubernetes.helm.v3.Chart("argocd-workflows-chart", { chart: "argo-cd", version: "3.33.0", // specify the desired version of the chart here fetchOpts: { repo: "https://argoproj.github.io/argo-helm", }, }, { provider }); // To access the Helm chart, we're using the `kubernetes.helm.v3.Chart` resource // The `repo` property must point to the chart's repository URL // Additionally, under `fetchOpts`, you provide the repo URL and optionally the version of the chart if a specific one is needed // Step 4: Export the Argo CD server URL // You can get the service public IP and assemble the hosted URL like this. const argoCdServer = argoWorkflowsChart.getResourceProperty("v1/Service", "argocd-server", "status"); export const argoCdServerUrl = pulumi.interpolate`http://${argoCdServer.loadBalancer.ingress[0].ip}`;
Here's what each step in the program is doing:
- We start by creating a new resource group called
myResourceGroup
to hold the AKS cluster. - We create an AKS cluster named
myAksCluster
with a single node pool using Ds2_v2 standard VM size. - We're using the
kubeConfigRaw
output of the AKS cluster to access it withkubectl
commands. - The
kubernetes.Provider
resource calledk8sProvider
tells Pulumi to use our newly created AKS' kubeconfig. - We then declare a Helm chart resource
argocd-workflows-chart
, which references the Argo CD Helm chart from the official Argo project Helm repo. - Finally, we export the generated URL for the Argo CD server. To have a valid URL, ensure the necessary services are exposed and point to correct endpoints, which might require further configuration based on your specific networking setup.
Make sure to review and adjust versions, names, and settings per your requirements and Azure environment configuration. After writing this Pulumi program in a file (e.g.,
index.ts
), you can simply runpulumi up
in the terminal at the directory where your file resides to create the resources specified in the program.- An AKS cluster using the