Create a Kubernetes Cluster in Azure Container Service

In the previous post, we built a Docker image and then pushed it to Azure Container Registry to host. Now in this one, I am going to show…

Create a Kubernetes Cluster in Azure Container Service

In the previous post, we built a Docker image and then pushed it to Azure Container Registry to host. Now in this one, I am going to show you how to create a Kubernetes Cluster in Azure Container Service.

Azure Container Service allows you to quickly deploy a production ready Kubernetes, DC/OS, or Docker Swarm cluster. Learn how to use Azure Container Service with these quickstarts, tutorials, and samples.

Kubernetes on-premises seems to get bad press about it being hard to setup, though I haven’t tried to configure it my self from scratch, it seems to be pretty straight-forward when we create Kubernetes Cluster in Azure Container Service.

Creating the Kubernetes Cluster

We can use the “az acs create” Azure CLI command to create the Azure Container Service with a Kubernetes Cluster in it.

az acs create --orchestrator-type kubernetes --resource-group azurecontainerservicepoc --name AramK8SClusterPoc --generate-ssh-keys

The azurecontainerservicepoc is the resource group we generated in our Azure subscription in the previous post.

The AramK8SClusterPocis Kubernetes Cluster name.

This command might take few minutes to finish and will return a json result with some information about the Azure Container Service that it created.

Get the Kubernetes CLI going

To be able to connect to this Kubernetes cluster we created in Azure from our client computer we need to install the Kubernetes CLI or command-line interface or kubectl. You can find more information about the kubectl from the following link:

kubectl
Production-Grade Container Orchestrationkubernetes.io

If you are using the Azure Command Shell then the kubectl is already installed. And if not you can install it with the following command (you need to run your command prompt in elevated permission or Administration mode):

az acs kubernetes install-cli

Note the path where this command downloads the kubectl.exe file because you are going to need it for the next steps.

Connect to the Kubernetes Cluster

Now we can use the kubectl commands to connect to the Kuberetes Cluster we created in Azure Container Service.

To setup our kubectl to connect to the Kubernetes cluster on ACS, we can use the following command:

az acs kubernetes get-credentials --resource-group azureContainerServiceEast --name AramK8SClusterPoc

To verify the connection to your cluster, run the kubectl get nodes command.

To do that navigate to the path (shown in the previous step) and run the following command:

kubectl get nodes

And you can see the list of nodes in this Kubernetes Cluster:

Now our Kubernetes with 4 nodes are ready to put our code in them.

In the next post I will show you how you can deploy your images to this cluster and manage them with Kubernetes in Azure Container Service.

Cheers!