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](https://github.co/hiddenchars)
[Show hidden characters](/bring-your-own-kubernetes-cluster-to-azure-azure-arc/{{ revealButtonHref }})
#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
#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 –resource-group -l eastus
[view raw](https://gist.github.com/mysticrenji/d3a7b179be7ce578d29e8fc3a0c828f3/raw/db5d4c9103c9c5b2f25a4c8f617f43535ae89fc2/InstallScripts.sh) [InstallScripts.sh](https://gist.github.com/mysticrenji/d3a7b179be7ce578d29e8fc3a0c828f3#file-installscripts-sh) hosted with ❤ by [GitHub](https://github.com)

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](https://github.co/hiddenchars)
[Show hidden characters](/bring-your-own-kubernetes-cluster-to-azure-azure-arc/{{ revealButtonHref }})
#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
[view raw](https://gist.github.com/mysticrenji/a9ec25604114d7305ad4d1727908b32f/raw/8c2775f47da09fede72cec9c3b96c80bc00ba8ab/InstallMonitoring.sh) [InstallMonitoring.sh](https://gist.github.com/mysticrenji/a9ec25604114d7305ad4d1727908b32f#file-installmonitoring-sh) hosted with ❤ by [GitHub](https://github.com)

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

Renjith Ravindranathan

Renjith Ravindranathan

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


Note

Disclaimer: The views expressed and the content shared in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.

Share :

Related Posts

Experimenting GitHub Container Registry

Experimenting GitHub Container Registry

Recently GitHub announced public beta availability of their Container Registry and I thought I will give it a try. So in this article I will take you …

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 …

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 be …