With Azure Kubernetes Service you can create, configure and manage a cluster of VMs that can run containerized apps. Below are all the steps that someone needs to follow to create an Azure Kubernetes Service (AKS).
Prerequisites
- Create Service principal client ID
- Create Service principal client secret
- Download and install puttygen
- Download and install kubectl package latest version
- Download and install cmder tool
Create Service Principal Client ID
Below are the steps for a new Service Principal Client ID. From the main [Azure Active Directory] blade – [App registrations], select [+ New application registration].
Register New Application
Register a New app by filling up the required fields to create the app, as the below image shows.
Register New Application.
Next, we need to copy the Application ID from the DemoClusterApplication and keep it somewhere safe until the AKS Cluster creation.
Create Service principal client secret
In the previous step we created the Application ID and now we will generate the authentication key.
These can be done from the blade Settings – Keys, type a Description for the key and click Save.
Important Notice: Copy and keep somewhere safe the key value because after the first save it will be not visible.
Create Azure Kubernetes Service (AKS)
Now, we have completed the 2 first basic steps and it’s time to begin the Azure Kubernetes Service deployment.
Create a Resource Group
At the first step, we must create a Resource Group, which includes all the necessary resources for the deployment.
We need to provide a Name, select a Subscription, choose a Resource group location and click Create.
Create Resources – Azure Kubernetes Service -AKS
The resource group is deployed and we are ready to create the main resource Azure Kubernetes Service -AKS
Basics Tab
Fil up the Basics blade as shown in the following image,
Click Next Authentication button or Authentication tab to continue the cluster configuration.
Authentication Tab
In this step, we configure the cluster to authenticate with the Service principal.
Select Configure service principal, and on the new blade select Use existing {Service principal} and type the Service principal client ID and the Service principal client secret.
Service principal client ID | Type the Application ID from the “Service Principal client ID” step |
Service principal client secret | Type the Secret key, that we copy on “Service principal client secret” step |
Click Next: Networking >> button or Networking tab to move to the next step
Networking Tab
At the Networking tab choose for HTTP application routing Yes (default) and for Network configuration Basic (default) or Advanced. In this demo we choose Basic.
HTTP application routing | Integrated HTTP routing and public DNS for applications |
Network configuration | Choose between a basic network configuration using kubernetes with a default VNet, or an advanced configuration using Azure CNI with the option to customize your VNet. |
Click Next: Monitoring>> button or Monitoring tab to move to the next step,
Monitoring Tab
In this tab, we choose Yes(default) to Enable container monitoring, let the Log Analytics workspace as is or if we can create a new one.
Click Next: Tags>> button or Tags tab to move to the next step,
Tags Tab
At the Tags tab, we can add tags to the resources to easily manage the billing.
Review + Create Tab
At the final tab, we can make a quick review of the configuration and click Create to start deployment.
After a couple minutes( 15 – 20 minutes) the cluster is ready. And we can see a brand new Resource Group with all the resources in it.
DefaultResourceGroup -WEU | Contains the Log Analytics Workspace |
Demo-AzureContainerService | Contains the Kubernetes service |
MC_Demo-AzureContainerService_DemoCluster_westeurope | Contains the Kubernetes service resources, such as VMs, Disk, DNS Zone, Route Table , VNet, etc. |
Connect to the cluster
Now, we are ready to connect to the cluster. Open the cmder tool, and type the commands with the following order:
Step 1, Login to Azure
Step 2, Authenticate device login
At step 2, we must open the page https:// microsoft.com/devicelogin, and type the code CYVRBR5SL
Step 3, Get Credentials
Run the command, to get the config file into the path c:\Users\username\.kube\config
az aks get-credentials --resource-group Demo-AzureContainerService --name DemoCluster
Step 4, Verify Connection
kubectl get nodes
Step 5, Create YAML File Application
Info: YAML file is kubernetes manifest file which includes the cluster container images. |
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: azure-vote-back
spec:
replicas: 1
template:
metadata:
labels:
app: azure-vote-back
spec:
containers:
- name: azure-vote-back
image: redis
ports:
- containerPort: 6379
name: redis
---
apiVersion: v1
kind: Service
metadata:
name: azure-vote-back
spec:
ports:
- port: 6379
selector:
app: azure-vote-back
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: azure-vote-front
spec:
replicas: 1
template:
metadata:
labels:
app: azure-vote-front
spec:
containers:
- name: azure-vote-front
image: microsoft/azure-vote-front:v1
ports:
- containerPort: 80
env:
- name: REDIS
value: "azure-vote-back"
---
apiVersion: v1
kind: Service
metadata:
name: azure-vote-front
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: azure-vote-front
kubectl apply -f democluster.yaml
Step 6, Run The Application
get service az-demo-cluster-front