- Newest
- Most votes
- Most comments
This guide demonstrates how to use AWS Controllers for Kubernetes (ACK) to provision and manage Application Load Balancer (ALB) resources through Kubernetes APIs.
Prerequisites
- EKS cluster
- kubectl configured
- Helm installed
- Necessary IAM permissions
Method 1: Using ACK ELBv2 Controller
Step 1: Install ACK ELBv2 Controller
# Export required variables in the terminal export SERVICE=elbv2 export RELEASE_VERSION=$(curl -sL https://api.github.com/repos/aws-controllers-k8s/${SERVICE}-controller/releases/latest | jq -r '.tag_name | ltrimstr("v")') export ACK_SYSTEM_NAMESPACE=ack-system export AWS_REGION=us-east-1 # Use the correct region for your deployment # Complete the login to public ECR repository (make sure a role/user has logged in the terminal as an AWS identity) aws ecr-public get-login-password --region us-east-1 | helm registry login --username AWS --password-stdin public.ecr.aws # Run the helm command helm install --create-namespace -n $ACK_SYSTEM_NAMESPACE ack-$SERVICE-controller \ oci://public.ecr.aws/aws-controllers-k8s/$SERVICE-chart --version=$RELEASE_VERSION --set=aws.region=$AWS_REGION
Step 2: Deploy ALB Resources
Here's an example manifest that sets up:
- Two target groups (Blue/Green)
- One ALB listener
- Traffic split configuration
apiVersion: elbv2.services.k8s.aws/v1alpha1 kind: TargetGroup metadata: name: blue-tg spec: name: blue-tg protocol: HTTP port: 80 targetType: ip vpcID: {VPC_ID} --- apiVersion: elbv2.services.k8s.aws/v1alpha1 kind: TargetGroup metadata: name: green-tg spec: name: green-tg protocol: HTTP port: 80 targetType: ip vpcID: {VPC_ID} --- apiVersion: elbv2.services.k8s.aws/v1alpha1 kind: Listener metadata: name: main-listener spec: loadBalancerARN: {LOAD_BALANCER_ARN} port: 80 protocol: HTTP defaultActions: - type: forward forwardConfig: targetGroups: - targetGroupARN: ${BLUE_TG_ARN} weight: 90 - targetGroupARN: ${GREEN_TG_ARN} weight: 10
Benefits
- Declarative management of ALB reyour source documents. Native Kubernetes experience
- Simplified canary and blue-green deployments
- Version-controlled infrastructure
Notes
- Replace placeholder values (VPC_ID, ARNs) with your actual values
- Adjust weights in forwardConfig based on your traffic split requirements
- Ensure proper IAM permissions are configured for the ACK controller
Additional Resources
#aws #kubernetes #eks #alb #ack
UPDATES:
- Update helm command. Reference: https://aws-controllers-k8s.github.io/community/docs/user-docs/install/
- Only use one TargetGroup and link that target group using listener. Remove references to
targetGroup2from the sample YAML file.
answered a year ago
To create a standalone target group for use with EKS without attaching it to a load balancer, you can use the AWS Load Balancer Controller's TargetGroupBinding custom resource. This approach allows you to create a target group independently and then reference it from your EKS manifests.
Here's how you can accomplish this:
- First, create the target group using the AWS CLI or SDK:
aws elbv2 create-target-group \
--name my-standalone-targetgroup \
--protocol HTTP \
--port 80 \
--target-type instance \
--vpc-id vpc-12345678
The command above creates a target group with HTTP protocol on port 80 for instance targets. You can adjust parameters like protocol, port, and target-type based on your requirements.
- After creating the target group, you can use the TargetGroupBinding custom resource in your EKS manifests to associate pods with this target group:
apiVersion: elbv2.k8s.aws/v1beta1 kind: TargetGroupBinding metadata: name: my-targetgroup-binding spec: targetGroupARN: <your-target-group-arn> serviceRef: name: my-service port: 80
This TargetGroupBinding resource will register the pods backing your Kubernetes service as targets in the standalone target group.
For multi-cluster scenarios, you can use the multiClusterTargetGroup flag in the TargetGroupBinding to allow the same target group to be used across multiple EKS clusters:
apiVersion: elbv2.k8s.aws/v1beta1 kind: TargetGroupBinding metadata: name: my-targetgroup-binding spec: targetGroupARN: <your-target-group-arn> serviceRef: name: my-service port: 80 multiClusterTargetGroup: true
This approach gives you the flexibility to create and manage target groups independently of load balancers, which can be useful for scenarios where you need to pre-create target groups or share them across multiple resources.
Sources
Use CreateTargetGroup with an AWS SDK or CLI - AWS SDK Code Examples
Building Resilient Multi-cluster Applications with Amazon EKS, Part 1: Implementing Cross-cluster Load Balancing with NLB | Networking & Content Delivery
answered a year ago
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated a year ago

I don't want blue green, I just want to create target for service from manifests
btw the commands for helm install is not working