injection

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 33 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 (
	// HAProxyConfigMap holds HAProxyAuxKey and HAProxySPOEKey.
	HAProxyConfigMap = "inkwall-haproxy"
	HAProxyAuxKey    = "haproxy-aux.cfg"
	HAProxySPOEKey   = "spoe.conf"
	// HAProxyAuxPath is where the controller looks for its auxiliary
	// configuration file.
	HAProxyAuxPath = "/usr/local/etc/haproxy/haproxy-aux.cfg"
	// HAProxyConfDir holds spoe.conf in the controller's container.
	HAProxyConfDir = "/usr/local/etc/inkwall"
	// HAProxySPOEConf is spoe.conf's path, which the filter names.
	HAProxySPOEConf = HAProxyConfDir + "/" + HAProxySPOEKey
	// HAProxyContainer is the controller's container in its Helm chart.
	HAProxyContainer = "kubernetes-ingress-controller"
	// HAProxyConfigAnnotation on an injected pod says whether its HAProxy
	// got the agent's configuration: "mounted", or why not.
	HAProxyConfigAnnotation = "waf.inkwall.dev/haproxy-config"
	// HAProxyConfigMounted is HAProxyConfigAnnotation's value when it did.
	HAProxyConfigMounted = "mounted"
)

The HAProxy Kubernetes Ingress Controller's pods get, besides the engine, the SPOE agent's configuration (0002 §6.4): the agent's backend in the controller's auxiliary configuration file, which the controller loads after its own, and spoe.conf, which each protected Ingress's backend loads with its filter. Both come from HAProxyConfigMap, which the injection controller keeps in the pod's namespace.

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 (
	ReasonEngineConfigured = "Configured"
	// ReasonEngineTooOld: the engine pinned in spec.engine.image is a
	// release too old for some settings, which it is injected without.
	ReasonEngineTooOld = "EngineTooOld"
	// ReasonEngineVersionUnknown: the pinned engine's tag isn't a
	// release, so it is injected without the settings some releases
	// don't know.
	ReasonEngineVersionUnknown = "EngineVersionUnknown"
)

Reasons of the InkwallConfig's EngineConfigured condition.

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

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

View Source
const HAProxyResponseGroup = "inkwall-response"

HAProxyResponseGroup is the SPOE group that sends a response.

View Source
const HAProxyResponsesScope = "inkwall-responses"

HAProxyResponsesScope is spoe.conf's scope for the backends whose policies inspect responses: its request message tells the engine their responses follow, and its group sends them (0006 §4).

View Source
const ResponseMessagesFlag = "--response-messages"

ResponseMessagesFlag tells the engine of an HAProxy pod that HAProxy sends the responses of the requests whose policies inspect them (since 0.6.0): it keeps those requests for their responses.

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 EngineConfiguredCondition added in v0.6.0

func EngineConfiguredCondition(e wafv1alpha1.EngineSpec, generation int64) metav1.Condition

EngineConfiguredCondition says whether the engine is injected with every spec.engine setting e sets: False, naming those left out and why, when spec.engine.image pins an engine that may not know them.

func HAProxyConfigured added in v0.4.0

func HAProxyConfigured(pod *corev1.Pod) (bool, string)

HAProxyConfigured reports whether an injected HAProxy controller pod's HAProxy has the agent's configuration, and if not, why.

func HAProxyFiles added in v0.4.0

func HAProxyFiles() map[string]string

HAProxyFiles are HAProxyConfigMap's data: the agent's backend, on the engine's socket, with HELLO health checks (option spop-check), so a stopped engine is marked down at once; and the SPOE configuration, in two scopes: inkwall, for the backends whose policies don't inspect responses, and HAProxyResponsesScope, for those that do, which also sends the response (HAProxyResponseGroup) and registers its variables. Each sends the message the engine reads when a backend's http-request rules are about to run, telling it whether the response follows, so the engine keeps only the requests whose responses come. timeout processing is the largest inspection deadline (1s) plus 500ms: the engine decides a slow request itself, with its failure mode.

