Photo by Ryunosuke Kikuno on Unsplash

Cilium NetworkPolicy with AWS Security Group rules

Rocky Chen
CodeX
Published in
5 min readApr 27, 2023

--

Cilium is a powerful network policy and security enforcement solution that is designed to work with Kubernetes and other container orchestration platforms.

Cilium network policy allows you to define rules that control how network traffic flows between Kubernetes pods and services or going outside of the cluster. These rules can be used to enforce security policies and prevent unauthorized access to your cluster. You can define policies based on a range of criteria, including IP addresses, ports, and protocols.

When Cilium running on AWS EKS clusters, it supports network policy rules based on AWS security groups: toGroups. However, it is totally different with Pod Security Group from AWS VPC CNI, as Cilium toGroups whitelists communications between Pods inside the Kubernetes cluster and a set of EC2 VMs attaching the specified AWS security groups.

Prerequisites

In this post, it would be demoed that how to use toGroups rules in Cilium NetworkPolicy to control the traffic between the Kubernetes cluster and an EC2 VM.

Therefore, the Kubernetes Pods should be able to send traffic to the target EC2 VM. In my case, the EC2 instance is launched in the same VPC with the EKS cluster and the a security group is added to allow traffic coming in from Pods in…

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Rocky Chen
Rocky Chen

Written by Rocky Chen

SRE | Cloud Engineer | AWS Certified Solutions Architect – Professional

No responses yet