webhook

package
v0.3.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 32 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webhook holds the operator's admission webhooks. The validating webhook checks what the CRD schemas can't (0004 §3.1, level 2): rule sets must compile the way the engine loads them, and policy paths must be ones the engine's router can match. In Managed mode it also keeps the control plane's policies to the operator (SourceGuard), and warns about the InkwallConfig's deprecated fields.

Index

Constants

View Source
const InjectPath = "/mutate-v1-pod"

InjectPath is the Pod webhook's path.

View Source
const MutatingConfigName = "inkwall-operator-mutating"

MutatingConfigName is the MutatingWebhookConfiguration of the Pod webhook; the certificate rotator injects its CA bundle.

View Source
const PodWebhookName = "pods.waf.inkwall.dev"

PodWebhookName is the Pod webhook in MutatingConfigName.

View Source
const PolicyWebhookName = "wafpolicies.waf.inkwall.dev"

PolicyWebhookName is the WAFPolicy webhook in ValidatingConfigName.

View Source
const ValidatingConfigName = "inkwall-operator-validating"

ValidatingConfigName is the ValidatingWebhookConfiguration the webhooks below are registered in; the certificate rotator injects its CA bundle.

Variables

This section is empty.

Functions

func AddCertRotator

func AddCertRotator(mgr manager.Manager, o CertOptions, ready chan struct{}) error

AddCertRotator keeps a self-signed CA and serving certificate in the Secret, writes the certificate to CertDir and injects the CA into the validating webhook configuration, renewing them before they expire. ready is closed once the certificate files are in place and the CA is injected. It runs on every replica, so each one can serve; the replicas share the Secret. The Secret must exist (EnsureCertSecret).

func EnsureCertSecret

func EnsureCertSecret(ctx context.Context, c client.Client, key types.NamespacedName) error

EnsureCertSecret creates the empty certificate Secret if it doesn't exist; the rotator only fills an existing one. It runs before the manager starts, so it uses a direct client.

func OperatorUser added in v0.1.1

func OperatorUser(ctx context.Context, c client.Client) (string, error)

OperatorUser asks the API server who the operator is (SelfSubjectReview, which every authenticated user may ask), so the guard knows its writes whatever its ServiceAccount is called.

func ServiceDNSNames

func ServiceDNSNames(service, namespace string) []string

ServiceDNSNames returns the names of a Service, for CertOptions.DNSNames.

func Setup

func Setup(mgr manager.Manager, inject *PodInjector, guard *SourceGuard) error

Setup registers the validating webhooks with mgr's webhook server, and the Pod webhook when inject is set. guard keeps the control plane's objects to the operator.

Types

type CertOptions

type CertOptions struct {
	// Secret holds the CA and the serving certificate, shared by every
	// replica.
	Secret types.NamespacedName
	// CertDir is where the certificate files are written for the webhook
	// server.
	CertDir string
	// DNSNames are the names the certificate is valid for: the webhook
	// Service's, and the distribution Service's.
	DNSNames []string
	// InjectWebhooks injects the CA into the validating webhook
	// configuration; off when the webhook is disabled.
	InjectWebhooks bool
	// InjectPodWebhook also injects it into the mutating configuration of
	// the Pod webhook.
	InjectPodWebhook bool
}

CertOptions configures the webhook's serving certificate.

type PodInjector

type PodInjector struct {
	// Client reads the InkwallConfig.
	Client client.Reader
	// Decoder decodes pods.
	Decoder admission.Decoder
	// Image and PullPolicy are the engine's, unless InkwallConfig sets one.
	Image      string
	PullPolicy corev1.PullPolicy
	// OperatorAddr is the distribution server engines connect to.
	OperatorAddr string
	// Integrations recognise proxy pods; nil: the defaults.
	Integrations *integrations.Selectors
	// Namespaces are the proxy namespaces: a pod elsewhere isn't a proxy
	// pod, whatever its labels (the webhook's namespaceSelector leaves it
	// out already).
	Namespaces integrations.Namespaces
	// Disabled are the integrations the operator may not wire, by name
	// (0004 §7): their pods don't get the engine.
	Disabled map[string]string
	// BundleSecret is the bundle Secret, namespace/name, engines read when
	// the operator is unreachable.
	BundleSecret string
}

PodInjector adds the engine to proxy pods.

func (*PodInjector) Handle

Handle injects the engine into a pod of a known proxy.

type SourceGuard added in v0.1.1

type SourceGuard struct {
	// Operator is the user the operator writes as (OperatorUser).
	Operator string
	// Reader reads the InkwallConfig, whose mode decides.
	Reader client.Reader
}

SourceGuard keeps the control plane's objects, labelled inkwall.dev/source: saas, to the operator while the cluster is in Managed mode (0004 §4.9): no one else may create, change or delete them, or add or remove the label. In the other modes the operator doesn't write them, so they are ordinary objects again, which their owners can clean up.

Jump to

Keyboard shortcuts

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