Deploy the quarks helm chart on Azure Kubernetes Service (AKS)
TypeScriptDeploying a Helm chart on Azure Kubernetes Service (AKS) requires a few steps using Pulumi:
- Create an AKS cluster.
- Install the Helm chart onto the cluster.
Below, I will guide you through the code required to deploy the "Quarks" Helm chart on an AKS cluster using Pulumi and TypeScript.
Setting up AKS Cluster
We will start by creating an instance of AKS using the
azure-native
package specifically theManagedCluster
resource. This will provision a Kubernetes cluster in Azure on which Helm charts can be deployed.Installing the Quarks Helm Chart
Once the AKS cluster is ready, we install the Quarks Helm chart using the
helm.sh/v3.Chart
resource from thekubernetes
provider. This resource manages the deployment of Helm charts on the Kubernetes cluster.Pulumi Program
Let's dive into the Pulumi program:
import * as azure_native from "@pulumi/azure-native"; import * as kubernetes from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Create an Azure Resource Group const resourceGroup = new azure_native.resources.ResourceGroup("resourceGroup"); // Create an AKS cluster const cluster = new azure_native.containerservice.ManagedCluster("myAksCluster", { resourceGroupName: resourceGroup.name, agentPoolProfiles: [{ count: 1, vmSize: "Standard_DS2_v2", name: "agentpool", mode: "System", }], dnsPrefix: "dnsPrefix", enableRBAC: true, kubernetesVersion: "1.22.10", }, { parent: resourceGroup }); const creds = pulumi.output(azure_native.containerservice.listManagedClusterUserCredentials({ resourceGroupName: resourceGroup.name, resourceName: cluster.name, })); // Export the kubeconfig export const kubeconfig = creds.apply(creds => { const encoded = creds.kubeconfigs[0].value!; return Buffer.from(encoded, 'base64').toString(); }); // Create a Kubernetes provider instance using the kubeconfig from AKS cluster const k8sProvider = new kubernetes.Provider("k8sProvider", { kubeconfig: kubeconfig, }); // Deploy the Quarks Helm chart onto the AKS cluster const quarksChart = new kubernetes.helm.v3.Chart("quarks", { chart: "quarks", // Specify the Chart repo here if it's not in Helm's default repository // repo: "<URL of the Quarks Helm chart repository>", // You can add any required custom values file or values here // values: { }, }, { provider: k8sProvider }); // Exports export const aksClusterName = cluster.name;
Explanation
- We start by importing the necessary Pulumi libraries to work with Azure and Kubernetes.
- Then, we set up a resource group and an AKS cluster, specifying the minimum requirement for agent pool profile.
- We retrieve the kubeconfig for the created AKS cluster using
listManagedClusterUserCredentials
, which is required to communicate with the AKS cluster. - We then create a Kubernetes provider using the kubeconfig that will allow Pulumi to interact with our AKS cluster.
- Finally, we use the
helm.v3.Chart
resource to deploy the Quarks Helm chart to the AKS cluster.
What Next?
To execute this Pulumi program:
- Save this code in a file named
index.ts
. - Ensure you have the Pulumi CLI, Node.js, and TypeScript installed on your machine.
- Run
pulumi up
from your command line in the same directory as your code. Pulumi will perform a deployment preview and ask for confirmation before proceeding.
After confirming, Pulumi will execute the deployment, and you will be able to see the resources being created in your terminal. Once completed, your AKS cluster will be running with the Quarks Helm chart deployed on it.