Deploying applications in MS Azure AKS using Ingress (NGINX Ingress Controller)
- Microsoft Azure Kubernetes Service (AKS) is a fully managed container orchestration service. It reduces the complexity of container deployment and management and provides automation.
- Azure automatically creates and configures a Kubernetes control plane for each cluster. In addition, MS handles all Kubernetes upgrades and new version updates within AKS.
- Using AKS doesn’t attract cluster management and master node fees, unlike other platforms. Customer is charged for the network resources, worker nodes & other Azure resouces that are used.
- Infrastructure management is smooth; AKS elastically provisions resources, so customers/developers don’t need to worry about whether they’re being used effectively.
- Azure AKS Architecture :
A Kubernetes cluster is divided into two components:
- Control plane: provides the core Kubernetes services and orchestration of application workloads. This is managed by Azure
- Nodes: run client application workloads on Kubernetes.
- Control plane: provides the core Kubernetes services and orchestration of application workloads. This is managed by Azure
- Ingress is a Kubernetes API object that maps an application to a stable, externally addressable HTTP or HTTPS URL. It can route traffic to multiple services
- Ingress controllers work at layer 7 and can use more intelligent rules to distribute application traffic. Ingress controllers typically route HTTP/HTTPS traffic to different applications based on the inbound URL.
-
Clone the repository and navigate to the folder lab-05
-
Open powershell in administrator mode and login with below command. If you have multiple subscriptions then select the correct subcription by second command
$ az login --use-device
$ az account set --subscription <<-subsctption name/id->> (optional if you have multiple subcriptions) -
To view the current/default subscrition use the below command (optional).
$az account show --output table
-
Create resource group "aksdemo".
$ az group create --name aksdemo --location southeastasia -
Create an AKS cluster with 2 nodes (if you want to attach ACR then add --attach-acr )
$ az aks create --name aksdemo -g aksdemo --node-count 2 --generate-ssh-keys -
Switch context. (To configure kubectl to connect to your Kubernetes cluster, use the az aks get-credentials command).
$ az aks get-credentials -n aksdemo -g aksdemo -
Refer below commands for verification of contexts.
$ kubectl config view
$ kubectl config current-context (output should be aksdemo).
$ kubectl config get contexts
$ kubectl config use-context <<-context name->> -
Check nodes and pods in your AKS cluster.
$ kubectl get nodes -o wide
$ kubectl get pods -
Add a NGINX ingress controller without customizing the defaults. The last command is deprecated & if 3rd command works then no need to execute last command
$ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
$ helm repo update
$ helm install nginx-ingress ingress-nginx/ingress-nginx --create-namespace --namespace ingress-basic --set controller.replicaCount=2 --set controller.nodeSelector."kubernetes.io/os"=linux --set defaultBackend.nodeSelector."kubernetes.io/os"=linux
$ helm install nginx-ingress ingress-nginx/ingress-nginx --create-namespace --namespace ingress-basic --set controller.replicaCount=2 --set controller.nodeSelector."beta.kubernetes.io/os"=linux --set defaultBackend.nodeSelector."beta.kubernetes.io/os"=linux -
Verify NGINX controller installation
$ kubectl get pods -n ingress-basic -l app.kubernetes.io/name=ingress-nginx --watch -
Inspect the ingress controller Service
$ kubectl get svc -n ingress-basic -
Deploy the cats application (pod and ClusterIP service)
$ kubectl apply -f cats.yaml -
Deploy the "Dogs" application (pod and ClusterIP service)
$ kubectl apply -f dogs.yaml -
Deploy the "Birds" application (pod and ClusterIP service)
$ kubectl apply -f birds.yaml -
Create the ingress resource
$ kubectl apply -f ingress.yaml -
List existing pods & services
$ kubectl get pods
$ kubectl get svc -
List existing ingress
$ kubectl get ingress
- Get the ingress controller External IP (type LoadBalancer)
$ kubectl get svc -n ingress-basic - Browse to the cats, dogs and birds service
$ http://<<-ingress-controller-external-ip->>/cats
$ http://<<-ingress-controller-external-ip->>/dogs
$ http://<<-ingress-controller-external-ip->>/birds - Clean up resources
$ kubectl get all
$ kubectl delete all --all
$ kubectl delete ingress --all
$ kubectl delete all --all -n ingress-basic
$ kubectl delete namespace ingress-basic - List existing resources
$ kubectl get all - Clean your Azure enviornment. Other than "aksdemo" there will be an autogenerated resource group created which also needs to be deleted
$ az group delete --name <<-resource group name->> --yes -y
$ az group delete --name aksdemo --yes -y
- Kubernetes core concepts for Azure Kubernetes Service (AKS)
- Optimize compute costs on Azure Kubernetes Service (AKS)
- Top 10 Cost Optimization Techniques for AKS Workloads running in Azure
- Azure Kubernetes Service (AKS)
- What is Application Gateway Ingress Controller?
- Is ingress-nginx really a load balancer or not?
- Network concepts for applications in Azure Kubernetes Service (AKS)