CANARY DEPLOYMENT IN AZURE KUBERNETES SERVICE

Part 1: Setting Up Azure Kubernetes Service

Shubham Singh
3 min readAug 20, 2020

Bonjour
In this blog I’ll help you setup your Kubernetes Cluster and Nodes using Azure Kubernetes Service (AKS). This Blog is a part of the series CANARY DEPLOYMENT IN AKS.
Please follow these steps to create your own AKS Cluster

Step 1: Creating a Service Pipeline and Secret

  1. Open your Azure Active Directory
  2. Click on App Registration and create a new service pipeline. It should look similar to the one shown in the image. Copy the Application (client) ID and save it in notepad or other text editor

3. Click on Register
4. Next click on Certificate and Secret and create a new client secret. You must copy this secret and save it in your notepad or some other text editor as this will be displayed only once. The two credentials should look something like this: (see the image below)

Step 2: Creating AKS Cluster using Azure CLI

For this blog I am going to use azure bash shell inside azure portal, but you can use any terminal or powershell you like. The reason I am using it because it comes with lots of inbuilt tools like Docker, Kubectl, Azure CLI etc.

  1. Open your Azure Bash/ Azure Powershell from inside your azure portal

2. Execute the below command. Remember to replace the blocks within <> brackets with your own names.

1. CREATE A RESOURCE GROUP
$ az group create --location <westus> --name <MyResourceGroup>
2. CREATE AN AKS CLUSTER
TEMPLATE
$ az aks create
--resource-group <RESOURCE-NAME>\
--name <CLUSTER-NAME> \
--node-count <NODE-COUNT> \
--enable-addons monitoring \
--generate-ssh-keys \
--service-principal "<service principal created in step 1>" \
--client-secret "<secret key created in step 2>"
EXAMPLE
$ az aks create
--resource-group MyResourceGroup\
--name dev \
--node-count 1 \
--enable-addons monitoring \
--generate-ssh-keys \
--service-principal "56c57a4e—5373—4af5—89cf—fdc7a06d1583" \
--client-secret "848.1eyN7q2X1.317NyU5—wuF~Ag't119Ne"

You should see an output screen something similar to the below image. It will take sometime for the process to complete (around ~10 minutes)

Step 3: Get access credentials for a managed Kubernetes cluster.

After running the below command, a directory .kube directory will be create in User Home. This will contain a config file. PLEASE STORE THIS FILE ONLY ON TRUSTED SYSTEM ONLY. ANYONE HAVING THE ACCESS TO YOUR KUBECONFIG FILE CAN CONTROL YOUR CLUSTER.

File location: $HOME/.kube/config

TEMPLATE:
az aks get-credentials --name <CLUSTER_NAME> \
--resource-group <RESOURCE_GROUP_NAME>\
[--admin] [--context] [--file] [--overwrite-existing] \ [--subscription]
EXAMPLE:
$ az aks get-credentials --name MyManagedCluster --resource-group MyResourceGroup

Learn more about this here

Step 4: Execute Kubectl Commands

  1. Please check that you have docker, kubectl installed on your virtual machine, in case you are not using azure bash/ powershell.
  2. You are all set to run your favorite kubectl commands.
$ kubectl get svc
$ kubectl get nodes
$ kubectl get pods
$ kubectl get deploy

HERE ARE SOME LINKS THAT WILL HELP YOU INSTALL KUBECTL, DOCKER AND DETAILS ABOUT AKS.

  1. Setup up your docker and Kubectl [HERE]
  2. Learn more about AKS [HERE]
  3. AZ AKS COMMANDS [HERE]

Thank you, Hope you enjoyed reading it.

PART 2 OF THE BLOG IS AVAILABLE HERE

--

--

No responses yet