Deploy the hive-schema helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the
hive-schema
Helm chart on Azure Kubernetes Service (AKS) using Pulumi, you will need to follow these steps:- Set up an AKS cluster.
- Install the Helm chart on the AKS cluster.
In the Pulumi program below, I'll guide you through setting up an AKS cluster and then deploying the
hive-schema
Helm chart to it. We will use theazure-native
provider to create the AKS cluster, and thekubernetes
provider to deploy the Helm chart.The process consists of:
- Importing necessary packages and setting up the Pulumi program.
- Creating a new resource group to contain our AKS cluster.
- Creating an AKS cluster within the resource group.
- Configuring the Kubernetes provider to deploy resources to the created AKS cluster.
- Using the
Chart
resource to deploy thehive-schema
.
Let's walk through the code:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Create a resource group const resourceGroupName = new azure_native.resources.ResourceGroup("myResourceGroup"); // Create an AKS cluster const managedClusterName = new azure_native.containerservice.ManagedCluster("myManagedCluster", { resourceGroupName: resourceGroupName.name, agentPoolProfiles: [{ count: 1, maxPods: 110, mode: "System", name: "agentpool", osDiskSizeGB: 30, osType: "Linux", vmSize: "Standard_DS2_v2", }], dnsPrefix: "aks", enableRBAC: true, kubernetesVersion: "1.20.7", linuxProfile: { adminUsername: "adminuser", ssh: { publicKeys: [{ keyData: "<SSH PUBLIC KEY>", }], }, }, nodeResourceGroup: `MC_azurepulumi_${resourceGroupName.name}_myManagedCluster`, servicePrincipalProfile: { clientId: "<SERVICE PRINCIPAL CLIENT ID>", secret: "<SERVICE PRINCIPAL CLIENT SECRET>", }, }); // Create a provider for the AKS cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: managedClusterName.kubeConfig.apply(kubeConfig => kubeConfig), }); // Deploy the hive-schema helm chart const chart = new k8s.helm.v3.Chart("hive-schema", { chart: "hive-schema", version: "1.0.0", // Replace with the desired version of the chart fetchOpts:{ repo: "https://charts.example.com/", // Replace with the actual Helm repo URL }, }, { provider: k8sProvider }); // Export the Kubeconfig export const kubeconfig = managedClusterName.kubeConfig;
Replace
<SSH PUBLIC KEY>
,<SERVICE PRINCIPAL CLIENT ID>
, and<SERVICE PRINCIPAL CLIENT SECRET>
with your actual SSH public key and Azure service principal credentials. Also, replacehttps://charts.example.com/
with the Helm repository that contains thehive-schema
chart and adjust the version accordingly.You can create an SSH key pair using
ssh-keygen
on Linux or macOS, and using PuTTYgen on Windows.Make sure you have an Azure service principal with contributor access to the resource group. You can create one by following Azure's documentation.
The above code defines an AKS cluster with a single node pool. The
Provider
resource configures the Kubernetes provider to use the AKS cluster's kubeconfig, which is used by thehelm.v3.Chart
resource for deployment.Once you apply this program using Pulumi, it will set up the AKS cluster and deploy the
hive-schema
Helm chart to it. Remember that deploying this infrastructure will incur costs in Azure, based on the resources provisioned. You can always destroy the infrastructure created by Pulumi, which will remove all associated costs.To run this program:
- Install Pulumi and configure it to connect to your Azure account.
- Install Node.js if you haven't already.
- Save the above code to a file with a
.ts
extension, for example,index.ts
. - Run
npm install
to install the necessary dependencies. - Use
pulumi up
to preview and deploy the changes.
If you need more information about any of the resources used, you can visit the following documentation pages:
- For Azure Resource Group: ResourceGroup
- For Azure Kubernetes Service: ManagedCluster
- For Kubernetes Helm Chart: Chart