Exploring Azure Kubernetes Service: A Practical Approach
This 2 step series - in continuation with the deploy-app-azure-free as BASE.
Please refer to STEP 1 here
*************************************************************************
NOTE: Listed steps are accurate as of June 2024 for the Azure portal.
*************************************************************************
This blog targets to:
Create Azure Kubernetes Cluster in connection with the Azure Container Registry, i.e. already created.
Deploy the image to created cluster and
Check if the deployed service is working from the AZURE cluster.
*************************************************************************
To create AKS, I went to the Azure portal search bar and searched for ‘aks’.
Clicked ‘kubernetes services’
Clicked the ‘Create’ button.
Selected ‘Kubernetes cluster’ from the list displayed.
‘Subscription’ is autofilled and as of now I have only one.
Selected the same resource group I used for ACR. i.e. ‘readit-app-rg’
In cluster details; select ‘Dev/Test’ for Cluster preset configuration.
Entered the ‘Kubernetes cluster name’
Region selected nearer to my location – same in my all configuration.
For ‘AKS pricing tier’, keep ‘Free’. (Options available are Free, Standard and Premium)
Although the tier is free, the infrastructure it requires will cost. (such as VM, Storage and Networking etc.)
Kept the default selected version for ‘Kubernetes version’
For ‘Automatic upgrade’, selected the recommended one ‘Enable with patch’
Rest remaining as it is.
Clicked on the ‘Integrations’ tab.
Selected the ‘Container registry’ as ‘readitnitin’.
Clicked ‘Review + create’
Reviewed changes and clicked ‘Create’ on the review stage.
Deployment is complete and clicked on the ‘Go to resource’
Cluster is up and running.
ACR is connected.
Now to connect VSCode to AKS, I have to download AKS CLI and install it in VSCode.
AKS has its own CLI which is kubernetes CLI.
Go to VSCode terminal
Type ‘az aks install-cli’ and hit enter.
Considering the suggestion highlighted in the ss above – post azure aks cli installed successfully; re-launching the VSCode to help installation take effect.
Entered ‘az login’ command to make sure my VScode is connected with my AZ account- it was successful.
Now I want to connect to the AKS cluster, ang get credentials. For doing that, Hit
‘az aks get-credentials --resource-group readit-app-rg --name cart-aks’ command.
Hit ‘kubectl get nodes’ command to see nodes available in the cluster.
2 nodes are up.
The # nodes are decided by AKS. This number can go up and down as needed. BUT for orchestration, we at least need 2 nodes.
I can now deploy my containers to ASK.
To deploy the workloads to AKS. ‘deployment.yaml’ file plays an important role. It contains all details for workload related configuration.
NOTE the important part from ‘deployment.yaml with regards to ASK – connection to container registry.
I will now deploy my containers to AKS.
Using ‘kubectl apply –f deployment.yaml’ and hit enter.
This means:
The pods were created
The service for the pods created. – Service is a public endpoint which allows pods to be accessible from outside.
Trying to access the ‘cart’ service deployed to AKS.
Go to the Azure portal and navigate to clusters created and connected from local.
Expand ‘Kubernetes resources’ click ‘Services and ingresses’
This list is of services created by AKS + the service I deployed to.
The status is ‘Ok’ and type is ‘load balancer’. This is the only service from the cluster accessible externally.
Rest all are AKS internal services and resources.
Clicked on ‘readit-cart’ service.
On the ‘Pods’ tab, I see ‘running’ pods.
Copy the ‘External Ip’ and hit enter in the new browser.
NOTE the URL
This is how we deploy the containers to ASK from VSCode.
************************** NOTE OF CAUTION *****************************
Don’t forget to delete the AKS and ACR.
First - stop running cluster.
Then Delete.
Clicked ‘Delete’
Deleting ACR
And the 2 step exercise to demonstrate:
Create ACR, deploy image to ACR from VSCode
Create AKS, connect it with ACR, deploy image to cluster from VSCode and accessing the application
Is successful.
Subscribe to my newsletter
Read articles from Nitin directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nitin
Nitin
A Seasoned gate keeper for software quality (Manual / Automation (Web + Mobile native + API) / Performance test) with 13 years of experience, An automation🤖 lover and a continuous📚 learner. A test automation geek and a DevOps engineer using and exploring cloud☁️. Looking for opportunities in Cloud DevOps for mutual growth. (Working remotely since last 5 years with teams in Europe / USA and Canada)