injection

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 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 injection gets the engine into a proxy's pods (0004 §4.3): a Pod webhook adds it as a native sidecar, and a controller provides what the sidecar needs in the pod's namespace (the trust ConfigMap) and in the operator's (read access to the bundle Secret).

Index

Constants

View Source
const (
	ContainerName = "inkwall-engine"
	// TrustConfigMap holds the operator's CA (ca.crt) and the bundle public
	// keys in the pod's namespace: trusted-keys.pub, every key the engine
	// accepts, and ed25519.pub, the active one. All are public. The kubelet
	// updates the mounted files when it changes, and the engine reloads
	// the keys.
	TrustConfigMap = "inkwall-trust"

	// SocketVolume shares the engine's Unix socket with the proxy
	// (Sidecar.SocketDir).
	SocketVolume = "inkwall-socket"

	// InjectedAnnotation marks a pod the engine was injected into.
	InjectedAnnotation = "waf.inkwall.dev/injected"
	// InjectAnnotation set to "false" on a pod keeps the engine out. As a
	// label (InjectLabel), the Pod webhook isn't even called: the pod
	// starts while the operator is down, when the webhook fails closed.
	InjectAnnotation = "waf.inkwall.dev/inject"
	InjectLabel      = InjectAnnotation
)

Names in the pods the engine is injected into.

View Source
const GrantName = "inkwall-bundle-reader"

GrantName names the Role and RoleBinding that let proxy pods read the bundle Secret.

Variables

This section is empty.

Functions

func Engine added in v0.3.0

func Engine(s Sidecar) (corev1.Container, []corev1.Volume)

Engine returns the engine container, a native sidecar (an init container with restartPolicy Always), and the volumes it needs: what Inject adds to a pod, and what a proxy with its own pod template takes (Envoy Gateway's EnvoyProxy).

func HasEngine added in v0.1.1

func HasEngine(pod *corev1.Pod) bool

HasEngine reports whether pod has the engine container.

func Inject

func Inject(pod *corev1.Pod, s Sidecar) bool

Inject adds the engine to pod as a native sidecar (an init container with restartPolicy Always, so it starts before the proxy and stops after it), and the volumes it needs. It reports false, changing nothing, for a pod that already has the engine or opted out.

func ObjectSelector

func ObjectSelector(pods *metav1.LabelSelector) *metav1.LabelSelector

ObjectSelector is the Pod webhook's objectSelector for pods: those pods, without the ones that opted out with the label.

func OptedOut

func OptedOut(pod *corev1.Pod) bool

OptedOut reports whether pod keeps the engine out, with the annotation or the label.

func WantFailurePolicy

func WantFailurePolicy(policies []wafv1alpha1.WAFPolicy) admissionregistrationv1.FailurePolicyType

WantFailurePolicy is the Pod webhook's failurePolicy for these policies.

Types

type PodWebhookReconciler

type PodWebhookReconciler struct {
	Client client.Client
	// ConfigName is the MutatingWebhookConfiguration, WebhookName its Pod
	// webhook.
	ConfigName  string
	WebhookName string
	// Pods selects the proxy pods (integrations.Selectors.LabelSelector).
	Pods *metav1.LabelSelector
	// Namespaces are the proxy namespaces.
	Namespaces integrations.Namespaces
}

PodWebhookReconciler keeps the Pod webhook's objectSelector and failurePolicy (0004 §4.3). It runs on the leader; the chart installs the webhook with the defaults, and a Helm upgrade that resets them is corrected here.

The objectSelector is the proxy pods' selector (InkwallConfig can override it), minus pods labeled waf.inkwall.dev/inject: "false"; the namespaceSelector, the proxy namespaces.

The failurePolicy follows the policies' modes. Detect only: Ignore, so proxy pods start even while the operator is down, without the engine (reported as SidecarMissing). Any policy in block mode: Fail, so a proxy pod can't start without its engine while its routes must be blocked; pods already running keep serving.

func (*PodWebhookReconciler) Reconcile

Reconcile sets the objectSelector and failurePolicy.

func (*PodWebhookReconciler) SetupWithManager

func (r *PodWebhookReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the controller. The manager must cache the MutatingWebhookConfiguration (only ConfigName).

type Reconciler

type Reconciler struct {
	Client client.Client
	// APIReader reads uncached: the trust ConfigMaps aren't cached.
	APIReader client.Reader
	// Namespace is the operator's, with the bundle and certificate Secrets.
	Namespace string
	// CertSecret holds the operator's CA (ca.crt).
	CertSecret string
	// Pods select the proxy pods (nil: the defaults), and Disabled are the
	// integrations the operator may not wire, by name: their pods are
	// neither given the trust ConfigMap nor granted the bundle.
	Pods     *integrations.Selectors
	Disabled map[string]string
}

Reconciler provides what injected engines need. It runs on the leader.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)

Reconcile reconciles the trust ConfigMap of a namespace, or the grant.

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the controller.

type Sidecar

type Sidecar struct {
	Image      string
	PullPolicy corev1.PullPolicy
	// Resources of the engine; empty: the defaults below.
	Resources *corev1.ResourceRequirements
	// OperatorAddr is the distribution server, host:port.
	OperatorAddr string
	// BundleSecret is the bundle Secret, namespace/name, that a new engine
	// reads when the operator is unreachable.
	BundleSecret string
	// DenyBeforeBundle rejects requests until the engine has a bundle.
	DenyBeforeBundle bool
	// Args are the adapter's command and its own flags, e.g.
	// ["forward-auth"].
	Args []string
	// SocketDir, when set, is an emptyDir (SocketVolume) mounted in the
	// engine, for a Unix socket the proxy mounts too.
	SocketDir string
}

Sidecar configures the injected engine.

func (Sidecar) Configured added in v0.3.0

func (s Sidecar) Configured(e wafv1alpha1.EngineSpec) Sidecar

Configured returns s with an InkwallConfig's engine settings.

Jump to

Keyboard shortcuts

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