Voiced by Amazon Polly |
Introduction to AKS With Ingress
Azure Kubernetes cluster can leverage an ingress controller to facilitate the usage of a single Azure Load Balancer to forward traffic to multiple domains. The NGINX Ingress controller will listen to all the ingress events from all the namespaces and add corresponding directives and rules into the NGINX configuration file. It makes it possible to use a centralized routing file that includes all the ingress rules, hosts, and paths.
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
Scope
- Introduction to GrandNode E-Commerce Application
- Containerizing MongoDB and grandnode (.NET based e-commerce application)
- Running application locally
- Creating ACR repo and pushing container images to ACR
- Setting up Azure Kubernetes Service with Windows worker nodes
- Deploying Nginx Ingress Controller on AKS
- Deploying GrandNode E-commerce Application on EKS with persistent storage
- Configuring ingress for the applications and verification.
Technologies Used
- Azure Kubernetes Service
- Nginx Ingress Controller
- Grandnode
- MongoDB
- Azure LoadBalancer
- Azure Container Registry
- Azure Disk Storage
Pre-requisites
- Azure account
- GitHub account
- Azure CLI
- Windows Server 2019 / Windows 10 (If you use a different operating system, use corresponding source code and make required changes to the entire setup.)
- Docker
Application Overview
GrandNode is an a free and open-source e-Commerce platform based on the modern MongoDB database that enables the flexible development of online stores.
GrandNode requires .NET Core 6.0, MongoDB 4.0+, and OS-specific dependency tools.
Preparing MongoDB docker image
- Clone the GitHub repo at “https://github.com/aneez004/mongo-windows.git”. Switch to the git folder.
- Modify the mongodbuser.ps1 file
- Add database username and password of your choice or keep the defaults. Here we are adding the user “grandadmin” with a password “grand” to the database admin. In the Dockerfile, we are using mongo windows image as the base image, and we copy over the PowerShell script to create the db user.
- Build and tag the docker image with a preferred tag name
Preparing Grandnode docker image
- Clone the Github repo at “https://github.com/aneez004/grandnode2.git”. Navigate to the “grandnode2” folder.
- Verify the Dockerfile
- Build and tag the image
Running the E-Commerce Application Locally
- Run the mongodb docker container
- Run the grandnode docker container by linking to the MongoDB container
- Verify both containers are up and running
- Access the application from a browser at http://localhost:8080
- Enter company information. Under ‘Store Information’, provide admin email username and password.
- Under ‘Database Information,’ enter the following details:
- MongoDB Server Name: MongoDB (the same name you provide using –name option during docker run)
- Database name: admin
- Username: grandadmin (replace with what you have given in the mongodbuser.ps1 file)
- Password: grand (replace with what you have given in the mongodbuser.ps1 file)
Click on Install
- Restart the grandnode container
- Access the application at http://localhost:8080
- Access the admin page to modify your E-Commerce site. Enter the admin username and password provided during grandnode installation
Creating Container Registry for Application Container Images
- Login to Azure portal. If you don’t have an account, create a free account at https://azure.microsoft.com/en-us/free/
- Search and select ‘Container Registries’
- Click on Create container registry
- Select your subscription, create a new resource group and select it
- Enter a unique ‘Registry Name’. Note down this name for future requirements.
- Accept default values for the remaining settings. Then select Review + create. After reviewing the settings, select Create
- Note down the registry name and login server
Pushing Images to the Registry
- Install chocolatey (if not installed) using instructions from the link https://chocolatey.org/install.
- Install Azure CLI using the following command
- Log into your Azure account using azure cli using the following command
- Enter your credentials from the browser pop up window
- Log in to the Azure Container registry before pushing container images to the registry.
- Tag the docker images built in the previous sections in the Azure container registry name format. Replace the required values
- Push the application container images to the Azure container registry
- Verify the images are pushed
Creating AKS Cluster with Windows Worker Nodes
- Create a resource group for the AKS cluster. Use the same location used for creating container registry
- Create the cluster. Replace resource group name, windows admin username and password.
- If you are using a different Kubernetes version, make sure that version is supported in that region using the command
- Add a Windows Server node pool. An AKS cluster is created with a node pool that can run Linux containers by default. Add node pool that can run Windows Server containers alongside the Linux node pool
- Install kubectl locally using the command. Alternatively, you may install it using binaries or chocolatey
- Execute the following command to Get access credentials for the Kubernetes cluster
- Verify if the node pools are added and cluster is up and running
NGINX Ingress Controller Deployment on AKS Cluster
- Use the following command to deploy nginx ingress controller on the cluster
- Verify that the controller is deployed as intended by checking the pods and service in the namespace ingress-nginx
- Note down the external ip against the service ingress-nginx-controller. Access the ip from a browser
This confirms that the ingress controller is installed as intended - Integrate Azure Container Registry with the AKS cluster using the following command. Provide valid values for acr registry, cluster name and rg name
Deploying GrandNode E-commerce Application on AKS
- Navigate to the grandnode2 directory that you have earlier downloaded using git. Navigate to the directory manifests under grandnode2. List the files.
- Create namespace
- Create ‘azuredisk’ storage class with ‘Immediate’ volume binding mode
- Create persistent storage for both grandnode and mongodb in us region
- Create deployments and service files for mongodb and grandnode e-commerce application for us region. Verify all resources are created
- Set up ingress resource for the grandnode US application
- Repeat the steps to create Kubernetes resources for Canada region also.
Configure persistent storage for grandnode and mongo in Canada region - Create deployment and service resources
- Set up ingress resource for the grandnode US application
- Configure dns locally. Ideally it is required to add CNAME entries for your domain name at your domain registrar or where you have configured the dns server. For this demo, we are configuring dns locally.Open command prompt or powershell in Administrative mode. Execute the following command to edit the hosts file to set up temporary dns to point the hostnames to the external ip of nginx ingress loadbalancer.
Get the external ip associated with the nginx ingress controller using the following commandEdit the host file (C:\Windows\System32\drivers\etc\hosts) and add entries for us and Canada grandnode sites pointed against the nginx ingress loadbalancer ip address - Access the us site at http://us.grandnode.com (Replace with the values that you have used). Complete the installation by providing company information, store information and database information. Provide the mongodb server name as the service name corresponding to the mongo service in the us namespace (mongo-us-service).
- Provide db details and click on “Install”. Wait for the installation to complete
- Restart the grandnode deployment to complete the installation
- Access the site at http://us.grandnode.com
- Access the admin page for us grandnode application at http://us.grandnode.com/admin
- Repeat the steps for Canada grandnode deployment.Access the canada site at http://canada.grandnode.com (Replace with the values that you have used). Complete the installation by providing company information, store information and database information. Provide the mongodb server name as the service name corresponding to the mongo service in the canada namespace (mongo-canada-service).
- Restart the grandnode deployment to complete the installation
- Access the application at http://canada.grandnode.com
- Access the admin page at http://canada.grandnode.com/admin
Conclusion
Migration of windows workloads to Kubernetes is gaining acceptance as it offers increased flexibility, security, high availability and portability for their applications. Microsoft .NET applications can be now easily containerized and deployed on existing AKS Cluster by adding windows worker nodes to the existing cluster. Leveraging the functionalities of nginx as web-server, reverse-proxy and loadbalancer on the Kubernetes cluster facilitates usage of a single cloud Loadbalancer to forward traffic to large number of clients.
Drop a query if you have any questions regarding Containerization and we will get back to you quickly.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, and many more.
To get started, go through our Consultancy page and Managed Services Package, CloudThat’s offerings.
FAQs
1. What are the limitations of running multiple node pools on AKS?
ANS: –
- First node pool can’t be deleted.
- Windows server node pool name has a limit of 6 characters.
- AKS Cluster can have a maximum of 10 node pools.
2. What are the guidelines for selecting windows base images for containerization?
ANS: –
- Use ‘Windows server core’ if your application requires full .NET framework
- Use ‘Nano Server’ if building an application based on the .NET core
WRITTEN BY Nisarg Desai
Nisarg Desai is a certified Lead Full Stack Developer and is heading the Consulting- Development vertical at CloudThat. With over 5 years of industry experience, Nisarg has led many successful development projects for both internal and external clients. He has led the team for development of Intelligent Quarterly Remuneration System (iQRS), Intelligent Training Execution and Analytics System (iTEAs), and Cloud Cleaner projects among many others.
Click to Comment