Welcome to the next lesson on deploying our Blog Platform to Kubernetes!
In our previous session, we successfully deployed all our backend microservices—Auth, Blog, and the API Gateway—to our EKS cluster. Each service is running in its own Deployment and is discoverable through an internal ClusterIP Service. However, our application is still completely sealed off from the outside world. Today, we will change that.
Our goal is to expose our API Gateway to external traffic using a Kubernetes Ingress and an AWS Application Load Balancer (ALB). This is the final and crucial step to making our backend accessible over the internet.
Learning Goals for This Lesson
- Understand the roles of a Kubernetes
Ingressand the AWS Load Balancer Controller. - Write an
Ingressmanifest to route external traffic to ourgateway-service. - Apply the manifest and verify that an AWS ALB is provisioned and correctly configured.
- Learn how to debug common issues related to Ingress and the Load Balancer Controller.
MERN Stack Comparison
In the MERN world, when you deploy a backend API, you need a way to route public traffic to your Node.js process. You might put a reverse proxy like NGINX in front of it or use a managed service like AWS Elastic Load Balancing (ELB) or Vercel's routing layer. You configure this proxy with rules, for instance, "all traffic to api.myblog.com should go to my server running on port 3000."
A Kubernetes Ingress is the declarative, Kubernetes-native way to define these rules. You write a YAML file that says, "I want traffic for path / to go to my gateway-service." A special piece of software called an Ingress Controller then reads this file and automatically configures the underlying infrastructure (in our case, an AWS Application Load Balancer) to make it happen.
1. Understanding Ingress and the AWS Load Balancer Controller
Before we write any code, let's clarify the key components.
- Ingress: A Kubernetes resource that defines rules for routing external HTTP/S traffic to services within the cluster. It can handle path-based routing, host-based routing, and TLS termination.
- Ingress Controller: A program running in your cluster that watches for
Ingressresources and uses them to configure a load balancer. It's the engine that implements the Ingress rules. - AWS Load Balancer Controller: The specific Ingress Controller we use for EKS. It integrates directly with AWS APIs. When it sees an
Ingressresource, it automatically provisions and configures an AWS Application Load Balancer (ALB) for you.
This architecture is powerful because you manage your cloud infrastructure directly from your Kubernetes manifests, keeping everything version-controlled and in one place.

