Deploy the kube-plex helm chart on Azure Kubernetes Service (AKS)
TypeScriptDeploying the kube-plex Helm chart on Azure Kubernetes Service (AKS) requires a few steps. First, you will need to create an AKS cluster, then configure your Kubernetes provider to use the credentials for the AKS cluster, and finally deploy the kube-plex chart using the Helm chart resource.
Let's go through the process step by step.
Step 1 - Creating an AKS Cluster
The
azure-native
provider'sManagedCluster
resource is what we'll use to create the AKS cluster. This sets up a Kubernetes cluster managed by Azure and allows you to configure the number of nodes, node size, and other properties.Step 2 - Configuring the Kubernetes Provider
Once an AKS cluster is provisioned, you have to obtain the
kubeconfig
to configure the Kubernetes provider. Thiskubeconfig
allows Pulumi to connect to your AKS cluster and manage Kubernetes resources.Step 3 - Deploying kube-plex using Helm Chart
Finally, we'll use the
Chart
resource from thekubernetes
provider to deploy the kube-plex Helm chart. The chart can be found in its Helm repository or as a packaged.tgz
file.Here's how you could write this as a Pulumi program in TypeScript:
import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create the AKS cluster const resourceGroup = new azure_native.resources.ResourceGroup("myResourceGroup"); const cluster = new azure_native.containerservice.ManagedCluster("myCluster", { resourceGroupName: resourceGroup.name, agentPoolProfiles: [{ count: 3, vmSize: "Standard_DS2_v2", name: "agentpool", mode: "System" }], dnsPrefix: "myakscluster", // Provide your DNS prefix enableRBAC: true, kubernetesVersion: "1.18.14", linuxProfile: { adminUsername: "adminuser", ssh: { publicKeys: [{ keyData: "ssh-rsa ..." // Your public key string }] } }, nodeResourceGroup: "myaksnodegroup", servicePrincipalProfile: { clientId: "xxxxx", // Your service principal client ID secret: "xxxxx" // Your service principal client secret } }); // Step 2: Configure the Kubernetes provider to connect to the AKS cluster const creds = pulumi.all([cluster.name, resourceGroup.name]).apply(([clusterName, rgName]) => azure_native.containerservice.listManagedClusterUserCredentials({ resourceName: clusterName, resourceGroupName: rgName, })); const kubeconfig = creds.kubeconfigs[0].value.apply(enc => Buffer.from(enc, 'base64').toString()); const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig }); // Step 3: Deploy the kube-plex Helm chart const kubePlexChart = new k8s.helm.v3.Chart("kube-plex", { chart: "kube-plex", fetchOpts: { repo: "https://billimek.com/repo/", // URL of the repository where kube-plex is hosted }, values: { // Specify the values for the kube-plex Helm chart } }, { provider: k8sProvider }); // Export the Cluster's kubeconfig and the service endpoint of kube-plex export const kubeConfigOutput = kubeconfig; export const kubePlexServiceEndpoint = pulumi.interpolate`http://${kubePlexChart.getResourceProperty("v1/Service", "kube-plex", "status").apply(status => status.loadBalancer?.ingress[0].ip)}`;
Explanation
-
The
azure_native.resources.ResourceGroup
resource defines a new resource group where all other resources will reside. -
azure_native.containerservice.ManagedCluster
creates the AKS cluster in the resource group. Note thatdnsPrefix
,servicePrincipalProfile.clientId
, andservicePrincipalProfile.secret
should be replaced with your actual values. The same applies to thelinuxProfile.ssh.publicKeys.keyData
, where you should provide your SSH public key to access the cluster nodes. -
We use the
listManagedClusterUserCredentials
function to retrieve the cluster credentials after the AKS cluster is provisioned. -
Create a Kubernetes provider instance with the obtained
kubeconfig
to manage Kubernetes resources within the AKS cluster. -
The
k8s.helm.v3.Chart
resource is used to deploy the kube-plex Helm chart to your Kubernetes cluster. Therepo
field insidefetchOpts
should be the URL of the Helm repository where kube-plex is stored, and thevalues
should be an object with configuration values specific to kube-plex.
Finally, the program exports the
kubeConfigOutput
to access the Kubernetes cluster usingkubectl
and thekubePlexServiceEndpoint
, which will be the external endpoint to access kube-plex once it's deployed.Running this program while having Pulumi configured with the appropriate Azure credentials should result in the deployment of the kube-plex Helm chart on your AKS cluster. Remember to replace placeholder values with your actual details (e.g., SSH keys, service principal details, etc.) before running it.
-