Connect civo k3s Cluster with Azure ARC
First of Kubernetes aka k8s is a defacto orchestration engine for everyone now (believe it or not). Since people are creating kubernetes clusters in multiple clouds, on-premise, and trying to avoid a vendor lock-in kind of scenario there comes a need to manage all the clusters from one place. Now there are a lot of tools that help to do that and today I will be discussing Azure ARC.
Back in 2019 Azure ARC was announced to closed preview and now it's available for all to experiment with. So what Azure arc lets you do, it helps you to manage infrastructure not running in Azure. Kubernetes clusters running in different cloud vendors or on Premise can leverage the Azure Tech stack for management.
to Explain how Azure ARC will help consider a scenario that you have 50 clusters spanned across various cloud vendors and on premise, With Azure Arc you will be able to get a unified view for all the clusters and also you will be able to leverage:
- RBAC Major thing I would say is the access control and ability for the developers to deploy applications on all the clusters from a single place with the GitOps model. Which sounds interesting to me.
Image is taken from Azure official blog
civo cloud has created a first-ever managed k3s cluster(you can get access by applying here ). So I will be using the k3s(certified kubernetes distribution) cluster. First login to civo cloud and create a cluster pretty simple and fast in less than 2 minutes as follows:
Let the cluster get created meanwhile let's configure and enable Azure ARC 1) Install Azure CLI - docs
2) Run following commands to enable azure arc feature
az login az feature register --namespace Microsoft.Kubernetes --name previewAccess az feature register --namespace Microsoft.KubernetesConfiguration --name sourceControlConfiguration Verify the enablement by : az feature list -o table | grep Kubernetes Microsoft.Kubernetes/previewAccess Registered Microsoft.KubernetesConfiguration/sourceControlConfiguration Registered
Now Register the providers
az provider register --namespace Microsoft.Kubernetes az provider register --namespace Microsoft.KubernetesConfiguration Check if they are completed: az provider show -n Microsoft.Kubernetes -o table az provider show -n Microsoft.KubernetesConfiguration -o table
All these commands will take some time to take effect so show some patience here.
Install kubernetes extensions(either add or update)
az extension add --name connectedk8s az extension add --name k8sconfiguration az extension update --name connectedk8s az extension update --name k8sconfiguration
Install Helm3 as Azure Arc used Helm 3 for installing the agents on the cluster. You can install helm 3 from the docs.
3) Go to Azure Arc in Azure portal
Select Register Cluster Screen 1 will show all the prerequisite steps to be performed out of which I have done all except downloading the kubeconfig file
you can download the kubeconfig file from the civo cloud ui
Screen 2 just enter the cluster details
Screen3 Run the commands as shown (point the kubeconfig to the right config file)
Screen4 Verification page shows the cluster is connected and after finishing you can setup gitops, Azure monitoring and Compliance policies.
From the kubectl you can see the components running
kubectl get pods -n azure-arc --kubeconfig config NAME READY STATUS RESTARTS AGE flux-logs-agent-799cb595f5-4qvqf 2/2 Running 0 11m metrics-agent-784cddf6c6-l6hrg 2/2 Running 0 11m controller-manager-7d6f9f56b5-8tqxq 3/3 Running 0 11m resource-sync-agent-d86c6ddd-z7h7c 3/3 Running 0 11m cluster-metadata-operator-745954d56d-nc5fk 2/2 Running 0 11m clusteridentityoperator-5497448799-xdv9h 3/3 Running 0 11m config-agent-57889d49d6-k6g28 3/3 Running 0 11m
That's it the cluster is now connected to Azure Arc. Let us try some GitOps now go to configurations and click add configuration and define the git repo from where you want to. have the application deployed on the cluster directly. In this case, I am taking sample git repo by azure
BOOM all the things get deployed automatically
kubectl get all -n demo --kubeconfig config2 NAME READY STATUS RESTARTS AGE pod/memcached-86bdf9f56b-r8d96 1/1 Running 0 14s pod/demom-558478cbcb-kndmd 1/1 Running 0 14s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/memcached ClusterIP 192.168.191.38 <none> 11211/TCP 14s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/memcached 1/1 1 1 15s deployment.apps/demom 1/1 1 1 15s NAME DESIRED CURRENT READY AGE replicaset.apps/memcached-86bdf9f56b 1 1 1 15s replicaset.apps/demom-558478cbcb 1 1 1 15s
you can access the application and the port where the azure-vote-front service is running
kubectl get svc --kubeconfig config2 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE azure-vote-back ClusterIP 192.168.202.113 <none> 6379/TCP 14m azure-vote-front LoadBalancer 192.168.129.104 <pending> 80:30823/TCP 14m
It's pretty easy to connect the cluster and deploy the application onto kubernetes directly using Git. You will also be able to use helm to deploy the application from the configuration. Other things that can be done is setting up azure monitor and polices
Saiyam Pathak [CKA | CKAD | CNCF Ambassador]