Skip to content

feat: select services by service-proxy-name label#9

Open
kvaps wants to merge 3 commits intomainfrom
feat/service-proxy-name-label
Open

feat: select services by service-proxy-name label#9
kvaps wants to merge 3 commits intomainfrom
feat/service-proxy-name-label

Conversation

@kvaps
Copy link
Copy Markdown
Member

@kvaps kvaps commented Apr 21, 2026

Summary

Adds support for selecting services via the standard Kubernetes service.kubernetes.io/service-proxy-name: cozy-proxy label, in addition to the existing networking.cozystack.io/wholeIP: "true" annotation. A service matching either selector is managed by cozy-proxy.

Motivation

Since v0.2.0 cozy-proxy performs stateless NAT in the raw table (early_snat chain). On clusters running plain kube-proxy (iptables/IPVS) — e.g. default RKE2 + Calico + MetalLB — kube-proxy installs its own LoadBalancer rules that race with cozy-proxy's raw-table NAT and break outbound SNAT. The service.kubernetes.io/service-proxy-name label is the standard Kubernetes mechanism that instructs kube-proxy to ignore a service, letting cozy-proxy fully own its packet path. Cozystack itself adopted the same label on VM LoadBalancer services in cozystack/cozystack#2357.

The legacy annotation is kept as-is so existing deployments need no changes.

Changes

  • Controller now matches a service if it carries either selector
  • README documents both selectors and guides users on which to pick

Test plan

  • Plain kube-proxy cluster (RKE2 + Calico + MetalLB BGP): verify outbound SNAT works for services labeled service-proxy-name=cozy-proxy
  • Cozystack reference env (Cilium KPR): verify existing annotation-only services continue to work unchanged
  • Service with both selectors set: managed exactly once
  • Removing the last selector from a managed service: rules cleaned up

Refs: #8

kvaps and others added 2 commits April 21, 2026 20:23
Add support for the standard Kubernetes service.kubernetes.io/service-proxy-name
label with value "cozy-proxy" as an alternative to the legacy
networking.cozystack.io/wholeIP annotation. Either selector alone is sufficient;
both may be set on the same Service.

The label is the recommended selector for plain kube-proxy (iptables/IPVS)
deployments, because kube-proxy natively skips services carrying it, eliminating
the rule collision that otherwise breaks outbound SNAT after the move to raw
table early_snat (v0.2.0). The annotation is retained for backward compatibility.

Refs: #8

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@kvaps has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 20 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 33 minutes and 20 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dbd03381-e955-49ca-a42c-7e63132f0ab3

📥 Commits

Reviewing files that changed from the base of the PR and between 5655195 and d5531a6.

📒 Files selected for processing (2)
  • README.md
  • pkg/controllers/services_controller.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/service-proxy-name-label

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Keep only a single note that the legacy annotation is retained for backward
compatibility; remove all other annotation references from user-facing docs.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the service selection logic to support the standard service.kubernetes.io/service-proxy-name: cozy-proxy label alongside the legacy networking.cozystack.io/wholeIP: "true" annotation. This improvement ensures that kube-proxy ignores services handled by cozy-proxy, preventing rule collisions in clusters using plain kube-proxy. The README has been updated with guidance on which selector to use and the controller code now implements the dual-selection logic. I have no feedback to provide.

@kvaps kvaps marked this pull request as ready for review April 21, 2026 18:32
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