Deploy the puppet-catalog-diff-viewer helm chart on Azure Kubernetes Service (AKS)
TypeScriptDeploying the
puppet-catalog-diff-viewer
Helm chart on Azure Kubernetes Service (AKS) involves several steps. You will first need to create an AKS cluster. After which, you will install the Helm chart into your AKS cluster. Pulumi's@pulumi/azure-native
and@pulumi/kubernetes
packages provide the necessary components to accomplish these tasks.Firstly, you must import the required Pulumi packages and set up the Pulumi program. As a novice, you should know that Pulumi programs are structured like typical TypeScript programs, where you import libraries, create resources, and Pulumi takes care of the deployment and lifecycle management.
Here's how you can achieve the deployment:
- We'll start by creating an AKS cluster using Pulumi's Azure Native package.
- Once the cluster is provisioned, we'll configure Pulumi to use the credentials for your AKS cluster so that it can manage resources in it.
- Finally, we'll deploy the Helm chart to the AKS cluster using Pulumi's Kubernetes package.
Below is a detailed Pulumi program written in TypeScript that demonstrates these steps:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create the AKS cluster const resourceGroupName = new azure_native.resources.ResourceGroup("myResourceGroup"); const cluster = new azure_native.containerservice.ManagedCluster("myCluster", { resourceGroupName: resourceGroupName.name, agentPoolProfiles: [{ count: 2, // Specifies the number of agents (VMs) to create in this agent pool vmSize: "Standard_DS2_v2", // The size of the VMs in the agent pool name: "agentpool" // The name of the agent pool }], dnsPrefix: "mydns", // DNS prefix specified when creating the AKS cluster kubernetesVersion: "1.20.7", // The version of Kubernetes to use linuxProfile: { adminUsername: "adminuser", ssh: { publicKeys: [{ keyData: "<your-ssh-rsa-public-key>" // Replace with your actual RSA public key }], }, }, enableRBAC: true, }); // Export the AKS cluster's kubeconfig export const kubeconfig = cluster.kubeConfigRaw; // Step 2: Configure Pulumi to use the AKS cluster credentials const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeConfigRaw, }); // Step 3: Deploy the Helm chart to the AKS cluster const puppetCatalogDiffViewerChart = new k8s.helm.v3.Chart("puppet-catalog-diff-viewer", { repo: "myhelmrepo", // Name of the Helm repository, replace with the actual name if necessary chart: "puppet-catalog-diff-viewer", // Name of the chart in the Helm repository version: "1.0.0", // Specify the chart version, ensure it’s available in the repo }, { provider: k8sProvider }); // Optionally, you can export endpoints or other resources that the Helm chart might provision.
Please replace
<your-ssh-rsa-public-key>
with your actual SSH public key to allow secure access to the nodes within your AKS cluster.This Pulumi program does the following:
- Sets up a new resource group in Azure to contain our AKS cluster.
- Creates a new AKS cluster with a specified VM size and node count. It also sets up the
adminUsername
andssh
key for secure access. - The AKS cluster
kubeconfig
is exported so you can interact with your cluster usingkubectl
from your local machine. - A
k8s.Provider
resource is created to interact with your new AKS cluster using the generatedkubeconfig
. ThisProvider
will be used for deploying Kubernetes resources. - Finally, the puppet-catalog-diff-viewer Helm chart is deployed using Pulumi's Helm Chart resource. This resource fetches the specified chart from the Helm repository and deploys it on the AKS cluster using the
k8sProvider
.
Remember to replace the
repo
field with the actual name of the Helm repository wherepuppet-catalog-diff-viewer
is located if it's different from "myhelmrepo", and also specify the correct version that you want to deploy.Before running
pulumi up
which deploys the program, make sure you have the@pulumi/azure-native
and@pulumi/kubernetes
packages installed, your Azure credentials configured, and Pulumi CLI set up appropriately on your system.After deploying the Helm chart, you can use
kubectl
to interact with your AKS cluster and confirm that thepuppet-catalog-diff-viewer
application is running as expected.