[PR #4975] k8s api auth proxy - add embedded client WhoIs API for Kubernetes auth proxy integration #24644

Open
opened 2026-08-05 06:08:57 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4975
Author: @shyam0904a
Created: 12/19/2025
Status: 🔄 Open

Base: mainHead: feature/k8s-api-auth-proxy


📝 Commits (10+)

  • 3f73947 feat: add groups and userId to RemotePeerConfig for k8s auth proxy
  • f113e8b feat: add kubeconfig CLI command for k8s auth proxy
  • e7f89ef fix: update status_test.go for new AddPeer signature
  • a9ce130 fix: remove conflicting shorthand flag in kubeconfig command
  • a8ba428 embed client
  • 855326d peer identity update, help in dynamic group updates
  • 5204970 fix: use strings.HasPrefix and add TLS warning in kubeconfig command
  • 731b8fe fix: clone Groups slice and improve error message in WhoIs
  • 475706f fix: use RLock for read-only GetPeerIdentityByIP and clone Groups slices
  • 0618370 perf: optimize AccountPeerGroupsLookup with pre-built reverse index

📊 Changes

14 files changed (+324 additions, -4752 deletions)

View changed files

client/cmd/kubeconfig.go (+131 -0)
📝 client/cmd/root.go (+1 -0)
📝 client/embed/embed.go (+42 -0)
📝 client/internal/connect.go (+5 -0)
📝 client/internal/engine.go (+8 -1)
📝 client/internal/peer/status.go (+64 -2)
📝 client/internal/peer/status_test.go (+5 -5)
📝 client/internal/routemanager/client/client_bench_test.go (+1 -1)
📝 management/internals/controllers/network_map/controller/controller.go (+2 -2)
📝 management/internals/shared/grpc/conversion.go (+45 -4)
📝 management/internals/shared/grpc/server.go (+11 -1)
📝 management/server/peer_test.go (+1 -1)
shared/management/proto/management.pb.go (+0 -4735)
📝 shared/management/proto/management.proto (+8 -0)

📄 Description

Describe your changes

Add Kubernetes API Auth Proxy feature with embedded NetBird client for identity-aware access to the Kubernetes API.

Changes include:

  • client/embed/embed.go: Add WhoIs() method for peer identity lookup by IP
  • client/internal/connect.go: Expose StatusRecorder for embed client
  • client/internal/peer/status.go: Add GetPeerIdentityByIP() and UpdatePeerIdentity() methods
  • client/internal/engine.go: Update peer identity on network map changes
  • client/cmd/kubeconfig.go: Add CLI command to generate kubeconfig for auth proxy
  • shared/management/proto/management.proto: Add groups/userId to RemotePeerConfig
  • management/internals/shared/grpc/conversion.go: Populate groups in sync response

How it works:

  1. Auth proxy embeds NetBird client and joins the mesh
  2. Incoming kubectl requests are authenticated via WhoIs(remoteIP)
  3. Peer identity (user/groups) is mapped to Kubernetes impersonation headers
  4. Kubernetes RBAC controls access based on NetBird groups

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • [x ] Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • [x ] I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

527

Related PR for operator:
91

Summary by CodeRabbit

  • New Features
    • New kubeconfig command to generate kubeconfig for Kubernetes access via NetBird (prints or writes file, with usage hints).
    • Peer identity tracking: peers now include group names and user IDs to support RBAC/impersonation.
    • WhoIs lookup: query peer identity information by IP.
    • Sync responses and remote peer records now include peer group names and userId fields.

✏️ Tip: You can customize this high-level summary in your review settings.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/4975 **Author:** [@shyam0904a](https://github.com/shyam0904a) **Created:** 12/19/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feature/k8s-api-auth-proxy` --- ### 📝 Commits (10+) - [`3f73947`](https://github.com/netbirdio/netbird/commit/3f7394785801c666f8f539fd3111f73e4282ad5d) feat: add groups and userId to RemotePeerConfig for k8s auth proxy - [`f113e8b`](https://github.com/netbirdio/netbird/commit/f113e8b7850e00b321695dd41cb0c9de5fee64f6) feat: add kubeconfig CLI command for k8s auth proxy - [`e7f89ef`](https://github.com/netbirdio/netbird/commit/e7f89ef615b55a88ed3e7ed9aca10e7447d589f8) fix: update status_test.go for new AddPeer signature - [`a9ce130`](https://github.com/netbirdio/netbird/commit/a9ce130221e3ca2d15804e4280a317a978b91a49) fix: remove conflicting shorthand flag in kubeconfig command - [`a8ba428`](https://github.com/netbirdio/netbird/commit/a8ba4280981c517e46e31c38f01db7a269423d8f) embed client - [`855326d`](https://github.com/netbirdio/netbird/commit/855326de039d2194d66597f969cad147d66f2d21) peer identity update, help in dynamic group updates - [`5204970`](https://github.com/netbirdio/netbird/commit/5204970fcf0eb3f0cd45beba714c84ab8a0acf0f) fix: use strings.HasPrefix and add TLS warning in kubeconfig command - [`731b8fe`](https://github.com/netbirdio/netbird/commit/731b8fe746c5f67aa932f6c873d364f3fc7855dc) fix: clone Groups slice and improve error message in WhoIs - [`475706f`](https://github.com/netbirdio/netbird/commit/475706fe0de806c9ba5100fffc04115d88fe60b9) fix: use RLock for read-only GetPeerIdentityByIP and clone Groups slices - [`0618370`](https://github.com/netbirdio/netbird/commit/0618370e4cd9e4ffe337691ccf2c9abddad16947) perf: optimize AccountPeerGroupsLookup with pre-built reverse index ### 📊 Changes **14 files changed** (+324 additions, -4752 deletions) <details> <summary>View changed files</summary> ➕ `client/cmd/kubeconfig.go` (+131 -0) 📝 `client/cmd/root.go` (+1 -0) 📝 `client/embed/embed.go` (+42 -0) 📝 `client/internal/connect.go` (+5 -0) 📝 `client/internal/engine.go` (+8 -1) 📝 `client/internal/peer/status.go` (+64 -2) 📝 `client/internal/peer/status_test.go` (+5 -5) 📝 `client/internal/routemanager/client/client_bench_test.go` (+1 -1) 📝 `management/internals/controllers/network_map/controller/controller.go` (+2 -2) 📝 `management/internals/shared/grpc/conversion.go` (+45 -4) 📝 `management/internals/shared/grpc/server.go` (+11 -1) 📝 `management/server/peer_test.go` (+1 -1) ➖ `shared/management/proto/management.pb.go` (+0 -4735) 📝 `shared/management/proto/management.proto` (+8 -0) </details> ### 📄 Description ## Describe your changes Add Kubernetes API Auth Proxy feature with embedded NetBird client for identity-aware access to the Kubernetes API. **Changes include:** - `client/embed/embed.go`: Add WhoIs() method for peer identity lookup by IP - `client/internal/connect.go`: Expose StatusRecorder for embed client - `client/internal/peer/status.go`: Add GetPeerIdentityByIP() and UpdatePeerIdentity() methods - `client/internal/engine.go`: Update peer identity on network map changes - `client/cmd/kubeconfig.go`: Add CLI command to generate kubeconfig for auth proxy - `shared/management/proto/management.proto`: Add groups/userId to RemotePeerConfig - `management/internals/shared/grpc/conversion.go`: Populate groups in sync response **How it works:** 1. Auth proxy embeds NetBird client and joins the mesh 2. Incoming kubectl requests are authenticated via WhoIs(remoteIP) 3. Peer identity (user/groups) is mapped to Kubernetes impersonation headers 4. Kubernetes RBAC controls access based on NetBird groups ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [x ] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) [527](https://github.com/netbirdio/docs/pull/527) Related PR for operator: [91](https://github.com/netbirdio/kubernetes-operator/pull/91) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * New kubeconfig command to generate kubeconfig for Kubernetes access via NetBird (prints or writes file, with usage hints). * Peer identity tracking: peers now include group names and user IDs to support RBAC/impersonation. * WhoIs lookup: query peer identity information by IP. * Sync responses and remote peer records now include peer group names and userId fields. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 06:08:57 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#24644