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
- func HasEngine(pod *corev1.Pod) bool
- func Inject(pod *corev1.Pod, s Sidecar) bool
- func ObjectSelector(pods *metav1.LabelSelector) *metav1.LabelSelector
- func OptedOut(pod *corev1.Pod) bool
- func WantFailurePolicy(policies []wafv1alpha1.WAFPolicy) admissionregistrationv1.FailurePolicyType
- type PodWebhookReconciler
- type Reconciler
- type Sidecar
Constants ¶
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" // 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.
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 Inject ¶
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 ¶
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
}
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 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 ¶
func (r *PodWebhookReconciler) Reconcile(ctx context.Context, _ reconcile.Request) (reconcile.Result, error)
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 selects the proxy pods (integrations.Selectors.PodSelector).
Pods labels.Selector
}
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
}
Sidecar configures the injected engine.