1. Azure Arc : Setting up 'Kubernetes - Azure Arc' with AKS cluster
We will also make use of Git Repository and Docker Hub registry. For this article, I will be using my public repo and hub but you are free to use yours.
- PassHours/Hello-AzureArc (git repo)
- atanudochub/helloazurearc (docker hub registry/image)
I have already developed a sample .Net core web app and uploaded it in my git repository. It's a very basic web app to display a welcome screen "Welcome to Azure Arc" but you got the idea 😊
- Lets go inside the resource group (arc-rg-01 in my case) where we have both our Kubernetes service cluster and the Kubernetes - Azure Arc cluster.
- Get into the Kubernetes - Azure Arc cluster and click the "GitOps" option from the left menu. It will be empty as we have configured nothing yet.
- Now the interesting part. We would like to deploy our Hello-AzureArc containerized application into our AKS cluster through the Azure Arc for Kubernetes GitOps channel and you would be surprised to see that how easy it is. Microsoft has done a great job in simplifying things here by providing a single command 👉 az k8sconfiguration create. All the heavy duty complex operations are taken care behind the scene for you.
az k8sconfiguration create \
--name <<your choice>> \
--cluster-name <<your cluster name>> \
--resource-group <<your k8s cluster resource group>> \
--operator-instance-name <<your choice>> \
--operator-namespace <<your choice>> \
--repository-url <<your git repo url>> \
--scope cluster --cluster-type connectedClusters \
--operator-params="--git-poll-interval 5s --git-readonly"
The interesting part to note here in the command is the last line --operator-params. This is the param where you are applying your gitops command. I am giving the command instruction here to poll my git repo (as mentioned in the --repository-url param) every 5 seconds (bit aggressive here for this demo but in real life it would be much higher value, may be every 30 mins), get all the changes and apply in my cluster. A typical continuous deployment scenario.
- Upon completion, you will find the configuration (hello-arc in my case) showing up under the GitOps menu. The Operator state will show "Pending" first and then will turn to "Installed" after completion of the deployment process. So, have some patience here.
- It signals done but we need to verify. Lets check our AKS cluster now in the following sequence in the Kubernetes resources section.
👉 Namespace. hello-arc is our namespace created successfully
👉 Workloads. Select the "Pods" tab and filter it by "default" namespace as we have not mapped it to any particular namespace and hence default. Three pods are up an running successfully.
👉 Services and ingresses. Our hello-arc-service is up and running having an external load balancer IP address.
Refer hello-azurearc.yml deployment yml in the git repo
- Click the External IP and voila! our app is running as expected. Auto magic isn't it 👼 We have just issued a single command and surprise!
So, I believe it's enough to witness the power of Azure Arc for Kubernetes. I have just touched the tip of the iceberg; purposefully avoided going deep as this could unnecessarily confuse readers and make the article long and complex. But you can explore. 👍
The most significant part is that your kubernetes cluster can be running anywhere (on premise or on any cloud); the process is exact the same. You can manage and deploy apps into your clusters running anywhere sitting right on Azure. Cool !
Now if you make any changes in your application; just dockerize it; update the image with a new version number and upload it to the registry. The git operation will fire up automatically; would read that from your deployment yml in the git repo; download the image from your container registry and deploy it in your cluster behind the scene as a part of continuous deployment.
You can also run all your kubectl commands on the cluster and it works just fine
That's
it.
Congratulations! for coming this far. Hope this article will help you to further explore more on this topic.
Do share with me about your experience and what you have built upon this
foundation. You can take it upto any level and integrate. I would love
to hear from you.
No comments:
Post a Comment