Deploy the typesense helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the Typesense Helm Chart on an Azure Kubernetes Service (AKS) cluster, you'll need to complete a few steps:
- Set up an AKS cluster: This is where your Typesense application will be deployed.
- Install Helm: Helm is a package manager for Kubernetes, which you will use to deploy Typesense.
- Deploy the Typesense Helm Chart: You will use Helm to deploy the Typesense application onto your AKS cluster.
Below is the Pulumi program written in TypeScript that sets up a new AKS cluster and deploys the Typesense Helm Chart on it.
Detailed Steps in TypeScript:
- Initial setup: Import necessary Pulumi and Azure packages.
- Create a resource group: This logical container holds related resources for an Azure solution.
- Create an AKS cluster: Using the
ContainerService
resource to instantiate the cluster. - Configure Kubernetes provider: Set up the Kubernetes provider to point to the created AKS cluster.
- Install Typesense using the Helm Chart: Add the Helm Chart resource to your program that points to the Typesense chart.
Let's go through the code step-by-step:
import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Set up an AKS cluster const resourceGroup = new azure.core.ResourceGroup("resourceGroup", { location: "WestUS", }); const aksCluster = new azure.containerservice.KubernetesCluster("aksCluster", { resourceGroupName: resourceGroup.name, location: resourceGroup.location, defaultNodePool: { name: "aksagentpool", nodeCount: 2, vmSize: "Standard_DS2_v2", }, dnsPrefix: `${pulumi.getStack()}-kube`, servicePrincipal: { clientId: process.env.CLIENT_ID, clientSecret: process.env.CLIENT_SECRET, }, }); // Export the kubeconfig export const kubeConfig = aksCluster.kubeConfigRaw; // Step 2: Install Typesense using Helm Chart const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: aksCluster.kubeConfigRaw, }); const typesenseChart = new k8s.helm.v3.Chart("typesense", { chart: "typesense", version: "0.1.0", // Use the specific chart version fetchOpts: { repo: "https://charts.typesense.org", // Official Typesense Helm Chart repository }, }, { provider: k8sProvider }); // Export the Typesense service endpoint export const typesenseEndpoint = typesenseChart.getResource("v1/Service", "typesense").status.loadBalancer.ingress[0].ip;
In this code:
- We start by importing the necessary modules.
- We create a new Azure resource group in the
WestUS
region. - We provision an AKS cluster with a small default node pool that consists of two nodes.
- The
kubeConfig
of the created AKS cluster is exported so that you can use it to interact with your cluster usingkubectl
. - The
k8s.Provider
is configured with the exported kubeconfig file. This is essential for interacting with the AKS cluster. - We then declare a Helm Chart resource that corresponds to the Typesense chart. Note that you need to provide the appropriate chart version and the repository URL where the Typesense Chart is hosted.
After the program is executed, you'll have an AKS cluster running with the Typesense application installed via its Helm chart. The
typesenseEndpoint
variable at the end of the script is exported, which you can use to access the Typesense service.Please replace
process.env.CLIENT_ID
andprocess.env.CLIENT_SECRET
with your actual Azure Service Principal credentials. These are required for creating the AKS cluster.To run this Pulumi program:
- Save the code into a file named
index.ts
. - Run
pulumi up
to start the deployment process. - After the deployment completes, you can use the output
kubeConfig
to interact with your AKS cluster andtypesenseEndpoint
to access the Typesense service.
Remember to configure your Pulumi environment with
pulumi login
and set up the Azure CLI withaz login
before running the script. Also, make sure you have Helm installed if you intend to manage Helm releases directly.