projection

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Overview

Package projection watches CustomResourceProjection objects and keeps the served API surface in sync with them.

Index

Constants

View Source
const ResyncPeriod = 10 * time.Minute

ResyncPeriod is how often the informer relists projections, as a backstop against a missed watch event.

Variables

View Source
var APIServiceGVR = schema.GroupVersionResource{
	Group:    "apiregistration.k8s.io",
	Version:  "v1",
	Resource: "apiservices",
}

APIServiceGVR is the resource the aggregation layer routes with.

View Source
var GVR = schema.GroupVersionResource{
	Group:    crispv1alpha1.GroupName,
	Version:  "v1alpha1",
	Resource: "customresourceprojections",
}

GVR is the resource the controller watches. The typed client knows this already; it is kept because the APIService reconciler and the tests address resources by GVR.

Functions

This section is empty.

Types

type APIServiceOptions

type APIServiceOptions struct {
	// Enabled turns the reconciler on.
	Enabled bool

	// ServiceName and ServiceNamespace locate the Service in front of this
	// server; Port is the Service port, not the container port.
	ServiceName      string
	ServiceNamespace string
	Port             int32

	// CABundle verifies this server's serving certificate. When empty, the
	// APIService is created with insecureSkipTLSVerify, which matches the
	// self-signed certificates the server generates by default.
	CABundle []byte

	// GroupPriorityMinimum and VersionPriority order this group against others.
	GroupPriorityMinimum int32
	VersionPriority      int32

	// AllowedGroupSuffixes bounds which API groups a projection may claim. A
	// group is allowed when it equals one of these or ends in "." followed by
	// one. Empty allows any group, which is the default and what every existing
	// deployment had.
	//
	// Registering a group is not a local act. An APIService is cluster-scoped
	// and routes a whole group/version to this server, so a projection naming
	// "cert-manager.io/v1" -- a group whose operator is not installed yet --
	// takes it, and takes it for good: the kube-apiserver's own controllers
	// only manage APIServices carrying the automanaged label, so nothing hands
	// it back when the real operator arrives.
	//
	// Whoever may write a projection is not necessarily whoever decides which
	// API groups a cluster serves. This is how an operator keeps those apart,
	// by naming the suffixes their projections live under.
	AllowedGroupSuffixes []string
}

APIServiceOptions describes how to reach this server, which is what an APIService needs in order to route to it.

func DefaultAPIServiceOptions

func DefaultAPIServiceOptions() APIServiceOptions

DefaultAPIServiceOptions returns options pointing at the conventional in-cluster deployment.

type Controller

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

Controller keeps the router's resources in sync with the cluster.

func New

func New(opts Options) *Controller

New builds a controller. The caller owns starting the informer factory.

func (*Controller) Degraded

func (c *Controller) Degraded() []string

Degraded returns the projections that are defined but not being served, sorted. An empty result means every projection compiled.

func (*Controller) HasSynced

func (c *Controller) HasSynced() bool

HasSynced reports whether the controller has installed the API surface at least once, which is what makes the server ready to serve projections.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context)

Run processes queue items until the context is cancelled.

type Options

type Options struct {
	// Client reads projections and writes their status.
	Client crispclient.Interface

	// DynamicClient is used for the APIServices this server registers.
	DynamicClient dynamic.Interface

	// Factory supplies the projection informer. The caller owns starting it.
	Factory crispinformers.SharedInformerFactory

	// SecretInformers watch the Secrets that hold data source credentials, so
	// a rotated password is picked up when it changes rather than at the next
	// resync. One per namespace credentials may be read from. Optional: with
	// none, rotation still lands within ResyncPeriod.
	SecretInformers []cache.SharedIndexInformer

	// APIServiceInformer watches the registrations this server manages, so
	// reconciling them reads from a cache rather than making a request per
	// served group version on every sync. Optional: without it the reconciler
	// reads through the client.
	APIServiceInformer cache.SharedIndexInformer

	// CRDInformer watches the CustomResourceDefinitions that projections
	// borrow schemas from, so an edited one is picked up when it changes
	// rather than at the next resync. Metadata only: the schema itself is read
	// through the client when a projection is prepared, and caching every
	// schema in the cluster is a cost this server has no reason to pay.
	// Optional: with none, an edit still lands within ResyncPeriod.
	CRDInformer cache.SharedIndexInformer

	// Compiler turns projections into servable resources; Router installs them.
	Compiler *apidynamic.Compiler
	Router   *apidynamic.Router
	// HasPeers reports whether this server expects to run alongside other
	// replicas, which is what makes a projection with no mapped resourceVersion
	// unsafe: the version a list reports then comes from a per-replica counter,
	// so two replicas hand the same client incompatible versions.
	HasPeers bool

	// Pools is the shared connection pool cache, trimmed as projections come
	// and go.
	Pools *crispsql.PoolCache

	// Static projections come from --projection-dir and are always served,
	// regardless of what exists in the cluster.
	Static []crispv1alpha1.CustomResourceProjection

	// StaticDir is where those came from. Given one, the controller re-reads it
	// on every sync and watches it for changes; without one, Static is fixed.
	StaticDir string

	// APIServices controls whether this server registers the groups it serves
	// with the aggregation layer, and how it describes itself when it does.
	APIServices APIServiceOptions

	// EventClient records Events against projections. Optional: without it the
	// controller reports through conditions and the log only.
	//
	// Conditions say what a projection's state is now; an Event says that it
	// changed and when. That is what kubectl describe shows, and what anything
	// watching for failures reacts to — neither of which a condition alone
	// reaches.
	EventClient kubernetes.Interface
}

Options configures a Controller.

Jump to

Keyboard shortcuts

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