Skip to content

How do I stop security group rules, listeners, or other changes from reverting on a load balancer in Amazon EKS?

4 minute read
0

I want to keep the changes I make to security group rules, listeners, or other parameters on my load balancer in Amazon Elastic Kubernetes Service (Amazon EKS).

Short description

Note: In the following resolution , a "load balancer" refers to load balancing services and ingress resources. For example, Network Load Balancer is a load balancing service, and Application Load Balancer is an ingress resource.

You must specify changes in the manifest file's annotations to change the default parameters of your load balancer. Those parameters include health check paths, default timeout values, certificate Amazon Resource Names (ARNs), and security group rules.

The following issues occur because of reverted load balancer changes in Amazon EKS:

  • The load balancer's custom security group rules revert to 0.0.0.0/0 or disappear.
  • The load balancer deletes or adds listener rules.
  • Your custom idle timeout values revert to their default values.
  • Your SSL/TLS certificate automatically reverts to its previous version.
  • You can't update your health check path.
  • Amazon EKS modifies roles through the load balancer's properties.
  • Your service experiences downtime.

To troubleshoot these issues, first determine the API operation that changes your resource and the tool that made the call. Then, re-implement your changes in the manifest file.

Resolution

When you change the default configuration of your load balancer with an AWS API operation, the controller reverts your changes during the next cluster reconciliation. The controller reverts changes you make from tools that call AWS API operations, such as the Amazon Elastic Compute Cloud (Amazon EC2) console and the AWS Command Line Interface (AWS CLI). For more information, see Controllers on the Kubernetes website.

The following scenarios cause AWS Load Balancer Controller to activate cluster reconciliations and restart aws-load-balancer-controller pods:

  • Upgrades for the control plane, worker node, or platform
  • Underlying problems such as hardware failure or health issues that cause your EC2 instance to refresh
  • Activities that result in update, delete, or patch API calls on the controller pods
  • Automatic, periodic reconciliation

Note: By default, the controller's reconciliation period is 1 hour. Amazon EKS doesn't support periodic reconciliation on versions 2.4.7 and earlier of Amazon EKS.

Verify that the controller reverted your changes

Find the API call that relates to the updated resource. Review your AWS CloudTrail Event History for events that match the time frame that the changes occurred. For all AWS Load Balancer API calls, see the Elastic Load Balancing (ELB) API reference. For Amazon EC2 API calls, see the Amazon EC2 API reference.

If you use dedicated roles for AWS Load Balancer Controller, then the event contains the service AWS account's AWS Identity and Access Management (IAM) role that made the API call. If the controller uses WorkerNode roles, then the event contains the node role that made the API call. The following example event indicates that the user eksctl-mycluster-nodegr-NodeInstanceRole called the RevokeSecurityGroupIngress operation to update your instance's parameters:

...."type": "AssumedRole",
"arn": "arn:aws:sts::123456789012:assumed-role/eksctl-mycluster-NodeInstanceRole/i-0ab1c2d3e4f5a6b7c",
"sessionContext": {
  "sessionIssuer": {
    "type": "Role",
    "arn": "arn:aws:iam::123456789012:role/eksctl-mycluster-nodegr-NodeInstanceRole",
    "userName": "eksctl-mycluster-nodegr-NodeInstanceRole"
  },
  ...
  "eventName": "RevokeSecurityGroupIngress",
  "userAgent": "elbv2.k8s.aws/v2.4.5 aws-sdk-go/1.42.27 (go1.19.3; linux; amd64)",
  "requestParameters": {
    "groupId": "sg-0ab1c2d3e4f5a6b7c",
    "ipPermissions": {
      "items": [{
        "ipProtocol": "tcp",
        "fromPort": 443,  
        "toPort": 443,
        "groups": {},
        "ipRanges": {
          "items": [{
            "cidrIp": "0.0.0.0/0"
          }]
        }
      }]
    }
  }
}

Update your annotations to maintain your changes

After you identify the change made by an API operation that the controller reverted, update the ingress annotations in your manifest file to recreate that change.

Important: When you recreate the change, use only annotations in the manifest file that Amazon EKS supports to update your parameters. For lists of annotations that Amazon EKS supports, see Service annotations and Ingress annotations on the AWS Load Balancer Controller GitHub website.

AWS OFFICIALUpdated 9 months ago