DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Distributed Cloud Architecture for Resilient Systems: Rethink Your Approach To Resilient Cloud Services
  • Building a Serverless Application on AWS With AWS SAM
  • Keep Your Application Secrets Secret
  • Dynatrace Perform: Day Two

Trending

  • Deploying Heroku Apps To Staging and Production Environments With GitLab CI/CD
  • The Data Streaming Landscape 2024
  • Implementing Persistence With Clean Architecture
  • Architectural Insights: Designing Efficient Multi-Layered Caching With Instagram Example
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Automate Application Load Balancers With AWS Load Balancer Controller and Ingress

Automate Application Load Balancers With AWS Load Balancer Controller and Ingress

This article will help automate the process of creating and configuring ALBs with AWS Load balancer controller and Ingress template on Elastic Kubernetes Service (EKS).

By 
KONDALA RAO PATIBANDLA user avatar
KONDALA RAO PATIBANDLA
·
Jan. 17, 24 · Tutorial
Like (5)
Save
Tweet
Share
4.4K Views

Join the DZone community and get the full member experience.

Join For Free

Automating AWS Load Balancers is essential for managing cloud infrastructure efficiently. This article delves into the importance of automation using the AWS Load Balancer controller and Ingress template. Whether you're new or experienced, grasping these configurations is vital to streamlining Load Balancer settings on Amazon Web Services, ensuring a smoother and more effective setup.

 A high-level illustration of AWS Application Load Balancer with Kubernetes cluster

                  A high-level illustration of AWS Application Load Balancer with Kubernetes cluster


A load balancer acts as clients' main point of contact, distributing incoming traffic across multiple targets, like EC2 instances, in various Availability Zones. This enhances application availability. Listeners, configured with protocols and ports, check for client connection requests. Rules set for each listener dictate how the load balancer routes requests to registered targets based on conditions. Prioritized rules include actions to be performed. A default rule is necessary for each listener, with the option to define additional rules for enhanced control.

Ingress Template

Ingress Templates are pivotal in AWS Load Balancer management, simplifying the configuration process for enhanced efficiency. These templates define rules that dictate how traffic is directed to services. They are vital for ensuring optimal resource utilization and maintaining security. With Ingress Templates, you can easily specify routing policies, manage backend services, and implement health checks. For example, you can create rules for directing traffic to specific products or AWS accounts. This section explores the necessity of Ingress Templates in AWS and provides sample rules, illustrating their importance in load balancer configuration.

AWS Load Balancer Controller

AWS Load Balancer Controller is a crucial component for managing Application Load Balancers (ALB) efficiently in the AWS environment. It acts as a bridge between Kubernetes clusters and AWS services, simplifying the deployment and management of ALBs directly through Kubernetes manifests. This controller is essential for automating load balancer configuration, ensuring seamless integration of Kubernetes workloads with AWS infrastructure. By using the AWS Load balancer Controller, users can enhance scalability, reduce manual intervention, and optimize the performance of applications running on Kubernetes clusters within the AWS ecosystem.

Creating an Ingress Template

Crafting an Ingress Template for AWS Load Balancers involves several key components to ensure effective configuration. 

  1. Rules: Define routing rules specifying how traffic is directed based on paths or hosts.  
  2. Backend Services: Specify backend services to handle the traffic, including service names and ports.
  3. Health Checks: Implement health checks to ensure the availability and reliability of backend services.

We'll walk through each component, detailing their significance and providing examples to create a comprehensive Ingress Template for AWS Load Balancers. This step-by-step approach ensures a well-structured and functional configuration tailored to your specific application needs.

YAML
 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sample-ingress
  annotations:
    kubernetes.io/ingress.class: "alb"
    alb.ingress.kubernetes.io/scheme: "internet-facing or internal"
    alb.ingress.kubernetes.io/certificate-arn: "arn:aws:acm:your-region:your-account-id:certificate/your-acm-cert-arn"