func HAProxyResponsesReady added in v0.6.0

func HAProxyResponsesReady(pod *corev1.Pod) (bool, string)

HAProxyResponsesReady reports whether an injected HAProxy controller pod's engine keeps requests for their responses (ResponseMessagesFlag), and if not, why. Pods injected before 0.6.0, or with a pinned engine that doesn't know the flag, don't: HAProxy mustn't send them responses.

func HasEngine added in v0.1.1

func HasEngine(pod *corev1.Pod) bool

HasEngine reports whether pod has the engine container.

func HasSocket added in v0.4.0

func HasSocket(pod *corev1.Pod, container string) bool

HasSocket reports whether pod's container mounts the engine's socket directory, as Inject mounts it in a SocketContainer.

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, and mounts the socket's directory in the SocketContainer. It reports false, changing nothing, for a pod that already has the engine or opted out.

func InjectHAProxy added in v0.4.0

func InjectHAProxy(pod *corev1.Pod)

InjectHAProxy gives an HAProxy controller pod, which Inject gave the engine, the engine's socket and the agent's configuration in its HAProxy container, and runs the engine as HAProxy's user when the container sets one, so HAProxy may connect to the socket. A pod whose container mounts its own auxiliary file keeps it: the agent's backend is then missing, and HAProxyConfigAnnotation says so.

func MountSocket added in v0.4.0

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

MountSocket mounts the engine's socket directory in s.SocketContainer, if pod has that container and it doesn't mount it yet. It reports whether it changed pod: another webhook (Istio's injector) may rewrite the container after Inject.

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
	// Pinned: Image is the InkwallConfig's spec.engine.image, not the
	// operator's own engine, so it gets only the flags its release knows
	// (ImageVersion, LeftOut).
	Pinned     bool
	PullPolicy corev1.PullPolicy
	// PullSecrets are Secrets in the pod's namespace the engine image is
	// pulled with: Inject adds them to the pod's imagePullSecrets. Proxies
	// whose pod template the operator patches (Envoy Gateway, Istio) take
	// them from their own configuration.
	PullSecrets []string
	// 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
	// TrustedProxies and TrustedHops are the InkwallConfig's
	// spec.engine.clientIP, besides the loopback.
	TrustedProxies []string
	TrustedHops    int
	// DenyBeforeBundle rejects requests until the engine has a bundle.
	DenyBeforeBundle bool
	// LogLevel is the engine's --log-level, empty for its default.
	LogLevel string
	// PolicyMetrics passes --policy-metrics.
	PolicyMetrics bool
	// JSONDenials passes --json-denials.
	JSONDenials bool
	// ResponseMessages passes --response-messages (ResponseMessagesFlag):
	// the proxy sends the responses of the routes whose policies inspect
	// them (HAProxy, in the inkwall-responses scope of spoe.conf).
	ResponseMessages 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
	// SocketContainer, with SocketDir, is the proxy's container Inject
	// mounts SocketDir in (istio-proxy).
	SocketContainer string
	// PodAnnotations are set on the pod Inject injects.
	PodAnnotations map[string]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.

func (Sidecar) LeftOut added in v0.6.0

func (s Sidecar) LeftOut() []string

LeftOut returns the settings s sets that its engine is injected without, because its release (or a custom build) may not know their flags.

type Version added in v0.6.0

type Version [3]int

Version is an engine release, MAJOR.MINOR.PATCH.

func ImageVersion added in v0.6.0

func ImageVersion(image string) (Version, bool)

ImageVersion returns the release an engine image runs, read from its tag: "ghcr.io/inkwall-dev/inkwall-engine:0.4.1", with or without a leading "v", a pre-release suffix or a digest after it. False when the tag isn't a release (latest, a branch, a digest alone): a custom build.

func (Version) String added in v0.6.0

func (v Version) String() string

Jump to

Keyboard shortcuts

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