webhook

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package webhook provides the mutating admission webhook handler for rewriting secret volumes to point to shadow secrets.

Index

Constants

View Source
const (
	SecretName = "kloak-webhook-certs"
	CertKey    = "tls.crt"
	KeyKey     = "tls.key"
)
View Source
const (
	// LabelEnabled is the label used to enable Kloak on a pod or namespace.
	// Pod-level enablement uses a label (not annotation) so that Kubernetes
	// objectSelector can match it, allowing the webhook to be scoped precisely.
	LabelEnabled = "getkloak.io/enabled"

	// AnnotationEnabled is the annotation injected by the webhook onto mutated pods.
	// The controller (DaemonSet) reads this to determine if a pod is kloak-enabled.
	AnnotationEnabled = "getkloak.io/enabled"
)
View Source
const (
	// AnnotationHosts is the hostname/IP a secret may be sent to.
	AnnotationHosts = "getkloak.io/hosts"
	// AnnotationPort restricts a secret to a specific port (or port/proto).
	AnnotationPort = "getkloak.io/port"
)

Variables

This section is empty.

Functions

func EnsureWebhookCerts

func EnsureWebhookCerts(ctx context.Context, c client.Client, namespace string) ([]byte, error)

EnsureWebhookCerts generates a self-signed certificate for the mutating webhook if the secret does not already exist in the cluster.

func PatchWebhookConfiguration

func PatchWebhookConfiguration(ctx context.Context, c client.Client, certPEM []byte) error

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(c client.Client, log *zap.SugaredLogger) *Handler

func (*Handler) Handle

Handle processes admission requests for pods. The admission.Handler interface requires req by value — cannot use a pointer.

type SecretValidator added in v0.1.1

type SecretValidator struct {
	// contains filtered or unexported fields
}

SecretValidator is a ValidatingAdmissionWebhook for kloak-enabled Secrets. It rejects configurations that would silently bypass runtime filters (e.g. a host label longer than the BPF map can compare).

func NewSecretValidator added in v0.1.1

func NewSecretValidator(log *zap.SugaredLogger) *SecretValidator

func (*SecretValidator) Handle added in v0.1.1

Handle validates a Secret admission request. Non-kloak-enabled secrets are allowed through unchanged; the webhook should also be scoped with an objectSelector on `getkloak.io/enabled=true`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL