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
- func AddCertRotator(mgr manager.Manager, o CertOptions, ready chan struct{}) error
- func EnsureCertSecret(ctx context.Context, c client.Client, key types.NamespacedName) error
- func OperatorUser(ctx context.Context, c client.Client) (string, error)
- func ServiceDNSNames(service, namespace string) []string
- func Setup(mgr manager.Manager, inject *PodInjector, guard *SourceGuard) error
- type CertOptions
- type PodInjector
- type SourceGuard
Constants ¶
const InjectPath = "/mutate-v1-pod"
InjectPath is the Pod webhook's path.
const MutatingConfigName = "inkwall-operator-mutating"
MutatingConfigName is the MutatingWebhookConfiguration of the Pod webhook; the certificate rotator injects its CA bundle.
const PodWebhookName = "pods.waf.inkwall.dev"
PodWebhookName is the Pod webhook in MutatingConfigName.
const PolicyWebhookName = "wafpolicies.waf.inkwall.dev"
PolicyWebhookName is the WAFPolicy webhook in ValidatingConfigName.
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 ¶
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
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 ¶
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.
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.