We use machine learning technology to do auto-translation. Click "English" on top navigation bar to check Chinese version.
Network Load Balancers now support Security groups
Introduction
At Amazon Web Services, we offer security from the get-go by providing you the ability to use
With this launch, you can assign multiple security groups to a Network Load Balancer. You can use the default Amazon Virtual Private Cloud (
Amazon Elastic Kubernetes Service (
LoadBalancer
. In version 2.6.0 and above, the controller automatically creates and/or applies security groups to Network Load Balancers, EC2 instances, and pods that are configured to use the Security Groups for Pods feature. Using the controller to provision/apply Network Load Balancers security groups enhances a node’s security a couple of ways. First, ingress rules can be simplified by referencing the load balancer’s security groups. Second, the controller keeps a constant number of security group rules per cluster which prevents scaling issues.
In this post, we’ll demonstrate how Amazon EKS handles security groups when Kubernetes applications are exposed by an NLB, thereby enhancing the end-to-end security posture.
Solution overview
In Kubernetes, pods are the smallest unit of deployment. These pods can be exposed as a Kubernetes Service which make the pods accessible to other applications inside and outside the cluster. A Kubernetes Service of type LoadBalancer
is a common way to expose applications running in a Kubernetes cluster.
Amazon EKS supports the Amazon Web Services Load Balancer Controller, which manages Amazon Web Services Elastic Load Balancers for a Kubernetes cluster. The controller is responsible for creating Network Load Balancers when you create a Kubernetes service of type LoadBalancer
. The controller watches for any changes to the pod and will reconcile those changes by updating the configuration of the load balancers.
Before this release, the network access rules for applications had to be configured on the instance on which Kubernetes pods were deployed. As the number of Network Load Balancers increased, so would the number of rules you had to manage until the maximum number of security group rules allowed per account was reached. This effected the number of NLBs that could be created in an Amazon Web Services account.
In version 2.6.0 of the Amazon Web Services Load Balancer controller, security groups are attached your frontend and backend automatically when a service of type LoadBalancer is created. Frontend security groups allows you to control the traffic that can be routed to the load balancer. The controller allows you to specify existing security groups through a Kubernetes annotation called
inbound-cidrs
and listen-ports
to the frontend security group.
The Amazon Web Services Load Balancer Controller also creates a shared backend security group to control the traffic between the Network Load Balancers and its backend targets, e.g. instances or pods belonging to a security group.
Note: the Load Balancer Controller will not create security groups for pods. In order for the controller to attach a security group to a group of pods, the pods need to be created with the
When the security group annotation is omitted from the Service, the controller automatically adds instance group rules that allow egress traffic from the backend security group of a load balancer. Automatic rule management is disabled when a security group is referenced by the security group annotation service.beta.kubernetes.io/aws-load-balancer-manage-backend-security-group-rules
.
Walkthrough
You must ensure that the Amazon EKS cluster is up and running before moving to the next section. If not, you can create a cluster using one of the methods mentioned in the Amazon EKS cluster creation
Before deploying a Kubernetes application, make sure that the controller Pods are active.
Now let’s deploy a sample web application.
Now, find the load balancer name <external-ip>
from newly created Kubernetes service.
Note: you may need to wait a couple of minutes before the load balancer is successfully provisioned.
kubectl get service sample-app
Next, login to
The latest version of Amazon Web Services Load Balancer Controller is backward compatible with prior versions and continues to support existing Network Load Balancers. The controller only provisions NLBs with security groups for new Services of type LoadBalancer
. You can apply security groups to NLB with both instance
and ip
target types, as well as internal and external schemes. The controller provides a feature flag that allows you to deactivate the automatic creation of NLB security groups. While installing or updating the controller, you may provide NLBSecurityGroup=false
using the --feature-gates
option. Amazon EKS strongly advises you to use security groups for NLB to improve the security posture of your applications.
Conclusion
In this post, we showed you how to create a service of type LoadBalancer and observed how the Amazon Web Services Load Balancer Controller automatically creates and assigns security groups to the frontend, i.e. the Network Load Balancer and its backend targets.
With the support of security groups for Network Load Balancers, you can control access to your applications and improve their security posture. This feature is accessible in all Amazon Web Services commercial Regions for no added cost. Please refer to the Network Load Balancer
As part of this update, we’ve also released a new version of the Amazon Web Services Load Balancer Controller (v2.6.0) which allows you to apply security groups to NLBs when you create Kubernetes services of type LoadBalancer
. The automatic creation of security groups enhances the end-to-end security of containerized workloads running in a Kubernetes cluster by directly controlling access at the load balancer level as opposed to at the instance level. Please refer to the
If you’re running Kubernetes on Amazon Web Services and want to begin using security groups with Network Load Balancers, upgrade to v2.6.0 of the Amazon Web Services Load Balancer Controller today. See the
The mentioned AWS GenAI Services service names relating to generative AI are only available or previewed in the Global Regions. Amazon Web Services China promotes AWS GenAI Services relating to generative AI solely for China-to-global business purposes and/or advanced technology introduction.