Skip to main content

Connect kind k8s cluster to Azure Arc

· 4 min read
Hasan Gural

If you haven't already used kind for deploying local Kubernetes, I strongly suggest you explore it and use it for testing the Kubernetes cluster itself. In this article, I am not going to dive into kind tool because this article is not intented to focus on this. If you are willing to learn kind tool, please search on the blog and get practice on it.

We will be primarily focusing how we can connect kind kubernetes cluster to Azure Arc. As you know, this demonstration is not for production usage but it will give you insights when you have connected kubernetes cluster to Azure Arc.

⚡Prerequisites for deploying Kind k8s Cluster

Here are the steps we will need to follow in this article

  • Clone the Azure Arc Git Repository
  • Install or update Azure CLI to version 2.25.0 and above.
  • Create Service Principal which has an access on subscription. Contributor role is required.
  • Docker Desktop for kind installation - kind is using Docker container “nodes”.
  • Install and configure kubectl.
  • Install Helm3
  • Install the Go programming language.

🚀Connecting kind k8s Cluster to Azure Arc

Before running below commands, please make sure that you have already connected your Azure Subscription using Azure CLI.

Preparing resource providers and Azure CLI for Azure Arc-enabled Kubernetes.
az provider register --namespace 'Microsoft.Kubernetes'
az provider register --namespace 'Microsoft.KubernetesConfiguration'
az provider register --namespace 'Microsoft.ExtendedLocation'
info

Above executions might take up-to 10 minutes to complete. Once it is completed, you can verify it executing the below commands.

Check registration is completed successfully
az provider show -n 'Microsoft.Kubernetes' -o table
az provider show -n 'Microsoft.KubernetesConfiguration' -o table
az provider show -n 'Microsoft.ExtendedLocation' -o table
Gain Azure-Arc Kubernetes extensions on Azure CLI
az extension add --name 'connectedk8s'
az extension add --name 'k8s-configuration'
danger

You might have already installed above extension on your Azure CLI. It is always good to have latest version of the extensions. You can follow below commands to upgrade installed extensions.

💬Optional: Upgrade existing extensions on Azure CLI
az extension update --name 'connectedk8s'
az extension update --name 'k8s-configuration'
🌱Installation and usage example for kind

I assume that in this guidance you will use Windows OS for practicing the article. If you're familiar with using choco package manager, you can get quickly the kind from it.

choco install kind
choco install golang
choco install kubernetes-helm

In order to create brand new kind k8s cluster, you can follow below config file to spin up it.

🧱 Option 1 - Config File for Kind
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: worker
- role: worker
- role: worker
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
authorization-mode: "AlwaysAllow"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
🧱 Option 2 - Use Azure Arc Jump Start config file.

I will continue with this option because it has been provided from Microsoft Official repository for Azure-Arc Connected kind clusters. Configuration of Option 1 should work seamlessly as well.

Before creating cluster you must do git clone for Azure Arc Jumpstart Repository.

git clone 'https://github.com/microsoft/azure_arc.git'

cd 'azure_arc/azure_arc_k8s_jumpstart/kind'

Once we function the git clone and change directory command, we are on the right path for creating cluster using Microsoft Provided config file.

kind create cluster --config 'kind_cluster.yaml' --name 'arc-demo-cluster'
caution

After executing the commands, you can validate your cluster is up-and-running using kubectl get nodes.

🧑‍💻 Deploying Azure-Arc agent into kind k8s cluster.

Create a resource group for putting kind k8s cluster as an Azure Resource.

az group create --name 'rg-arc-resources' -location'westus' -o table

I want to remind you when you execute below command, we have installed AZ-CLI and kubectl on the same terminal so we can manage everyhing in one place. For Deploying the Azure-Arc agents we will need to execute:

az connectedk8s connect -n 'arc-kind' -g 'rg-arc-resources' --tags 'Project=azure_arc_kind_k8s'