How to Expose Applications on AKS Externally Using HTTP

Azure Container Service (AKS) makes it easy to deploy and manage containerized applications in Azure.

You can use AKS to host your applications, or you can use AKS as a platform to build and deploy your own Kubernetes-based solutions. This article will show you how to expose your Azure Kubernetes Service (AKS) applications externally using HTTP.

Azure Kubernetes Service (AKS) provides a great way to manage your Kubernetes applications without having to worry about the underlying infrastructure. You can expose your AKS applications externally using Azure Load Balancer, built into any AKS cluster by default.

Manifest

In the following manifest file, I have a web application that exposes port 80 (HTTP) and a service configuration for that port.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-deploy
spec:
  replicas: 2
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
        - name: web-app
          image: nginx
          ports:
            - containerPort: 80
              name: http
      restartPolicy: Always

---
apiVersion: v1
kind: Service
metadata:
  name:  web-app
spec:
  type: LoadBalancer
  selector:
    app:  web-app
  ports:
    - port: 80
      name: http 
      protocol: TCP 
      targetPort: http 

To deploy the application, I will run the following command

kubectl apply -f deployment.yaml

Find External IP

To find the external IP address of the application, I will use the following kubectl command.

kubectl get service

Once I have the external IP, I will open it using a web browser and test the application.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.