Skip to content

Bring your own Kubernetes cluster to Azure – Azure Arc

|

There are use cases where customers wants to bring on-premises resources to cloud and tap on cloud services to easily manage it as well. Microsoft Azure Arc helps you extend Azure management to any infrastructure and enables deployment of Azure data services anywhere. It actually simplify day to day monitoring and management of the resource from an operations perspective and you can leverage the goodness of cloud to on premise resources. Azure Arc is still in preview and currently supports Kubernetes, SQL Servers, VMs and HCI and additional features are being developed under the hood. Initially I thought to onboard my Raspberry Pi cluster to Arc, but unfortunately preview version doesn’t support armv7 or armv8 architecture yet. So in this article , we will setup a Kubernetes single node on a VM and integrate with Azure Arc.

We can easily setup a Kubernetes cluster using Rancher K3s. Please not that you need to have Azure Account and subscription to setup the following resources. You may create an account using the portal. The below code snippet is executed on the VM (Ubuntu-18.04).

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC=”server –tls-san $(curl ifconfig.me) \ –write-kubeconfig-mode 644″ INSTALL_K3S_CHANNEL=latest sh –

Once it has been setup, next step is install Azure CLI to login to your azure subscriptions and register azure providers for Kubernetes.

#Install Helm
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
#Install Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
#Azure Login via CLI
az login
#Azure Resource Group Creation
#Azure Arc is available only on eastus,westeurope,westcentralus
az group create -l eastus -n <ResourceGroupName>
#Add Azure extensions related to kubernetes
az extension add –name connectedk8s
az extension add –name k8sconfiguration
#Register Azure Providers for Kubernetes Configuration
az provider register –namespace Microsoft.Kubernetes
az provider register –namespace Microsoft.KubernetesConfiguration
#Check whether Azure providers has been installed. Will take approx 10 mins to register
az provider show -n Microsoft.Kubernetes -o table
az provider show -n Microsoft.KubernetesConfiguration -o table
#Create Azure Arc Resource and connect it
az connectedk8s connect –name <AzureArcName> –resource-group <ResourceGroupName> -l eastus

If the connection is successful, you would see the cluster in the Azure Arc.

Enable Monitoring in Azure Arc Kubernetes
To enable monitoring on Azure Arc resources, you need to have Log Analytics Workspace Resource created in the Azure resource group. Recommended to put in the same resource group where Azure Arc was created. You may follow the steps provided in this link to create it. Once its created, please use the below code snippet to enable the monitoring feature in Azure Arc

#To enable monitoring on the worker nodes
curl -o enable-monitoring.sh -L https://aka.ms/enable-monitoring-bash-script
subscriptionId="<subscriptionid>"
clusterName="<AzureArcName>"
resourceGroup="<ResourceGroupName>"
analyticsWorkspace="<AnalysticsWorkspaceName>"
kubeContext="<KubecontextName>"
azureArcClusterResourceId = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Kubernetes/connectedClusters/$clusterName"
logAnalyticsWorkspaceResourceId="/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.OperationalInsights/workspaces/$analyticsWorkspace"
#Install script
bash enable-monitoring.sh –resource-id $azureArcClusterResourceId –kube-context $kubeContext –workspace-id $logAnalyticsWorkspaceResourceId

If enablement is complete, the metrics from inside the Kubernetes cluster will gradually start appear in the app insights section.

We will be able check the metrics – CPU, Disk, Pod logs etc. from Kubernetes with Azure monitor – Insight. The metrics will be published in the log analytics workspace and also we can write custom query to fetch details and even configure alerts.

So we have covered the integration part of Kubernetes with Azure Arc and also the monitoring side. Hope Arc would go GA soon with extended support for other platforms. Like always, please share your feedback and share it.

References
Arc Installations
Enable Monitoring

A DevOps engineer by profession, dad, traveler and more interestingly to tweak around stuff inside memory constrained devices during spare time.

A DevOps engineer by profession, dad, traveler and more interestingly to tweak around stuff inside memory constrained devices during spare time.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.