Introduction
In this article, we will learn and deploy the different types of services in the Azure Kubernetes Services (AKS) Clusters. Let's get started.
Azure Kubernetes Service
Azure Kubernetes Service (AKS) is a managed container orchestration service provided by Microsoft Azure. AKS allows us to manage the applications rather than the infrastructure.
AKS has an autoscaling feature and also simplifies the deployment of the application.
Types of AKS services
- Cluster IP: Exposes the service on an internal IP in the cluster. Its default service is Kubernetes.
- NodePort: Superset of ClusterIP. Exposes the service on the same port of each selected node in the cluster.
- LoadBalancer: Superset of NodePort. Creates an external load balancer in the current cloud and assigns an external IP to the service.
Steps to Create AKS Cluster
Log in to the Azure portal (https://portal.azure.com/)
Search Kubernetes services in the search bar.
Click Create option in the Kubernetes Services window.
First, provide an Azure subscription.
Create a new resource group named testRG.
Type Kubernetes cluster name as retailcluster02.
Choose the Azure region as US West US.
Choose the Kubernetes version as default.
Select Node Size as the Standard DS2_v2 option, which is recommended for standard configuration.
Choose Scale Method as the Autoscale option.
Specify the Node Count range as a 1:3 combination means 1 Master Node and 3 Worker Nodes.
Click the Review+Create button.
You will get a message as Validation passed on the screen and click Create button.
Click Create button.
The deployment started initialized in a minute or two it will become successful.
Click the Go to Resource button.
Retailcluster02 appears on the screen in you click Connect button.
Once you clicked the connect to the cluster, it will be redirected to the Cloud shell option.
Once Cloud shell is opened and you have to create storage first.
Suppose the users type the commands as kubectl get svc. You can notice by default; it displays the ClusterIP service.
YAML File for nginx-deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
The users can expose the deployment to the NodePort by changing the type as NodePort in the expose command as
kubectl expose deployment nginx-deployment --name=np-service --type=NodePort
At last, the users can expose the deployment to the LoadBalancer service by changing the type.
kubectl expose deployment nginx-deployment --name=lb-service --type=LoadBalancer
Click Services & Ingresses in the retailcluster02 window.
The users can see the list of available Kubernetes resources.
Click the External IP option.
You will get nginx-deployment opened in the new tab with the welcome mess. Welcome to nginx!
Summary
In this article, we successfully created and deployed Azure Kubernetes Service cluster management and learned different types of service in the AKS cluster end-to-end deployment.
Thanks for reading this article!!!