Deploy the gitlab-aio helm chart on Azure Kubernetes Service (AKS)
TypeScriptDeploying the GitLab all-in-one (AIO) Helm chart on Azure Kubernetes Service (AKS) involves several steps. First, you must create an AKS cluster, then you need to configure helm on your local machine so that you can deploy GitLab using its official Helm chart. For the purpose of this explanation, we will focus on defining the AKS cluster using infrastructure as code with Pulumi.
We'll be using the
azure-native
provider since it provides management capabilities for native Azure resources and is actively developed to keep up with ever-evolving Azure services. Specifically, we will use theazure-native.aks.Cluster
resource to create a managed Kubernetes cluster in Azure.After setting up the AKS cluster, we'll use the
kubernetes
provider along with thekubernetes.helm.v3.Chart
resource to deploy the gitlab-aio Helm chart into our cluster. Thekubernetes.helm.v3.Chart
resource allows us to deploy packaged applications into Kubernetes clusters using Helm charts.Here's a program in TypeScript that achieves this:
import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure-native"; import * as k8s from "@pulumi/kubernetes"; const config = new pulumi.Config(); // Create an Azure Resource Group const resourceGroup = new azure.resources.ResourceGroup("myResourceGroup"); // Create an AKS cluster const cluster = new azure.containerservice.ManagedCluster("myAksCluster", { resourceGroupName: resourceGroup.name, agentPoolProfiles: [{ count: 2, vmSize: "Standard_DS2_v2", name: "agentpool", osType: "Linux", }], dnsPrefix: "myakscluster", linuxProfile: { adminUsername: "aksuser", ssh: { publicKeys: [{ keyData: config.require("sshPublicKey") }], }, }, servicePrincipalProfile: { clientId: config.require("clientId"), secret: config.requireSecret("clientSecret"), }, }); // Export the Kubeconfig export const kubeconfig = cluster.kubeConfigRaw; // Create a K8s provider instance using the kubeconfig from the AKS cluster const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeConfigRaw, }); // Deploy gitlab-aio Helm chart using the k8s provider const gitlabChart = new k8s.helm.v3.Chart("gitlab", { chart: "gitlab", version: "4.10.3", // use the version that suits your needs namespace: "gitlab", fetchOpts:{ repo: "https://charts.gitlab.io/", }, values: { global: { edition: "ce" // use "ee" (Enterprise Edition) if you have access to EE features } }, }, { provider: k8sProvider }); // Export the GitLab URL by constructing it using the service load balancer's IP export const gitlabUrl = pulumi.interpolate`http://${gitlabChart.getResourceProperty("v1/Service", "gitlab-webservice-default", "status")["loadBalancer"]["ingress"][0]["ip"]}`;
To use this code, first, replace the placeholders with your values:
config.require("sshPublicKey")
should be replaced with your actual SSH public key.config.require("clientId")
andconfig.requireSecret("clientSecret")
should be replaced with your Azure service principal credentials.
Once you have this code, run it with Pulumi by saving it to a
index.ts
file, and then runningpulumi up
. Make sure you have the Azure CLI installed, are authenticated, and have Pulumi installed.The
kubeconfig
is exported as an output variable. This is the kubeconfig file of your new AKS cluster, which you will use withkubectl
to interact with your cluster.The
gitlabUrl
output will present the load balancer IP to access your GitLab instance after it's fully deployed.Keep in mind that installing and managing Helm Charts often involves additional configuration regarding values that might depend on your specific needs, especially for a complex application like GitLab. Always refer to the official GitLab Helm chart documentation for more details on configuration options you may require.