Categories:

Security Group (SG) and Network Access Control List (NACL) configurations for Elastic Kubernetes Service (EKS)


I was looking for firewall good practices for an EKS cluster. I easily found AWS recommendations about Security Groups (SG) but I had trouble finding some for Network Access Control List (NACLs). I realized it is not so easy to derive NACL configuration from an SG configuration if you do not understand some core concepts. In this article I will try to sum up these concepts by comparing SGs and NACLs. I will then propose some configurations for both resources in case you are hosting an EKS cluster.

Difference between NACLs and SGs

NACL and SG are both firewall rules, however they have notable differences that I have summarized in the following table:

 NACLSG
Scopessubnet or VPC – applies to all instances in the subnet or VPCinstance – applies to all instances linked to the SG
Cardinality1 NACL per subnet or VPC1 to many SG per instance or instance group
Actionsallow or denyallow – every unspecified rule defaults to deny
Statesstateless – i.e. NACLs allow traffic looking at the IP and port regardless of the fact that it is a reply requeststatefull – i.e. SGs automatically allow a reply to be returned. They maintain a state table that tracks the origin and destination IP and port. Only one rule (inbound or outbound) is required
Rule orderrules are applied in orderrules are applied simultaneously

Note that inbound traffic first passes through the NACL firewalls then to the SG firewallsOutbound traffic goes the opposite way.

Firewall requirement for EKS

The AWS documentation specifies the following requirements:

  • traffic needs to be allowed between the control plane and managed node groups
  • traffic needs to be allowed between nodes
  • nodes and control plane should have outbound access to the internet.

Note that one of the possibilities your nodes might not join your cluster is if they do not have access to the internet. Indeed, they need access to the Amazon EKS API.

SG configuration for EKS

Taking into account above consideration, here is an SG proposition for EKS.

Inbound

ProtocolPortSource
TCP443self
TCP1024 – 65535self

Outbound

ProtocolPortDestination
TCP4430.0.0.0/0
TCP800.0.0.0/0
TCP1024 – 655350.0.0.0/0

NACL configuration for EKS

Taking into account above consideration, here is a NACL proposition for EKS.

Inbound

Rule #ProtocolPortSourceAllow / Deny
100TCPAllselfAllow
200TCP1024 – 655350.0.0.0/0Allow
9000AllAllAllDeny

Outbound

Rule #ProtocolPortDestinationAllow / Deny
100TCPAllselfAllow
200TCP1024 – 655350.0.0.0/0Allow
300TCP800.0.0.0/0Allow
400TCP4430.0.0.0/0Allow
9000AllAllAllDeny

I hope this article will help you set up your EKS security group (SG) and network access control list (NACL) firewalls easily. If you have other recommendations, questions or challenges please reach me in the comment section. Take care.

Sourcepadok


Leave a Reply

Your email address will not be published. Required fields are marked *