Deploy the jx-app-ui helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the
jx-app-ui
Helm chart on Azure Kubernetes Service (AKS), you'll need a running AKS cluster and Helm must be configured to deploy charts to this cluster.Below is a Pulumi program written in TypeScript that illustrates the following steps:
- Provision an AKS cluster
- Deploy the Helm chart to the AKS cluster
We'll use
@pulumi/azure-native
to create the AKS cluster, which provides native Azure resource management, and@pulumi/kubernetes
to deploy the Helm chart.Here's an outline of what the code does:
- Define an AKS cluster resource, specifying the required properties such as the node count, machine size, and Kubernetes version.
- After the AKS cluster is provisioned, obtain the
kubeconfig
which is needed to communicate with the Kubernetes cluster. - Use the Helm Chart resource to deploy the
jx-app-ui
chart to the AKS cluster using thekubeconfig
.
Detailed Explanation and Pulumi Program:
import * as azure from "@pulumi/azure"; import * as azuread from "@pulumi/azuread"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; // Create an Azure Resource Group const resourceGroup = new azure_native.resources.ResourceGroup("exampleResourceGroup"); // Create an AKS cluster const managedCluster = new azure_native.containerservice.ManagedCluster("exampleCluster", { // Azure location for the cluster location: resourceGroup.location, // Reference to the resource group it belongs to resourceGroupName: resourceGroup.name, // Properties for the cluster creation agentPoolProfiles: [{ count: 2, maxPods: 110, mode: "System", name: "agentpool", osType: "Linux", vmSize: "Standard_DS2_v2", }], // DNS prefix for the AKS cluster dnsPrefix: pulumi.interpolate`${resourceGroup.name}-kube`, // Kubernetes version kubernetesVersion: "1.18.14", // Identity specification for the cluster - can be system-assigned, user-assigned, or both identity: { type: "SystemAssigned", } }); // Retrieve the kubeconfig for the created cluster const creds = pulumi.all([resourceGroup.name, managedCluster.name]).apply(([rgName, clusterName]) => azure_native.containerservice.listManagedClusterUserCredentials({ resourceGroupName: rgName, resourceName: clusterName, }) ); const kubeconfig = creds.kubeconfigs[0].value.apply(v => v.toString()); // Create a k8s provider instance using the kubeconfig from the AKS cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig, }); // Deploy the jx-app-ui Helm chart on the AKS cluster const appUiChart = new k8s.helm.v3.Chart("jx-app-ui-chart", { chart: "jx-app-ui", // Provide values.yaml file parameters here if necessary, for example: // values: { // service: { // type: "LoadBalancer", // }, // }, // Repository URL used to locate the Helm chart fetchOpts:{ repo: "https://charts.jenkins.io/", }, }, { provider: k8sProvider }); // Export the cluster name and kubeconfig export const clusterName = managedCluster.name; export const kubeConfigResult = kubeconfig;
This code block is a complete Pulumi program. It starts by importing the required Pulumi packages for interacting with Azure and Kubernetes. It creates an Azure Resource Group followed by an AKS cluster within that resource group. Once the cluster is provisioned, it retrieves the kubeconfig and creates a Pulumi Kubernetes provider that knows how to communicate with the AKS cluster by using this kubeconfig.
Next, it uses this provider to deploy the
jx-app-ui
Helm chart from thehttps://charts.jenkins.io/
repository. Thevalues
field can be used to customize the Helm chart's deployment by providing your configuration corresponding to thevalues.yaml
file within the Helm chart.To run this Pulumi program, save it in a
index.ts
file, and ensure you have the correct Azure credentials configured for Pulumi CLI typically usingaz login
. Runpulumi up
to create the resources. After confirming the resource creation, Pulumi will deploy the AKS cluster and thejx-app-ui
Helm chart to your Azure account.Remember that costs will be incurred on Azure for the resources created, so make sure to destroy the resources with
pulumi destroy
when you are done to avoid unnecessary charges.For more information on the used resources: