Get up to 50% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

Bring your own Kubernetes cluster to Azure – Azure Arc

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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
#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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
#To enable monitoring on the worker nodes
curl -o enable-monitoring.sh -L https://aka.ms/enable-monitoring-bash-script
subscriptionId=""
clusterName=""
resourceGroup=""
analyticsWorkspace=""
kubeContext=""
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

Share :

Related Posts

OpenShift 4.5 : NooBaa S3 Bucket for internal image registry

OpenShift 4.5 : NooBaa S3 Bucket for internal image registry

Image registry storage is best and recommended to run on S3 storage endpoint(then filesystem storage, then block). In this blog context, we are going …

Deploying ML Models to the Edge using Azure DevOps

Deploying ML Models to the Edge using Azure DevOps

Training ML Models and exporting it in more optimized way for Edge device from scratch is quite challenging thing to do especially for a beginner in …

Remove nodes from Kubespray Managed Kubernetes Cluster

Remove nodes from Kubespray Managed Kubernetes Cluster

Kubespray is a combination of Ansible and Kubernetes and you can use Kubespray for deploying production ready Kubernetes clusters.

How to Label a Namespace in Openshift or Kubernetes

How to Label a Namespace in Openshift or Kubernetes

Image : joc.com Labeling an object in OpenShift or Kubernetes is an awesome method to organize, group, or select API objects. Labels can be used to …

HashiCorp Certified Terraform Associate – Learning & Exam Tips

HashiCorp Certified Terraform Associate – Learning & Exam Tips

Introduction I started using Terraform somewhere in 2018, but very limited usage as I thought it is just another tool for provisioning infrastructure …

Containerize Window Application & deploy into AWS Elastic Kubernetes Service (EKS)

Containerize Window Application & deploy into AWS Elastic Kubernetes Service (EKS)

Hi everyone! for this general walkthrough I will be explaining my experiences containerizing an Window Application into Window Container which will …