admission

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package admission keeps pods in package namespaces on the images their packages pin: a tag a package pins becomes that tag at its digest, and in enforce mode an image no installed package vouches for is refused.

Index

Constants

View Source
const (
	ModeOff     = "off"
	ModeWarn    = "warn"
	ModeEnforce = "enforce"
)

Modes of the image policy.

View Source
const LabelImagePolicy = "kubepkg.dev/image-policy"

LabelImagePolicy on a namespace turns the image policy on there; the value is warn or enforce. The operator sets it on package namespaces.

Variables

This section is empty.

Functions

This section is empty.

Types

type Certs

type Certs struct {
	Client client.Client
	// Namespace and Service name the webhook Service; Secret holds the
	// certificates; Dir is the webhook server's certificate directory;
	// Webhook names the MutatingWebhookConfiguration.
	Namespace, Service, Secret, Dir, Webhook string
	// Now is the clock; time.Now when nil.
	Now func() time.Time
}

Certs keeps the webhook's serving certificate: a CA and a certificate for the webhook Service, in a Secret all replicas share, written to the directory the webhook server reads and given to the webhook configuration as its CA bundle. kubepkg issues them itself, so it does not depend on a certificate manager it might be the one installing.

func (*Certs) Ensure

func (c *Certs) Ensure(ctx context.Context) error

Ensure makes sure a valid certificate exists, is written to Dir and is trusted by the webhook configuration.

func (*Certs) NeedLeaderElection

func (c *Certs) NeedLeaderElection() bool

NeedLeaderElection is false: every replica serves the webhook.

func (*Certs) Start

func (c *Certs) Start(ctx context.Context) error

Start re-checks the certificate twice a day; it runs on every replica.

type Handler

type Handler struct {
	// Reader reads PackageSources and Namespaces, from the cache.
	Reader  client.Reader
	Decoder admission.Decoder
	// Recorder, when set, gets an Event on the pod's owner for every
	// image no package pins. Admission warnings go back to whoever made
	// the pod, usually a controller, so without Events nobody sees them.
	Recorder events.EventRecorder
}

Handler is the pod admission webhook.

func (*Handler) Handle

Handle implements admission.Handler.

type Pinned

type Pinned struct {
	// contains filtered or unexported fields
}

Pinned is what the installed packages pin.

func Collect

func Collect(ctx context.Context, c client.Reader) (*Pinned, error)

Collect gathers the images the installed packages pin.

func (*Pinned) Resolve

func (p *Pinned) Resolve(image string) (string, bool)

Resolve returns the image a container should run and whether a package vouches for it: a pinned tag gets its digest; an image with a digest is vouched for when a package pins that digest.

Jump to

Keyboard shortcuts

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