Deploy the rdf-streaming-updater helm chart on Azure Kubernetes Service (AKS)
TypeScriptDeploying an application using a Helm chart on an Azure Kubernetes Service (AKS) cluster involves several steps. We'll break down these steps and then present a cohesive Pulumi program written in TypeScript to accomplish your goal.
The steps are as follows:
-
Create an AKS Cluster: First, you need to have an AKS cluster up and running. You can create one using Pulumi's
azure-native
package which provides native Azure resources. Specifically, you would useazure-native.containerservice.ManagedCluster
to deploy an AKS cluster. -
Install the Helm Chart: Once the cluster is available, you can deploy applications using Helm charts. For this, Pulumi provides the
kubernetes.helm.v3.Chart
resource that allows you to install Helm charts into your Kubernetes cluster.
Now, let's put these steps into a Pulumi program. Below is a TypeScript program that will create an AKS cluster and deploy the "rdf-streaming-updater" Helm chart onto it.
Please note, this program assumes that you have the necessary Azure credentials configured for Pulumi to deploy resources to your Azure subscription.
import * as pulumi from "@pulumi/pulumi"; import * as azureNative from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Create an AKS Cluster const resourceGroup = new azureNative.resources.ResourceGroup("myResourceGroup"); const managedCluster = new azureNative.containerservice.ManagedCluster("myAKSCluster", { resourceGroupName: resourceGroup.name, agentPoolProfiles: [{ count: 3, // Number of nodes in Node Pool vmSize: "Standard_DS2_v2", // Size of the Virtual Machines to use for nodes mode: "System", // Sets the type of pool, System by default, can be set to User name: "agentpool", // Name of the node pool }], dnsPrefix: "myakscluster", // An unique DNS prefix for the AKS cluster enableRBAC: true, // Enable Role-Based Access Control kubernetesVersion: "1.19.11", // Specify the version of Kubernetes location: resourceGroup.location, // Use the resource group's location for the AKS cluster }); // Export the kubeconfig for the cluster export const kubeConfig = pulumi. all([resourceGroup.name, managedCluster.name]). apply(([resourceGroupName, clusterName]) => azureNative.containerservice.listManagedClusterUserCredentials({ resourceGroupName, resourceName: clusterName, })).then(creds => { const encoded = creds.kubeconfigs[0].value; return Buffer.from(encoded, "base64").toString(); } ); // Deploy the rdf-streaming-updater helm chart to the AKS cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: kubeConfig, }); const chart = new k8s.helm.v3.Chart("rdf-streaming-updater-chart", { chart: "rdf-streaming-updater", // Assuming rdf-streaming-updater is in a reachable Helm repo // You may need to specify a 'repo' property if it is not in the default stable repository. // repo: "<HELM_REPO_URL>", namespace: "default", // Deploy the chart in the default namespace or specify another }, { provider: k8sProvider }); // Optional: Export any resources, like URLs or endpoints // export const appUrl = //...
Explanation:
-
The
azureNative.containerservice.ManagedCluster
resource creates a new AKS cluster within a resource group. You can customize the cluster configurations as required by your application. -
The
pulumi.all(...).apply(...)
function is used to asynchronously fetch the kubeconfig of the newly created cluster which is necessary for Pulumi to manage resources within the AKS cluster. -
The
k8s.Provider
Pulumi resource is instantiated with the kubeconfig to be used for deploying resources into our AKS cluster. -
The
k8s.helm.v3.Chart
resource is used to deploy the "rdf-streaming-updater" Helm chart into the AKS cluster. We specify the chart name and namespace where this application should be deployed. If the Helm chart you are referring to is in a custom Helm repository, you need to provide therepo
argument with the URL of the repository. -
Optionally, you can export resources such as application URLs or other to use them outside Pulumi, for instance, to access the application that was just deployed using Helm.
The above Pulumi program provides an infrastructure as code approach to deploy a Helm chart in AKS. You should ensure the chart name and version you intend to deploy are accurate and available in the Helm repository mentioned in the program. If this Helm chart requires custom values, you can pass a
values
property to theChart
resource with an object containing the needed values.Please keep in mind, to execute this Pulumi code, you would need the Pulumi CLI installed and configured for use with Azure. Once you have this setup, you can run the pulumi up command to create the AKS cluster and deploy your Helm chart.
-