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

add support for nftables counter objects #21

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

aroradaman
Copy link
Member

@aroradaman aroradaman commented Jan 7, 2025

This PR adds support for native named nftables counters.
https://wiki.nftables.org/wiki-nftables/index.php/Counters

Fixes: #20

Sample Usage:
kubernetes/kubernetes#129505

Output (kind):

root@kind-worker:/# nft list counters
table ip kube-proxy {
	counter traffic-to-invalid-ports {
		comment "tarck packets sent to invalid ports of cluster ips"
		packets 0 bytes 0
	}
}
table ip6 kube-proxy {
	counter traffic-to-invalid-ports {
		comment "tarck packets sent to invalid ports of cluster ips"
		packets 0 bytes 0
	}
}


root@kind-worker:/# for i in {1..100}; do curl --silent 10.96.0.10:12345; done;


root@kind-worker:/# nft list counters
table ip kube-proxy {
	counter traffic-to-invalid-ports {
		comment "tarck packets sent to invalid ports of cluster ips"
		packets 100 bytes 6000
	}
}
table ip6 kube-proxy {
	counter traffic-to-invalid-ports {
		comment "tarck packets sent to invalid ports of cluster ips"
		packets 0 bytes 0
	}
}

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 7, 2025
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 7, 2025
@aroradaman
Copy link
Member Author

/assign @aojea @danwinship

Copy link
Collaborator

@danwinship danwinship left a comment

Choose a reason for hiding this comment

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

I agree with the idea in principle but it would be good to see how it's actually going to get used (ie, not just a WIP/PoC) to make sure we've got it right.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 14, 2025
@aroradaman aroradaman requested a review from danwinship January 14, 2025 12:18
@aroradaman
Copy link
Member Author

aroradaman commented Jan 14, 2025

I agree with the idea in principle but it would be good to see how it's actually going to get used (ie, not just a WIP/PoC) to make sure we've got it right.

I have tried to expose a metric using nftables counter, which tracks the number of reject packets destined for invalid ports of the ClusterIPs.
kubernetes/kubernetes#129505

@danwinship
Copy link
Collaborator

are we giving up on nfacct due to lack of support on some platforms?

@aojea
Copy link
Contributor

aojea commented Jan 24, 2025

are we giving up on nfacct due to lack of support on some platforms?

it seems counters is the replacement of nfacct in nftables https://wiki.nftables.org/wiki-nftables/index.php/Supported_features_compared_to_xtables#nfacct

@aroradaman
Copy link
Member Author

We can still use nfacct for iptables ( just in case we want to track something ).

@danwinship
Copy link
Collaborator

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 15, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aroradaman, danwinship

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 15, 2025
@k8s-ci-robot k8s-ci-robot merged commit f47eca3 into kubernetes-sigs:master Feb 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Named Counters
4 participants