Deploy the laravel-worker helm chart on Azure Kubernetes Service (AKS)
TypeScriptTo deploy the
laravel-worker
Helm chart on Azure Kubernetes Service (AKS) using Pulumi, we need to follow these steps:- Set up an AKS cluster.
- Configure
kubectl
to connect to the newly created AKS cluster. - Use the Helm chart resource to deploy
laravel-worker
onto the AKS cluster.
We will use Pulumi with TypeScript to do this. The following Pulumi program performs the steps mentioned above.
First, make sure you have Pulumi installed and the Azure CLI authenticated to your account.
Here's the detailed Pulumi program for deploying the
laravel-worker
Helm chart on AKS:import * as azure from "@pulumi/azure"; import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create an AKS cluster to deploy the laravel-worker Helm chart. const name = "aks-cluster"; const resourceGroup = new azure.core.ResourceGroup(`${name}-rg`, { location: "West US", }); const aksCluster = new azure.containerservice.KubernetesCluster(name, { resourceGroupName: resourceGroup.name, defaultNodePool: { name: "aksagentpool", nodeCount: 2, vmSize: "Standard_DS2_v2", }, identity: { type: "SystemAssigned", }, dnsPrefix: `${pulumi.getStack()}-kube`, linuxProfile: { adminUsername: "adminuser", sshKey: { keyData: "<SSH PUBLIC KEY>", // Replace with your SSH public key. }, }, servicePrincipal: { clientId: process.env.AZURE_CLIENT_ID!, clientSecret: process.env.AZURE_CLIENT_SECRET!, }, }); // Export the kubeconfig. export const kubeconfig = aksCluster.kubeConfigRaw; // Step 2: Use a KubeConfig to connect to the AKS cluster. const k8sProvider = new k8s.Provider("k8s-provider", { kubeconfig: aksCluster.kubeConfigRaw, }); // Step 3: Deploy the laravel-worker Helm chart on the AKS cluster. const chart = new k8s.helm.v3.Chart("laravel-worker", { chart: "laravel-worker", version: "1.0.0", // Replace with the desired version of the laravel-worker Helm chart. // You can specify the repo URL if the chart is not from the stable repository. // repo: "<URL of the Helm repository>", namespace: "default", // Add any custom values you want to provide in the `values` field like below: // values: { // image: "my-laravel-worker-image", // tag: "latest", // }, }, { provider: k8sProvider }); // Export the public endpoint of the laravel-worker service. export const frontendService = chart.getResourceProperty("v1/Service", "laravel-worker", "status").apply(status => status.loadBalancer.ingress[0]);
In this program:
- We are creating an Azure resource group and an AKS cluster with system-assigned managed identity and a default node pool configuration. You need to replace
<SSH PUBLIC KEY>
with your actual SSH public key. - We're exporting the
kubeconfig
so that you can usekubectl
to interact with the AKS cluster outside of this Pulumi program. - We instantiate a Pulumi Kubernetes provider using the
kubeconfig
of the AKS cluster. - We then deploy the
laravel-worker
Helm chart using its name and version, in thedefault
namespace. You need to replace1.0.0
with your desired version of the Helm chart. If your Helm chart is stored in a custom repository, you need to specify its URL. - Finally, we're exporting the public endpoint of the
laravel-worker
service after deploying the Helm chart.
Note: Pulumi tracks the state of your resources, and running subsequent
pulumi up
commands will update your infrastructure with respect to changes in this program.To execute this Pulumi program, run
pulumi up
in the directory of this project, and Pulumi will handle the provisioning and deployment process.Remember, the above program makes several assumptions:
- That you have appropriate subscriptions and permissions in Azure.
- Your Pulumi environment is already set up and authenticated with Azure.
- You have set your Azure Client ID and Secret as environment variables, accessible via
process.env.AZURE_CLIENT_ID
andprocess.env.AZURE_CLIENT_SECRET
. - You have the
laravel-worker
chart available or know the repository URL where the chart is hosted, and you may need to provide specific chartvalues
depending on your configuration.
If you need to change configurations such as the number of nodes in your AKS cluster or the VM size, modify the
defaultNodePool
properties accordingly. For more complex applications, you may also need to set up ingress controllers, persistent volumes, or configure RBAC rules, which can all be done through Pulumi Kubernetes resources.