To understand the benefits of this controller-based approach over older methods, it's worth watching a short introduction.
AWS Load Balancer Controller Tutorial (TLS): AWS EKS Kubernetes Tutorial - Part 6
The first couple of minutes of this video from Anton Putra provide an excellent explanation of why the AWS Load Balancer Controller exists and the advantages it offers over the legacy, in-tree Kubernetes controller.
Watch from the beginning until 02:24. Focus on understanding the limitations of the old system (slow release cycle, NodePort inefficiency) and the benefits of the new controller (independent releases, direct-to-pod routing).
2. Creating the Ingress Manifest
Now, let's write the manifest that will expose our gateway-service.
In your kube directory, create a new file named ingress.yaml.
# kube/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gateway-ingress
annotations:
# Specifies that the AWS Load Balancer Controller should handle this Ingress
kubernetes.io/ingress.class: "alb"
# Creates a public, internet-facing Load Balancer
alb.ingress.kubernetes.io/scheme: internet-facing
# Routes traffic directly to Pod IPs, which is more efficient
alb.ingress.kubernetes.io/target-type: ip
spec:
rules:
# Rule for all HTTP traffic
- http:
paths:
# A catch-all rule for any path
- path: /
pathType: Prefix
backend:
service:
# The name of the Service to route to
name: gateway-service
# The port of the Service to route to
port:
number: 80
Let's break down the most important parts:
-
metadata.annotations: This is where the magic happens for the AWS Load Balancer Controller.kubernetes.io/ingress.class: "alb": This annotation is deprecated in favor ofspec.ingressClassName, but is still widely used and tells Kubernetes that thealbcontroller is responsible for this Ingress.alb.ingress.kubernetes.io/scheme: internet-facing: This provisions a public ALB with a public IP address. The alternative isinternalfor private traffic within your VPC.alb.ingress.kubernetes.io/target-type: ip: This is a key optimization. It instructs the ALB to register the private IPs of yourgateway-servicePods directly as targets. This bypasses an extra network hop through the Kuberneteskube-proxy, resulting in lower latency and better performance.
-
spec.rules: This defines the routing logic.- We create a single rule that matches any path (
path: /,pathType: Prefix). - The
backendspecifies that all matching traffic should be sent to theServicenamedgateway-serviceon its port80.
- We create a single rule that matches any path (
For a clear, concise text reference on Ingress manifests and their annotations, the following article is very helpful.
How To Expose Multiple Applications on Amazon EKS Using a ...
The blog post 'How To Expose Multiple Applications on Amazon EKS...' provides a practical walkthrough. The section on creating the Ingress file is particularly relevant.
Read part 'C) Finally, let’s define our Ingress' in the article. Compare their Ingress manifest with ours. Note the similarities in annotations and the spec.rules structure. This reinforces the common patterns for defining an ALB Ingress.
3. Apply, Verify, and Test
It's time to bring our application online.
Prerequisite: The AWS Load Balancer Controller must be installed in your cluster. If you followed the standard eksctl cluster creation process, it may already be there. You can check with:
kubectl get deployment -n kube-system aws-load-balancer-controller
If the command returns a deployment, you're good to go. If not, you will need to install it. The videos referenced provide detailed instructions on this one-time setup.
-
Apply the Ingress Manifest:
From your project's root directory, run:kubectl apply -f kube/ingress.yamlOutput should be
ingress.networking.k8s.io/gateway-ingress created. -
Check the Ingress Status:
The controller will now start provisioning the ALB in AWS. This can take a few minutes. You can monitor its progress with:kubectl get ingress gateway-ingressInitially, the
ADDRESScolumn will be empty. Wait and run the command again. Once provisioning is complete, you will see the public DNS name of your new ALB:NAME CLASS HOSTS ADDRESS PORTS AGE gateway-ingress <none> * k8s-default-gatewayi-xxxxxxxx-xxxxxxxx.us-east-1.elb.amazonaws.com 80 2mCopy this address. This is the public entry point to your entire application!
-
Test the Endpoint:
Let's assume your API Gateway routes requests to/api/blogsto theblog-service. You can now test this publicly usingcurl:curl http://<your-alb-address>/api/blogsIf everything is configured correctly, you should receive a response (likely an empty list
[]if your database is empty) from yourblog-service, served through the API Gateway and the AWS Load Balancer.
Congratulations! Your microservices application is now live on the internet.
4. Debugging-First: When the Ingress Address Stays Empty
One of the most common problems is applying an Ingress manifest and seeing the ADDRESS field remain empty indefinitely.
-
Cause: This almost always means the AWS Load Balancer Controller is not running, has crashed, or lacks the correct IAM permissions to create resources in your AWS account.
-
How to Debug:
-
Check the Controller Logs: This is your primary source of truth. The controller runs in the
kube-systemnamespace.kubectl logs -n kube-system deployment/aws-load-balancer-controllerLook for any error messages. You might see
AccessDeniederrors if IAM permissions are wrong, or other errors related to misconfiguration. -
Describe the Ingress: Get the events associated with your Ingress resource.
kubectl describe ingress gateway-ingressScroll to the bottom
Eventssection. You might see an error message directly attached to the Ingress, giving you a clue. For example:Error syncing load balancer: failed to ensure load balancer: ... -
Check Controller Pod Status: Make sure the controller pod itself is running.
kubectl get pods -n kube-system | grep aws-load-balancer-controllerIf it's
CrashLoopBackOffor has0/1in theREADYcolumn, you need to debug the pod itself usingkubectl describe pod ...in thekube-systemnamespace.
-
The "How to Use AWS Load Balancer Controller" article has an excellent section on troubleshooting that lists these commands and more. It's a great page to bookmark.
How to Use AWS Load Balancer Controller for ALB and NLB on EKS
The 'Monitoring and Troubleshooting' section of this article by OneUptime is a concise and valuable reference for debugging.
Review the commands listed under 'Monitoring and Troubleshooting'. You don't need to run them all now, but familiarize yourself with what they do. kubectl logs and kubectl describe ingress are your first go-to commands for any Ingress-related issue.
Conclusion
In this lesson, we successfully bridged the gap between our internal Kubernetes cluster and the public internet. By creating a single Ingress manifest, we instructed the AWS Load Balancer Controller to provision and configure a powerful Application Load Balancer, routing all external traffic to our API Gateway.
Key Takeaways:
- An
Ingressresource is Kubernetes' standard way to define HTTP/S routing rules. - The AWS Load Balancer Controller acts on
Ingressresources to manage AWS ALBs automatically. - Annotations on the
Ingressmanifest are used to configure specific behaviors of the ALB (e.g.,internet-facing,iptarget type). - The
ADDRESSfield ofkubectl get ingressprovides the public DNS name for your application. - When debugging, always start by checking the logs of the
aws-load-balancer-controller.
Preview of the Next Lesson:
Our application is now fully deployed and functional. However, what happens when things go wrong inside a pod? In the next lesson, we will focus entirely on debugging running applications in Kubernetes. We'll intentionally introduce some common errors and learn how to use kubectl logs, kubectl describe pod, and kubectl exec to systematically diagnose and fix them, honing the critical skills you'll need in a production environment.