How to Deploy MongoDB on Kubernetes in 2 Minutes Using Helm Chart – Cloud-Native Best Practices

To deploy your Helm chart on an AKS (Azure Kubernetes Service) cluster, follow these step-by-step instructions. These cover setting up the AKS cluster, configuring kubectl, and deploying the Helm chart.

Prerequisites

Ensure the following tools are installed:

Step 1: Authenticate and Create AKS Cluster (If Not Already Done)

# Login to Azure
az login

# Set your subscription (optional)
az account set --subscription "<YOUR_SUBSCRIPTION_ID>"

# Create a resource group (skip if it already exists)
az group create --name myResourceGroup --location eastus

# Create AKS cluster (takes a few minutes)
az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 1 --generate-ssh-keys

Step 2: Connect kubectl to AKS

az aks get-credentials --resource-group myResourceGroup --name myAKSCluster

This command merges your AKS cluster context into ~/.kube/config.

Check connection:

kubectl get nodes

Step 3: Navigate to Your Helm Chart Directory

If your Helm chart is in DockercomposeNodejsMongodb/helm-chart:

cd DockercomposeNodejsMongodb/helm-chart

Step 4: Deploy the Helm Chart

helm install nodejs-mongodb ./

Check if the pods and services are up:

kubectl get all

Step 5: Access Your Node.js Application

By default, the service type is ClusterIP, which is internal-only. To expose it:

Option A: Change service-node.yaml to use LoadBalancer

Edit templates/service-node.yaml:

  type: LoadBalancer

Then upgrade the release:

helm upgrade nodejs-mongodb ./

Check the external IP:

kubectl get svc 

MongoDB is now deployed on AKS using Helm, with secure access and scalable infrastructure.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *