Deploy the argo-cr helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the Argo CD Helm chart on an Azure Kubernetes Service (AKS) cluster using Pulumi, you will need the following:
- An existing Azure Kubernetes Service (AKS) cluster where Argo CD will be installed.
- The
@pulumi/azure-native
and@pulumi/kubernetes
packages to create and interact with Azure resources and the Kubernetes cluster.
We'll assume you already have an AKS cluster running. If you do not have an AKS cluster, you can create one using Pulumi's
azure-native
provider, specifically using theazure-native.containerservice.ManagedCluster
resource.Now, let's focus on deploying the Argo CD Helm chart on the AKS cluster. We will follow these steps:
- Import necessary Pulumi libraries.
- Use Pulumi's
Config
to fetch Kubernetes configuration from your AKS cluster. - Use the
kubernetes
provider configured with AKS cluster credentials. - Deploy the Argo CD Helm chart using Pulumi's Kubernetes provider.
Here's how the Pulumi TypeScript program might look:
import * as azure from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Instantiate an Azure Kubernetes Service (AKS) provider const aksClusterName = "your-aks-cluster-name"; // Specify your AKS cluster name const resourceGroupName = "your-resource-group-name"; // Specify your Azure resource group name // Step 1: Fetch the credentials for the AKS cluster const creds = pulumi.output(azure.containerservice.listManagedClusterAdminCredentials({ resourceGroupName: resourceGroupName, resourceName: aksClusterName, })); // Step 2: Use the AKS cluster credentials to configure the Kubernetes provider const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: creds.apply(c => c.kubeconfigs[0].value), }); // Step 3: Deploy Argo CD Helm chart const argoCdChart = new k8s.helm.v3.Chart("argo-cd", { chart: "argo-cd", version: "3.2.3", // Argo CD Helm chart version fetchOpts: { repo: "https://argoproj.github.io/argo-helm", // Argo CD Helm chart repository }, values: { // Custom values for the Argo CD Helm chart. Adjust these as necessary. server: { service: { type: "LoadBalancer", }, }, }, }, { provider: k8sProvider }); // Export any important URLs or other data export const argoCdServerUrl = argoCdChart.getResourceProperty("v1/Service", "argo-cd/argo-cd-server", "status").apply(status => status.loadBalancer.ingress[0].ip);
Here's what we've done in the above code:
- We use
listManagedClusterAdminCredentials
to fetch the cluster admin credentials of the specified AKS cluster. - We create an instance of Pulumi's Kubernetes provider using these credentials.
- We deploy the Argo CD Helm chart from the Argoproj Helm chart repository to the AKS cluster using the
Chart
class of the@pulumi/kubernetes
package. - The Argo CD server is exposed via a LoadBalancer service. Modify the
values
field as needed to fit custom configuration requirements for Argo CD.
In the
export
statement, we are exporting the IP address of the LoadBalancer that provides access to the Argo CD server. After the deployment, you can use this IP address to access the Argo CD dashboard in your web browser.Make sure to replace
your-aks-cluster-name
andyour-resource-group-name
with your actual AKS cluster's name and resource group.To run this Pulumi program:
- Ensure you have Pulumi installed and configured with the correct Azure credentials.
- Create a new directory and initialize a new Pulumi project with
pulumi new
. - Install the required NPM packages with
npm install @pulumi/azure-native @pulumi/kubernetes
. - Replace the contents of
index.ts
(or the equivalent entry point in your language of choice) with the code provided above. - Run
pulumi up
to preview and deploy your changes.
After the deployment completes, Pulumi will provide you with the exported values, including the IP address for the Argo CD server. You can use that IP address to access the Argo CD UI in a browser and start managing your Kubernetes deployments.