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