Skip to content

feat: include iptables block binary in iptables monitor image #3945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 22, 2025

Conversation

santhoshmprabhu
Copy link
Contributor

@santhoshmprabhu santhoshmprabhu commented Aug 18, 2025

Reason for Change:

This PR incorporates the azure-block-iptables binary into the azure-iptables-monitor image. We originally were planning to deploy this binary as a systemd service through AgentBaker. However, @paulgmiller pointed out a limitation of doing so, which meant that we'd be forced to do node rotations when enabling/disabling eBPF host routing.

To avoid node rotations, we are now planning to install the iptables rule blocking from an init container in the CNS daemonset. Once the init container runs, it installs the LSM BPF program to block iptables rule installation, and additionally pins the link to the filesystem. This means that even after the init container finishes, iptables rules can't be installed in the host network namespace, unless explicitly allowed by our blocking logic. This does mean that a component may be able to install iptables rules by coming up sooner than CNS. We address this limitation by generating Kube events when such rules are detected (this is already being done in iptables-monitor).

When eBPF host routing gets disabled, an init/sidecar container in CNS can clean up the pinned BPF programs. The binary includes the functionality to do that in the "detach" mode. To enable future changes to the blocking logic, the binary also has an option to "overwrite" the BPF attachment. When overwrite is selected, any existing BPF program will be removed first, before attaching.

Validation done
Attach/Detach
image

Overwrite
image

Issue Fixed:

Requirements:

Notes:

@Copilot Copilot AI review requested due to automatic review settings August 18, 2025 21:03
@santhoshmprabhu santhoshmprabhu requested review from QxBytes and a team as code owners August 18, 2025 21:03
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR incorporates the azure-block-iptables binary into the azure-iptables-monitor container image to enable deploying it as a sidecar container in the CNS daemonset, avoiding the need for node rotations when enabling/disabling eBPF host routing.

  • Adds azure-block-iptables binary build stage to the azure-iptables-monitor Dockerfile
  • Updates Makefile to include azure-block-iptables version information and build arguments
  • Installs BPF development dependencies and sets up cross-compilation support

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
azure-iptables-monitor/Dockerfile Adds multi-stage build for azure-block-iptables binary with BPF dependencies and copies it to final image
Makefile Updates version matching and adds build argument for azure-block-iptables version

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@santhoshmprabhu santhoshmprabhu requested review from a team as code owners August 18, 2025 21:25
@santhoshmprabhu
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@santhoshmprabhu
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@santhoshmprabhu santhoshmprabhu self-assigned this Aug 20, 2025
@santhoshmprabhu santhoshmprabhu added go Pull requests that update Go code cilium Related to Cilium. labels Aug 20, 2025
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Santhosh  Prabhu  <[email protected]>
@santhoshmprabhu
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

QxBytes
QxBytes previously approved these changes Aug 20, 2025
tamilmani1989
tamilmani1989 previously approved these changes Aug 20, 2025
@santhoshmprabhu santhoshmprabhu added this pull request to the merge queue Aug 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 21, 2025
@santhoshmprabhu santhoshmprabhu dismissed stale reviews from tamilmani1989 and QxBytes via e503318 August 21, 2025 02:41
@santhoshmprabhu
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@santhoshmprabhu santhoshmprabhu added this pull request to the merge queue Aug 21, 2025
Merged via the queue into master with commit 72bdaf1 Aug 22, 2025
34 checks passed
@santhoshmprabhu santhoshmprabhu deleted the sanprabhu/iptables-block-in-monitor-image branch August 22, 2025 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cilium Related to Cilium. go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants