Skip to content

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

Merged
Andrei Kvapil (kvaps) merged 3 commits into
mainfrom
feat/service-proxy-name-label
Apr 27, 2026
Merged

Andrei Kvapil (kvaps) merged 3 commits into
mainfrom
feat/service-proxy-name-label

Conversation

@kvaps

Copy link
Copy Markdown
Member

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

@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

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

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ 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: f936731e-6111-4044-b55a-bb05eccfc37d

📥 Commits

Reviewing files that changed from the base of the PR and between e54181f and d3a72e6.

📒 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.

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

Copy link
Copy Markdown

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
Andrei Kvapil (kvaps) marked this pull request as ready for review April 21, 2026 18:32
Andrei Kvapil (kvaps) and others added 3 commits April 27, 2026 20:10
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 <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
@kvaps
Andrei Kvapil (kvaps) force-pushed the feat/service-proxy-name-label branch from d5531a6 to d3a72e6 Compare April 27, 2026 18:13
@kvaps
Andrei Kvapil (kvaps) merged commit bbb3d83 into main Apr 27, 2026
2 checks passed
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