The following README will guide you on how to use kind to run a Kubernetes cluster locally and connect it as an Azure Arc enabled Kubernetes cluster resource.
-
Clone this repo
git clone https://github.com/microsoft/azure_arc.git
-
Install or update Azure CLI. Azure CLI should be running version 2.7 or later. Use
az --version
to check your current installed version. -
Kind leverages Docker to run the Kubernetes nodes. You will need to install Docker locally:
- If you are a Windows user, install Docker Desktop. You can also use the Chocolatey package to automate the installation.
- If you are a MacOS User, install Docker Desktop for Mac.
- If you are a Linux user, use your package manager to install the Docker engine.
-
Install the Go programming language.
-
Create Azure Service Principal (SP)
To connect a Kubernetes cluster to Azure Arc, Azure Service Principal assigned with the "Contributor" role is required. To create it, login to your Azure account run the below command (this can also be done in Azure Cloud Shell).
az login az ad sp create-for-rbac -n "<Unique SP Name>" --role contributor
For example:
az ad sp create-for-rbac -n "http://AzureArcK8s" --role contributor
Output should look like this:
{ "appId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "displayName": "AzureArcK8s", "name": "http://AzureArcK8s", "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "tenant": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
Note: It is optional but highly recommended to scope the SP to a specific Azure subscription and Resource Group
-
Enable subscription for two providers for Azure Arc enabled Kubernetes
Registration is an asynchronous process, and registration may take approximately 10 minutes.az provider register --namespace Microsoft.Kubernetes Registering is still on-going. You can monitor using 'az provider show -n Microsoft.Kubernetes' az provider register --namespace Microsoft.KubernetesConfiguration Registering is still on-going. You can monitor using 'az provider show -n Microsoft.KubernetesConfiguration'
You can monitor the registration process with the following commands:
az provider show -n Microsoft.Kubernetes -o table az provider show -n Microsoft.KubernetesConfiguration -o table
-
Install the Azure Arc for Kubernetes CLI extensions connectedk8s and k8sconfiguration:
az extension add --name connectedk8s az extension add --name k8sconfiguration
Note: If you already used this guide before and/or have the extensions installed, use the az extension update --name connectedk8s
and the az extension update --name k8sconfiguration
commands.
-
Install kind
-
On Linux:
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64 chmod +x ./kind sudo mv ./kind /usr/local/bin/kind
-
On MacOS:
brew install kind
-
On Windows:
choco install kind
-
-
Navigate to the folder that has the kind cluster definition.
cd azure_arc/azure_arc_k8s_jumpstart/kind
-
Create the kind cluster. We are using a configuration file called
kind_cluster.yaml
to specify our cluster configuration. This will create a 3 node cluster, with 1 master node and 2 worker nodes.kind create cluster --config kind_cluster.yaml --name arc-cluster
Note: By default, kind will store the kubeconfig file used to connect to your cluster in the ~/.kube directory. If you want to use a custom directory to store the kubeconfig file, use the
--kube-config
flag. If you did chose a specific location for the cluster's kubeconfig file make sure you are exporting its location as an environment variable using theexport KUBECONFIG=kubeconfig location
or in Windows, add this location to your PATH. -
Verify your cluster was created successfully and you can access the cluster using
kubectl
.kubectl get nodes
Now that you have a running kind cluster, lets connect the kind cluster to Azure Arc.
bash az login --service-principal -u mySpnClientId -p mySpnClientSecret --tenant myTenantID
-
Create a resource group
az group create --name Arc-kind-Demo -l EastUS -o table
Note: Azure Arc enabled Kubernetes is currently supported in East US and West Europe
-
Deploy the Arc binaries using Azure CLI:
az connectedk8s connect -n Arc-kind-Demo -g Arc-kind-Demo --tags 'Project=jumpstart_azure_arc_k8s'
-
Upon completion, you will have your kind cluster connected as a new Azure Arc Kubernetes cluster resource in a new Resource Group.