How Application Load Balancer Works: Reference Architecture

2025-02-10

Ingress is a Kubernetes object that allows you to manage external or internal HTTP(S) access to services running in your Kubernetes cluster. It can be used to route requests for different paths to different services. The AWS ALB Ingress Controller is an open-source project that automates the creation and configuration of Application Load Balancers (ALBs) for Kubernetes Ingress resources. It simplifies and automates the management of your Ingress resources.

Key Features of the AWS Load Balancer Controller:

  • Sharing ALBs: You can use one ALB for multiple Ingress resources.
  • Support for NLBs: Network Load Balancers (NLBs) are ideal for high-traffic applications.
  • Support for TargetGroupBinding: Bind services to Elastic Load Balancer (ELB) target groups.
  • Support for fully private clusters: Keep clusters isolated from the internet.

How Ingress Works

Ingress works by defining a set of rules that map incoming requests to specific services. These rules can be based on the hostname, path, or other criteria. When a request arrives at your Kubernetes cluster, the Ingress controller uses these rules to determine which service to route the request to.

For example:

  • Requests for `www.cloudairy.com/app1` could be routed to a service called app1.
  • Requests for `www.cloudairy.com/app2` could be routed to a service called app2.
  • Requests for `www.cloudairy.com/user` could be routed to a service called user.

Practical Implementation with Commands

To deploy the AWS ALB Ingress Controller, follow these steps:

1. Install the AWS Load Balancer Controller:

kubectl apply -f https://github.com/kubernetes-sigs/aws-load-balancer-controller/releases/download/v2.4.0/v2_4_0_full.yaml

2. Create an Ingress Resource:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
spec:
rules:
- host: www.cloudairy.com
http:
paths:
- path: /app1
pathType: Prefix
backend:
service:
name: app1
port:
number: 80
- path: /app2
pathType: Prefix
backend:
service:
name: app2
port:
number: 80

3. Verify the Ingress Resource:

kubectl get ingress

4. Check the ALB Status:

kubectl describe ingress example-ingress

What Undercode Says

Ingress is a powerful tool for managing external traffic to Kubernetes services. The AWS ALB Ingress Controller simplifies this process by automating the creation and configuration of ALBs. Here are some additional Linux and Kubernetes commands to enhance your understanding:

  • Check Kubernetes Cluster Nodes:
    kubectl get nodes
    

  • View Pod Logs:

    kubectl logs <pod-name>
    

  • Describe a Service:

    kubectl describe service <service-name>
    

  • List All Pods:

    kubectl get pods --all-namespaces
    

  • Access a Pod Shell:

    kubectl exec -it <pod-name> -- /bin/sh
    

  • Delete a Pod:

    kubectl delete pod <pod-name>
    

  • Scale a Deployment:

    kubectl scale deployment <deployment-name> --replicas=3
    

  • View Cluster Events:

    kubectl get events
    

  • Create a Namespace:

    kubectl create namespace <namespace-name>
    

  • Apply a Configuration File:

    kubectl apply -f <filename>.yaml
    

  • Delete a Namespace:

    kubectl delete namespace <namespace-name>
    

  • View Cluster Information:

    kubectl cluster-info
    

  • Check Resource Usage:

    kubectl top nodes
    

  • Drain a Node:

    kubectl drain <node-name> --ignore-daemonsets --delete-local-data
    

  • Cordon a Node:

    kubectl cordon <node-name>
    

  • Uncordon a Node:

    kubectl uncordon <node-name>
    

  • View Persistent Volumes:

    kubectl get pv
    

  • View Persistent Volume Claims:

    kubectl get pvc
    

  • Create a Secret:

    kubectl create secret generic <secret-name> --from-literal=key=value
    

  • View Secrets:

    kubectl get secrets
    

  • Describe a Secret:

    kubectl describe secret <secret-name>
    

  • Create a ConfigMap:

    kubectl create configmap <configmap-name> --from-literal=key=value
    

  • View ConfigMaps:

    kubectl get configmaps
    

  • Describe a ConfigMap:

    kubectl describe configmap <configmap-name>
    

  • Rollout a Deployment:

    kubectl rollout status deployment/<deployment-name>
    

  • Rollback a Deployment:

    kubectl rollout undo deployment/<deployment-name>
    

  • View Deployment History:

    kubectl rollout history deployment/<deployment-name>
    

  • Patch a Deployment:

    kubectl patch deployment <deployment-name> -p '{"spec":{"template":{"spec":{"containers":[{"name":"<container-name>","image":"<new-image>"}]}}}}'
    

  • View Service Accounts:

    kubectl get serviceaccounts
    

  • Create a Service Account:

    kubectl create serviceaccount <service-account-name>
    

  • Describe a Service Account:

    kubectl describe serviceaccount <service-account-name>
    

  • View Roles:

    kubectl get roles
    

  • Create a Role:

    kubectl create role <role-name> --verb=get,list,watch --resource=pods
    

  • Describe a Role:

    kubectl describe role <role-name>
    

  • View Role Bindings:

    kubectl get rolebindings
    

  • Create a Role Binding:

    kubectl create rolebinding <rolebinding-name> --role=<role-name> --user=<user-name>
    

  • Describe a Role Binding:

    kubectl describe rolebinding <rolebinding-name>
    

For more detailed information, refer to the official Kubernetes documentation: Kubernetes Ingress and AWS Load Balancer Controller.

Ingress is a critical component for managing traffic in Kubernetes, and the AWS ALB Ingress Controller makes it easier to handle complex routing scenarios. By leveraging these tools and commands, you can ensure efficient and secure traffic management for your applications.

References:

Hackers Feeds, Undercode AIFeatured Image

Scroll to Top