Skip to content
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

Implement traffic command #29

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Implement traffic command #29

wants to merge 4 commits into from

Conversation

yokaze
Copy link
Contributor

@yokaze yokaze commented Apr 7, 2025

This PR implements npv traffic command.

Usage

  • npv traffic -n [NAMESPACE]
  • npv traffic -n [NAMESPACE] [POD]
  • npv traffic -n [NAMESPACE] -l [SELECTOR]

When multiple pods are selected, it shows the combined traffic amount.

Example Result

$ npv traffic -n test -l test=self
DIRECTION IDENTITY NAMESPACE EXAMPLE                                        PROTOCOL PORT BYTES PACKETS
Egress    2        -         cidr:1.1.1.1/32                                UDP      53   558   6
Egress    2        -         cidr:8.8.8.8/32                                UDP      53   558   6
Egress    22197    test      l4-ingress-explicit-allow-tcp-674bf84548-vbk7k TCP      8000 5820  72
Egress    23557    test      l3-ingress-explicit-allow-all-854c9bb96c-96nqs ANY      ANY  5808  72

Implementation

  1. npv traffic computes the list of pods, for which the traffic amount should be displayed
  2. It asks cilium-agent on each node through cilium-agent-proxy to query BPF policy map, along with traffic amount for each route (similar to npv inspect)
  3. It selects allowed and active (traffic > 0) routes
  4. Combine the traffic amount for pods and display the result

CI update

Overview: e2e/testdata/policy/README.md

This PR:

  • raises self pod from one to two, to check npv traffic shows combined traffic amount
  • changes test pods from ubuntu to testhttpd, to make real traffic
  • allows self pods to reach 1.1.1.1 (Cloudflare DNS)

yokaze added 3 commits April 7, 2025 13:41
Signed-off-by: Daichi Sakaue <daichi-sakaue@cybozu.co.jp>
Signed-off-by: Daichi Sakaue <daichi-sakaue@cybozu.co.jp>
Signed-off-by: Daichi Sakaue <daichi-sakaue@cybozu.co.jp>
@yokaze yokaze self-assigned this Apr 7, 2025
@yokaze yokaze changed the title implement traffic implement npv traffic Apr 7, 2025
@yokaze yokaze changed the title implement npv traffic Implement traffic command Apr 7, 2025
Signed-off-by: Daichi Sakaue <daichi-sakaue@cybozu.co.jp>
@yokaze yokaze force-pushed the implement-traffic branch from 3cc597a to fa7877e Compare April 8, 2025 02:06
@yokaze yokaze marked this pull request as ready for review April 8, 2025 02:09
@yokaze yokaze requested a review from tkna April 8, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant