Kubernetes is here to stay. We saw the orchestration wars between many platforms and as we know, Kubernetes came out on top. Even some of the platforms that were/are creating orchestration platforms are now adopting Kubernetes. With a highly focused piece of technology like Kubernetes, there are a ton of moving parts. How can we resolve that?
Using Azure Arc with a combination of tools like Azure DevOps, Kubernetes Manifests, and Helm, for example, enables deployments to any cluster that exists in Arc at scale. This means that you can take any application that currently exists in Kubernetes and kick it up a notch. That application can now exist in multiple Kubernetes clusters without the need to come up with a work-around to accomplish this.
In this blog post, we'll take a look at getting a Kubernetes cluster connected to Azure Arc.
Before Arc, I managed multiple Kubernetes clusters for clients that all used the same application (the in-house app). The problem was, the entire setup had to be done again and again for each client. There wasn't a clean work-around to deploy the same application to multiple Kubernetes clusters. Arc now enables us to do that.
To follow along with this blog post, you should have:
- A working knowledge of Kubernetes.
- An Azure subscription. If you don't have one, you can sign up for a free 30-day trial here.
- Azure Command-Line Interface (AZ CLI) installed and logged into. If you need to install AZ CLI, you can do so here. After the installation is complete, run
az loginon a terminal.
Creating a Kubernetes Cluster
Before connecting a Kubernetes cluster to Azure Arc, you need to ensure you have an existing Kubernetes cluster. Azure Arc expects a Kubernetes cluster to already exist as it doesn't create the cluster for you, but instead, connects it.
Creating a Kubernetes cluster can be done via the Azure CLI. Although there are many other ways, this blog post will follow that approach.
Open up a PowerShell terminal as an administrator. To create the AKS cluster, run the following code. The code below will create an AKS cluster with a Kubernetes API version of 1.15.1 and a worker node count of 1.
az aks create -g MyResourceGroup ` -n MyManagedCluster ` --kubernetes-version 1.15.11 ` --node-count 1
Installing the Azure CLI Extensions for Arc
After the Kubernetes cluster is created, it's time to enable the extensions for Azure CLI to connect the Kubernetes cluster to Azure Arc. To do this, you will need to register two providers for Azure Arc and install two extensions.
Registering the Providers
To register the two providers, open up PowerShell and run the following AZ CLI commands.
az provider register --namespace Microsoft.Kubernetes az provider register --namespace Microsoft.KubernetesConfiguration
Once complete, you should see an output similar to the screenshot below.
The register does take a few minutes. If you want to monitor the registration process, you can run the following commands.
az provider show -n Microsoft.Kubernetes az provider show -n Microsoft.KubernetesConfiguration
Installing the Extensions
After the registration is complete, the extension for AZ CLI will need to be installed. To install the extensions, run the following commands.
az extension add --name connectedk8s az extension add --name k8sconfiguration
Once the extensions are installed, you should see an output similar to the screenshot below.
Connecting to a Cluster
Now that the registrations, extensions, and Kubernetes cluster is ready to go, it's time to connect the Kubernetes cluster to Azure Arc. The following instructions will show you how to connect one cluster to Arc, but you can use the same steps to connect multiple clusters to Arc.
To connect the AKS cluster to Azure Arc, run the following AZ CLI command.
az connectedk8s connect --name Kubernetes_Cluster_Name --resource-group AzureArcTest
Once you run the above command in a terminal, you will see an output similar to the screenshot below. The connection from AKS to Arc will take a few minutes.
Congratulations! You have successfully connected an Azure Kubernetes Service cluster to Arc, one of the newest Microsoft in-preview platforms.
Azure Arc is a huge game changer with the way we manage applications in Kubernetes today. There is now a true centralized location that Kubernetes clusters can live. In this blog post, you learned how to connect an AKS cluster to Arc by using the AZ CLI.