Date

AKS Lab: Working with AKS Cluster

Summary

In this Lab article we will create Deployment with Service (Basic Load Balancer) for IIS website

Prerequisites

Azure subscription for Azure Azure Kubernetes Cluster, Azure Container Registry, kubeclt and Azure CLI module for Windows

Step by Step process

1. Add Azure Container Registry to ASK Cluster

 az aks update -n "azureCluster" -g aksGroup --attach-acr acrRepository 

2. Crate a Deployment and Service with Azure Network Load Balancer

Deployment Template example

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deploy-profile
  labels:
    app: deploy-profile 
spec:
  replicas: 2
  selector:
    matchLabels:
      app: deploy-profile
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: deploy-profile
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": windows
      containers:
      - image: acrrepository.azurecr.io/portfolio:latest
        name: portfolio 
        ports:
          - containerPort: 80
        resources: {}
status: {}

Services Template example

apiVersion: v1
kind: Service
metadata:
  name: deploy-profile
spec:
  type: LoadBalancer
  ports:
  - protocol: TCP
    port: 80
  selector:
    app: deploy-profile

3. Create Deployment and Service for IIS website

Create Deployment using .yaml template

 kubectl apply -f deploy.yaml 

deployment.apps/deploy-profile created

Check Deployment status

 kubectl get deployment 

NAME             READY   UP-TO-DATE   AVAILABLE   AGE

deploy-profile   2/2     2            2           18s

Create Service using .yaml template

 kubectl apply -f service.yaml 

service/deploy-profile created

Check Service status

 kubectl get service 

NAME             TYPE           CLUSTER-IP    EXTERNAL-IP    PORT(S)        AGE

deploy-profile   LoadBalancer   10.x.x.103   52.x.x.36   80:30464/TCP   18s

kubernetes       ClusterIP      10.x.x.1      <none>         443/TCP        71m

4. To view the Website running in the AKS Cluster, note LoadBalancer External IP

LoadBalancer   EXTERNAL-IP: 52.x.x.36

Open a Browser and type LoadBalancer   EXTERNAL-IP: 52.x.x.36 as URL

4. Check Logs for Pods

 kubectl logs <Pod-Name> 

5. Kubernetes Dashboard

 Kubectl create clusterrolebinding kubernetes-dashboard -n kube-system `  

 >> --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard 

AZmachina

Knowledge Shared = Knowledge2

We have created AZmachina blog to share our knowledge on Docker & Container and Kubernetes on Windows Servers with curious and enthusiastic novice learner. We hope that this will help them to take a swim in this vast ocean of Window Containers and Kubernetes

Happy Learning !
Recent Posts
Categories
Archives
Sumeet Kumar

Sumeet Kumar

I am Windows Core Engineer with 7+ years of experience in Windows Hyper-v, Failover Cluster, Windows Storage, Volume Shadow Copy (VSS), Docker & Containers on Windows Servers, Backup & Recovery, VMware vSphere EXSi & vCenter Server

RELATED

Articles

Leave a Reply

Your email address will not be published. Required fields are marked *