Deploy the rabbitmq-stomp helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the RabbitMQ-STOMP helm chart on an Azure Kubernetes Service (AKS) cluster, you'll need to take the following high-level steps:
-
Set up an AKS Cluster: First, you need to have an AKS cluster running on Azure. If you already have one, you can skip this step. If not, you'll need to create one. The
azure-native
Pulumi provider offers the necessary resources to create and configure an AKS cluster. -
Install the Helm Chart: Once you have your Kubernetes cluster, you can deploy RabbitMQ using the Helm package manager. Pulumi's
kubernetes
provider supports deploying Helm charts directly.
Below is a Pulumi program written in TypeScript that first creates an AKS cluster and then deploys the RabbitMQ-STOMP helm chart to it.
import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; import * as azuread from "@pulumi/azuread"; import * as k8s from "@pulumi/kubernetes"; import * as tls from "@pulumi/tls"; // Create an Azure Resource Group const resourceGroup = new azure.core.ResourceGroup("rg", { location: "West US", }); // Create an Azure AD Application for AKS const aksApp = new azuread.Application("aks", {}); // Create a Service Principal for the AD Application const aksSp = new azuread.ServicePrincipal("aksSp", { applicationId: aksApp.applicationId }); // Create a random password for the Service Principal const password = new tls.RandomPassword("password", { length: 20, special: true, }); // Create the Service Principal password const aksSpPassword = new azuread.ServicePrincipalPassword("aksSpPassword", { servicePrincipalId: aksSp.id, value: password.result, endDate: "2099-01-01T00:00:00Z", }); // Create the AKS cluster const cluster = new azure.containerservice.KubernetesCluster("aksCluster", { resourceGroupName: resourceGroup.name, kubernetesVersion: "1.18.14", servicePrincipal: { clientId: aksApp.applicationId, clientSecret: aksSpPassword.value, }, defaultNodePool: { name: "aksagentpool", nodeCount: 2, vmSize: "Standard_DS2_v2", }, // Setting DNS prefix is optional dnsPrefix: `${pulumi.getStack()}-kube`, }); // Export the KubeConfig export const kubeConfig = cluster.kubeConfigRaw; // Create a Kubernetes provider instance that uses the KubeConfig from the AKS cluster we just created const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeConfigRaw, }); // Deploy RabbitMQ-STOMP helm chart on the AKS cluster using the Helm Chart resource const rabbitmqChart = new k8s.helm.v3.Chart("rabbitmq", { chart: "rabbitmq", fetchOpts:{ repo: "https://charts.bitnami.com/bitnami", }, version: "8.22.1", // specify the version of the chart to deploy // Define values for the RabbitMQ Helm chart values: { // Set the STOMP plugin to enabled extraPlugins: "rabbitmq_stomp", // Any other RabbitMQ configurations can be set here }, }, { provider: k8sProvider }); // Export the RabbitMQ service endpoint export const rabbitmqEndpoint = pulumi.all([rabbitmqChart.getResourceProperty("v1/Service", "rabbitmq", "status"), cluster.name]) .apply(([status, name]) => `http://${status.loadBalancer.ingress[0].ip}:15672`);
Explanation:
-
We start by creating an Azure Resource Group to contain all our Azure resources.
-
Then, we setup an Azure AD Application and Service Principal, which are required for AKS to interact with other Azure services.
-
We create a service principal's password securely.
-
Next, we instantiate an AKS cluster with the service principal credentials.
-
We export the raw Kubernetes configuration (KubeConfig) required to interact with the Kubernetes cluster programmatically.
-
Using the KubeConfig, we create an instance of the Pulumi Kubernetes provider. This allows us to deploy Kubernetes resources to our AKS cluster.
-
Finally, we deploy the RabbitMQ-STOMP Helm chart to the AKS cluster using Pulumi's Helm chart resource.
This program assumes that your Pulumi stack is configured for Azure and that you have the necessary permissions to create resources in your Azure subscription.
You can run this program with the Pulumi CLI by simply executing
pulumi up
after setting up your Pulumi project and stack. Please ensure that you have Helm installed and configured on your system if necessary.The program's last lines export the AKS cluster's KubeConfig and RabbitMQ service endpoints so that you can access your RabbitMQ instance once it's deployed.
-