globalwebhook

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 18 Imported by: ? 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 globalwebhook implements a GLOBAL, cluster-aware validating admission webhook: a single ValidatingWebhookConfiguration, supplied to the shard at startup (via --admission-control-config-file, this plugin's config section), that fires for requests in EVERY logical cluster - without a per-workspace WebhookConfiguration object, and tamper-proof against workspace admins.

This is to admission what --authorization-webhook-config-file is to authorization: one endpoint, wired at bootstrap, applied globally. Unlike the authorization webhook it is an ADMISSION webhook, so the callout carries the full object body + operation and can DENY. The request's logical cluster is conveyed on the object via the kcp.io/cluster annotation (like kcp's per- cluster webhook plugin), stamped here for create/update (object) and delete (oldObject) so the external webhook is cluster-aware on every operation.

Configure it by putting a normal ValidatingWebhookConfiguration in this plugin's admission-config section (see docs/content/...); leave it unset and the plugin is inert. Only URL clientConfig with a caBundle is required - no per-cluster objects, no APIBindings.

Why only kcp.io/cluster, and not kcp.io/path?

Stamping the canonical workspace path as well would spare webhooks a front-proxy-style path cache, but there is no source that yields a correct path on EVERY request this plugin sees, and a wrong or missing path is worse than none:

  • root and system:shard: their LogicalCluster objects carry no kcp.io/path annotation, so the path would have to be derived from the name.
  • system:admin, system:system-crds, system, ...: no LogicalCluster object exists at all, so a lister lookup always misses.
  • freshly created workspaces: writes from initializers and child bootstrapping race the local LogicalCluster informer, so the lookup misses for a short window after creation.
  • the LogicalCluster create itself: the object does not exist yet.

Falling back to the cluster name in those cases is right for root/system:* (name == path) but hands webhook authors a hash as a "path" for workspace clusters in the race window; failing closed there breaks workspace bootstrap; omitting the annotation only sometimes makes it unreliable to program against. Webhooks that need the path can resolve it from the cluster name via the LogicalCluster (or the front-proxy index) themselves.

Index

Constants

View Source
const (
	// PluginName is the admission plugin name.
	PluginName = "apis.kcp.io/GlobalValidatingWebhook"
)

Variables

This section is empty.

Functions

func Register

func Register(plugins *admission.Plugins)

Register registers the plugin.

Types

type Plugin

type Plugin struct {
	*admission.Handler
	// contains filtered or unexported fields
}

Plugin is a global, cluster-aware validating admission webhook. It holds a static webhook source parsed once from its admission config; when that config is absent it is inert.

func NewGlobalValidatingWebhook

func NewGlobalValidatingWebhook(configFile io.Reader) (*Plugin, error)

NewGlobalValidatingWebhook parses the plugin config (a ValidatingWebhookConfiguration) into a static source. An empty config yields an inert plugin.

func (*Plugin) SetKubeClusterClient

func (p *Plugin) SetKubeClusterClient(client kcpkubernetesclientset.ClusterInterface)

SetKubeClusterClient implements WantsKubeClusterClient.

func (*Plugin) SetKubeInformers

func (p *Plugin) SetKubeInformers(local, global kcpkubernetesinformers.SharedInformerFactory)

SetKubeInformers implements WantsKubeInformers. Only the local factory is used (namespace informer); the source is static, so no global config informer.

func (*Plugin) Validate

Validate dispatches the admission request to the globally-configured webhook, with the request's logical cluster stamped on the object so the external webhook is cluster-aware.

func (*Plugin) ValidateInitialization

func (p *Plugin) ValidateInitialization() error

ValidateInitialization ensures required dependencies were injected.

Jump to

Keyboard shortcuts

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