Deploy the ebpf-agent helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the
ebpf-agent
Helm chart on Azure Kubernetes Service (AKS), you'll follow these steps:-
Provision an AKS Cluster: Use Pulumi's
azure-native
package to create an AKS cluster. You will need to define some required properties such asresourceGroupName
,location
for the AKS cluster, andkubernetesVersion
. -
Install the Helm Chart: Once you have your Kubernetes cluster ready, Pulumi provides the
kubernetes
package that has support for deploying Helm charts. You will define theChart
resource, and you'll need to provide the chart name (in this case,ebpf-agent
), along with any required values or configuration settings.
Here's a TypeScript program that illustrates how to carry this out:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Provision an AKS Cluster // Replace these parameters with your desired settings. const resourceGroupName = "myResourceGroup"; const clusterName = "myAKSCluster"; const location = "East US"; // Choose the appropriate Azure region for your cluster. const kubernetesVersion = "1.21.2"; // Use a supported Kubernetes version for AKS. const resourceGroup = new azure_native.resources.ResourceGroup("rg", { resourceGroupName, location, }); const managedCluster = new azure_native.containerservice.ManagedCluster("cluster", { resourceGroupName: resourceGroup.name, location: resourceGroup.location, kubernetesVersion: kubernetesVersion, agentPoolProfiles: [{ count: 1, maxPods: 110, mode: "System", name: "agentpool", osType: "Linux", vmSize: "Standard_DS2_v2", }], dnsPrefix: `${pulumi.getStack()}-kube`, }); const creds = pulumi.all([managedCluster.name, resourceGroup.name]).apply(([clusterName, rgName]) => { return azure_native.containerservice.listManagedClusterUserCredentials({ resourceGroupName: rgName, resourceName: clusterName, }); }); const kubeConfig = creds.kubeconfigs[0].value.apply( v => Buffer.from(v, "base64").toString() ); // Step 2: Install the Helm Chart using Pulumi's Kubernetes provider // Initialize the provider using our kubeconfig from the AKS cluster. const k8sProvider = new k8s.Provider("k8s", { kubeconfig: kubeConfig, }); // Deploy the `ebpf-agent` Helm chart into the `default` namespace. const ebpfAgentChart = new k8s.helm.sh.v3.Chart("ebpfAgent", { chart: "ebpf-agent", // The repository URL where the chart can be found // You might need to replace this URL with the specific Helm chart repository URL. repo: "https://charts.example.com/", version: "1.2.3", // Specify the version of the Helm chart. namespace: "default", }, { provider: k8sProvider }); // Export the cluster's kubeconfig. export const kubeconfig = kubeConfig;
How to use this code
Here's a walkthrough of the code snippet provided above:
- We begin by importing the necessary Pulumi libraries for interfacing with Azure resources and Kubernetes.
- We declare our resource group and AKS cluster using
azure_native
. We include an agent pool that defines the virtual machines that will form the Kubernetes nodes where our Helm chart could be deployed. - One of the important outputs from an AKS cluster creation is the
kubeConfig
which is used to communicate with the Kubernetes cluster. - We create a Pulumi Kubernetes provider that uses the AKS cluster's kubeconfig. This allows us to manage Kubernetes resources on the AKS cluster.
- We finally declare a Pulumi Helm chart resource. It references the
ebpf-agent
Helm chart and its configuration details. The chart is fetched from the specified Helm repository. Note that we export the kubeconfig, which could be used withkubectl
or other Kubernetes tools to interact with the cluster outside of Pulumi.
When you're ready to deploy this Pulumi program:
- Set up your Azure credentials locally or in your CI/CD pipeline as per Pulumi's documentation.
- Run
pulumi up
to execute the program. Pulumi will show you a preview of the actions to be taken and will await your confirmation before applying changes.
After running
pulumi up
, the AKS cluster and theebpf-agent
Helm chart should be deployed.-