In this blog post, I will show you how I scale an application that is running on my Azure Kubernetes Service (AKS) with Kubectl.
Kubectl
The official Kubernetes command-line tool is kubectl (Kube Control) and it allows us to manage any Kubernetes cluster using the command line. As a Kubernetes engineer, you will spend a lot of time using Kubectl.
To scale an application, we need to scale deployment because in Kubernetes applications are deployments.
Install Kubectl
Before we scale any application, we need to first load the AKS tools to Azure CLI and yes, I’m am assuming you have Azure CLI installed on your machine and you are connected to Azure.
To install the Kubectl for AKS, from Azure CLI run the following two commands after you have logged in to azure. (to login to azure use az login).
The command below will install the kubectl commands for an AKS cluster.
az aks install-cli
Next, we need to retrieve login details for our AKS cluster using the following command. Make sure you change the command to fit your resource group and cluster name.
az aks get-credentials --resource-group RGNAME --name CLUSTERNAME
After login in, I will get the list of deployments that are active on the cluster using the command below and take note of the deployment name.
kubectl get deployments
Note: If your application is not in the default namespace use the namespace option to select it –namespace name. In the example below I am scaling my app to 3 containers.
kubectl scale deployment/myapp --replicas=3