Skip to content

feat: Add AuthBridge Mutating Webhook for Kubernetes Workloads - #75

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
cwiklik:feat/add-new-authbridge-webhook
Jan 23, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
cwiklik:feat/add-new-authbridge-webhook

Conversation

@cwiklik

@cwiklik cwiklik commented Jan 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a new mutating admission webhook that automatically injects AuthBridge sidecars (SPIFFE helper and client registration) into standard Kubernetes workloads (Deployments, StatefulSets, DaemonSets, Jobs, and CronJobs).

Motivation

Previously, sidecar injection was only available for custom resources (Agent and MCPServer CRs). This webhook extends AuthBridge injection support to native Kubernetes workloads, enabling zero-touch authentication setup for any application.

Changes

New Files
kagenti-webhook/internal/webhook/v1alpha1/authbridge_webhook.go - Main webhook handler for workload mutation

Modified Files

  • kagenti-webhook/internal/webhook/injector/pod_mutator.go
    • Added InjectAuthBridge() method as the new entry point for AuthBridge injection
    • Added NeedsMutation() to determine if injection should occur based on labels and namespace settings
    • Added AuthBridgeDisabledValue constant for explicit opt-out

Idempotency

The webhook checks for existing spiffe-helper and kagenti-client-registration containers before injection to prevent duplicate sidecars on UPDATE operations.

Injected Components:

  • spiffe-helper sidecar container
  • kagenti-client-registration sidecar container

Required volumes (spiffe-helper-config, spire-agent-socket, svid-output, shared-data)

Usage Examples
Enable injection via workload label:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  labels:
    kagenti.io/inject: enabled
spec:
  # ...

Disable injection for specific workload:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  labels:
    kagenti.io/inject: disabled

How It Works

Injection Behavior Matrix

Namespace Label Workload Label Webhook Called? Injection Happens?
kagenti-enabled: true kagenti.io/inject: enabled ✅ Yes ✅ Yes
kagenti-enabled: true kagenti.io/inject: disabled ✅ Yes ❌ No (workload opt-out)
kagenti-enabled: true (no label) ✅ Yes ✅ Yes (namespace fallback)
(no label) kagenti.io/inject: enabled ❌ No ❌ No
(no label) (no label) ❌ No ❌ No
kagenti-enabled: false kagenti.io/inject: enabled ❌ No ❌ No

Note: The namespace must have kagenti-enabled: true label for the webhook to be invoked. This is a performance optimization to avoid unnecessary webhook calls for namespaces that won't be mutated.

Fixes:
rossoctl/rossoctl#526
#74

@cwiklik
cwiklik requested review from mrsabath and pdettori January 22, 2026 20:21
@cwiklik cwiklik added the enhancement New feature or request label Jan 22, 2026
@cwiklik cwiklik self-assigned this Jan 22, 2026
@cwiklik cwiklik changed the title feature: Add AuthBridge Mutating Webhook for Kubernetes Workloads feat: Add AuthBridge Mutating Webhook for Kubernetes Workloads Jan 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a mutating admission webhook that automatically injects AuthBridge sidecars into standard Kubernetes workloads (Deployments, StatefulSets, DaemonSets, Jobs, and CronJobs). Previously, AuthBridge injection was only available for custom resources (Agent and MCPServer CRs).

Changes:

  • Added new AuthBridge mutating webhook handler for workload resources
  • Implemented label-based opt-in/opt-out injection logic with namespace fallback
  • Added RBAC permissions for workload resource access

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
kagenti-webhook/internal/webhook/v1alpha1/authbridge_webhook.go New webhook handler that processes admission requests for Deployments, StatefulSets, DaemonSets, Jobs, and CronJobs
kagenti-webhook/internal/webhook/injector/pod_mutator.go Added InjectAuthBridge() and NeedsMutation() methods for new label-based injection logic
kagenti-webhook/internal/webhook/injector/namespace_checker.go Added IsNamespaceInjectionEnabled() function for namespace-level injection checks
kagenti-webhook/internal/webhook/injector/container_builder.go Fixed shell command quoting in BuildClientRegistrationContainer
kagenti-webhook/config/webhook/manifests.yaml Added authbridge webhook configuration to Kubernetes manifests
charts/kagenti-webhook/templates/authbridge-mutatingwebhook.yaml New Helm template for authbridge webhook with namespace selectors
charts/kagenti-webhook/templates/clusterrole.yaml Added RBAC permissions for workload resources
kagenti-webhook/scripts/full-deploy.sh Deployment script that creates authbridge webhook configuration
kagenti-webhook/cmd/main.go Registered AuthBridge webhook with manager
kagenti-webhook/Makefile Updated default cluster name and added deployment targets

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kagenti-webhook/scripts/full-deploy.sh Resolved

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants