Deploy the webhookie helm chart on Azure Kubernetes Service (AKS)
TypeScriptDeploying a Helm chart to an Azure Kubernetes Service (AKS) cluster using Pulumi involves several steps, which I will explain below. These steps include setting up the AKS cluster, configuring Pulumi to work with the cluster, and deploying the Helm chart.
AKS Cluster
Before deploying the Helm chart, you need to have an AKS cluster already created and running. Pulumi provides resources to manage AKS clusters, such as
ProvisionedCluster
from theazure-native
provider. TheProvisionedCluster
resource allows you to provision an AKS cluster in your Azure environment.Helm Chart Deployment
Pulumi's
kubernetes
provider is used to deploy Helm charts to a Kubernetes cluster. TheChart
resource from thekubernetes
provider represents a Helm chart, which Pulumi can deploy to any Kubernetes cluster, including AKS.The Program
The following TypeScript program illustrates how to:
- Set up an AKS cluster (assumed to be already provisioned for this program).
- Get credentials for the AKS cluster.
- Deploy a Helm chart called
webhookie
to the AKS cluster.
Let's take a look at the program:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as kubernetes from "@pulumi/kubernetes"; // You would replace `existingClusterName` and `existingResourceGroupName` // with the names of your existing AKS cluster and its resource group. const existingClusterName = "myAksCluster"; const existingResourceGroupName = "myResourceGroup"; // Retrieve the AKS cluster details. const cluster = azure_native.containerservice.ManagedCluster.get(existingClusterName, { resourceName: existingClusterName, resourceGroupName: existingResourceGroupName, }); // Create a Kubernetes provider instance using the AKS kubeconfig. const k8sProvider = new kubernetes.Provider("k8sProvider", { kubeconfig: cluster.kubeConfigRaw, }); // Deploy the `webhookie` Helm chart on the AKS cluster. const webhookieChart = new kubernetes.helm.v3.Chart("webhookieChart", { chart: "webhookie", // Ensure you have added the Helm repo that contains the webhookie chart // and replace `repoURL` with the repository URL. fetchOpts: { repo: "https://example.com/helm-charts", }, }, { provider: k8sProvider }); // Export the public IP of the webhookie service to access it. export const webhookieServiceIP = webhookieChart.getResourceProperty("v1/Service", "webhookie-service", "status") .apply(status => status.loadBalancer.ingress[0].ip);
Explanation
- We begin by importing the necessary Pulumi libraries:
pulumi
,azure-native
, andkubernetes
. - Accessing an existing AKS cluster is demonstrated using the
ManagedCluster.get
function from theazure-native
package. You need to provide the name and resource group of your cluster. - A
kubernetes.Provider
is instantiated with the retrieved AKS kubeconfig. This configures Pulumi to interact with your AKS cluster. - We declare a new Helm chart resource,
webhookieChart
, specifying:- The chart name:
'webhookie'
- The repo URL where the chart can be fetched.
- The associated Kubernetes provider indicating where the chart should be deployed.
- The chart name:
- Lastly, we export the public IP address of the deployed service, assuming that the
webhookie
Helm chart includes aService
with a LoadBalancer that exposes an IP address.
Requirements
To use this program effectively:
- You should have an existing AKS cluster.
- Pulumi CLI installed and logged in.
- Your Azure credentials configured using the Azure CLI or the Pulumi Azure provider.
- The Helm repository that contains the
webhookie
chart needs to be known and potentially needs to be added to your local Helm client configuration.
You would run this code using the Pulumi CLI by executing
pulumi up
, which will provision the resources defined in the code.Remember, this code assumes availability of the Helm chart
webhookie
and correct setting of the repository URL. Adjustchart
,fetchOpts.repo
, and other configurations as necessary to match the details of the Helm chart you intend to deploy.