spec:
  rules:
    - host: "*"
      http:
        paths:
          - path: /*
            pathType: Prefix
            backend:
              service:
                name: default-service
                port:
                  number: 80
          - path: /products
            pathType: Prefix
            backend:
              service:
                name: products-service
                port:
                  number: 80
          - path: /accounts
            pathType: Prefix
            backend:
              service:
                name: accounts-service
                port:
                  number: 80


  • metadata: Specifies the name of the Ingress and includes annotations for AWS-specific settings.
  • kubernetes.io/ingress.class: "alb": Specifies the Ingress class to be used, indicating that the AWS ALB Ingress Controller should manage the Ingress.
  • alb.ingress.kubernetes.io/scheme: "internet-facing" or "internal": Determines whether the ALB should be internet-facing or internal.
    Options:
    • "internet-facing": The ALB is accessible from the internet.
    • "internal": The ALB is internal and not accessible from the internet
  • alb.ingress.kubernetes.io/certificate-arn: "arn:aws:acm:your-region:your-account-id: certificate/your-acm-cert-arn": Specifies the ARN (Amazon Resource Name) of the ACM (AWS Certificate Manager) certificate to be associated with the ALB.
  • spec.rules: Defines routing rules based on the host. The /* rule directs traffic to the default service, while /products and /accounts have specific rules for products and accounts services.
  • pathType: Specifies the type of matching for the path.
  • backend.service.name and backend. service.port: Specifies the backend services for each rule.

AWS Load Balancer Controller

AWS Load Balancer Controller is a controller to help manage Elastic Load Balancers for a Kubernetes cluster. It satisfies Kubernetes Ingress resources by provisioning Application Load Balancers.

For more information about the AWS Load Balancer, refer to the AWS Load Balancer Controller.

YAML
 
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/name: aws-load-balancer-controller
  name: aws-load-balancer-controller
  namespace: alb-ingress
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/component: controller
      app.kubernetes.io/name: aws-load-balancer-controller
  template:
    metadata:
      labels:
        app.kubernetes.io/component: controller
        app.kubernetes.io/name: aws-load-balancer-controller
    spec:
      containers:
        - args:
            - --cluster-name=@@env: <<your EKS cluster name>>
            - --ingress-class=alb
          image: public.ecr.aws/eks/aws-load-balancer-controller:v2.5.2
          livenessProbe:
            failureThreshold: 2
            httpGet:
              path: /healthz
              port: 61779
              scheme: HTTP
            initialDelaySeconds: 30
            timeoutSeconds: 10
          name: controller
          ports:
            - containerPort: 9443
              name: webhook-server
              protocol: TCP
          resources:
            limits:
              cpu: 200m
              memory: 700Mi
            requests:
              cpu: 100m
              memory: 300Mi
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsNonRoot: true
          volumeMounts:
            - mountPath: /tmp/k8s-webhook-server/serving-certs
              name: cert
              readOnly: true
      priorityClassName: system-cluster-critical
      securityContext:
        fsGroup: 1337
      serviceAccountName: lineplanner-alb-ingress-controller
      terminationGracePeriodSeconds: 10
      volumes:
        - name: cert
          secret:
            defaultMode: 420
            secretName: aws-load-balancer-webhook-tls
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: aws-load-balancer-controller
  name: aws-load-balancer-webhook-service
  namespace: alb-ingress
spec:
  ports:
    - port: 443
      targetPort: 9443
  selector:
    app.kubernetes.io/component: controller
    app.kubernetes.io/name: aws-load-balancer-controller


Apply the AWS Load Balancer and Ingress template YAML files using the 'kubectl apply' command, as specified in the snippet below.

Shell
kubectl apply -f ingress-file.yaml
kubectl apply -f aws-alb-controller.yaml


Check the deployment status and monitor events to ensure successful configuration.

Shell
# To verify AWS Load Balancer controller deployment status
kubectl get pods -n abl-ingress

# To verify ingress deployment status
kubectl get ingress
kubectl describe ingress <<your-ingress-name>>


Confirm the creation and configuration of the AWS Load Balancer through AWS Console or CLI.

Shell
aws elbv2 describe-load-balancers --names <<your-load-balancer-name>>

Conclusion

This article highlighted the pivotal role of automating AWS Load Balancers using AWS Controller and Ingress Templates. The seamless orchestration provided by AWS Controller streamlines configuration, promoting efficiency and scalability. Ingress Templates play a crucial role in defining rules, backend services, and health checks, simplifying load balancer management. The benefits include enhanced resource utilization, reliability, and a more straightforward deployment process. By leveraging these tools, users can optimize their AWS infrastructure, ensuring a robust and responsive application environment. Embrace automation for a future-ready, resilient cloud architecture that adapts to evolving business needs.

AWS Kubernetes YAML application Load balancing (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Distributed Cloud Architecture for Resilient Systems: Rethink Your Approach To Resilient Cloud Services
  • Building a Serverless Application on AWS With AWS SAM
  • Keep Your Application Secrets Secret
  • Dynatrace Perform: Day Two

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: