Deploy and Access ngnix on AKS Cluster

Step1:

Store your resource group in a variable & create and verify AKS cluster

Step2: Configure kubectl to run against cluster

Step3: Create deployment.yaml file and apply the changes

apiVersion: apps/v1
 # The type of workload we are creating 
kind: Deployment
metadata:
  # Name of deployment - Required
  name: aks-web-app-deployment 
spec:
  replicas: 2
  selector:
    matchLabels: 
      app: aks-web-app
  # Pod template which decribes the pod you want to deploy
  template: 
    metadata:
      # Used to logically group pods together
      labels: 
        app: aks-web-app
    # Specific details about the containers in the Pod
    spec: 
      containers:
      - name: aks-web-app-container
        # Docker Hub image to use
        image: nginx 
        # Define ports to expose
        ports: 
        - containerPort: 80
          # Reference name of port
          name: http 
        resources:
          # Minimum amount of resources we want
          requests: 
            cpu: 100m
            memory: 128Mi
          # Maximum amount of resources we want
          limits: 
            cpu: 250m
            memory: 256Mi

Step4: Create Service.yaml file and apply the change

apiVersion: v1
 # The type of workload we are creating 
kind: Service
metadata:
# Name of Service - Required
  name: aks-web-app-service
# Specific details about the Service
spec:
# Type of Service to be deployed
  type: LoadBalancer
  ports:
  - port: 80
  # Used to tell the Service which Pods to associate with
  selector:
    app: aks-web-app

step 6:

After this, in few minutes, we can see external public IP gets generated!

Finally, we can access the app now!