Azure Kubernetes Service (AKS) is a managed Kubernetes service that helps you to deploy and manage clusters with ease. This post describes the commands in steps required to setup a Kubernetes cluster from the command line using the Azure CLI.
Prerequisites
- Azure subscription
- Azure CLI
Create an Azure Kubernetes Service
Step 1. Open Terminal and login to the Azure Portal:
az login
Step 2. Create a resource group:
az group create --name "rg-aks-test" --location westeurope
Step 3. Create a Kubernetes cluster in the resource group that we’ve just created:
az aks create --resource-group "rg-aks-test" --name "aksdevcoopstest" --node-count 1 --generate-ssh-keys --node-vm-size Standard_D2s_v3
Step 4. Install the Kubernetes CLI. There are 2 ways to do this:
- Install kubectl
az aks install-cli
Step 5. Configure kubectl to connect to the Kubernetes cluster:
az aks get-credentials --resource-group "rg-aks-test" --name "aksdevcoopstest"
Step 6. Verify the connection to the cluster:
kubectl get nodes
Cleanup
Step 7. Delete the Azure Kubernetes Cluster:
az aks delete --resource-group "rg-aks-test" --name "aksdevcoopstest" --yes --no-wait
Step 8. Delete the resource group:
az group delete --name "rg-aks-test"
Conclusion
If Azure is your cloud of choice, then Azure Kubernetes Service provides the most easiest and secure way to deploy and manage a Kubernetes cluster. AKS has a CI/CD integration with Azure DevOps, and the rest of the Azure services like ACR as container registry and Azure Key Vault for storing and managing secrets.
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on telegram.
