Documentation
¶
Overview ¶
Package endpointslice publishes a virtual workspace's address into the endpoint slices that APIExports reference.
The kcp side of a virtual resource is a reference from an APIExport to an object with a URL in its status. Nothing fills that URL in for a virtual workspace kcp does not run, which is what this is for.
It runs against a single workspace -- the one the APIExport lives in -- and that is not an accident of packaging. The slice kind is a CRD a provider applied to their own workspace, so it is only served there: there is no cluster-wide list of them to make, and no reason for this to hold credentials beyond the workspace it publishes into.
It works on unstructured objects because the kind belongs to the provider, not to this repository, so there are no generated clients for it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GroupVersionResource = schema.GroupVersionResource{ Group: "ephemeral.contrib.kcp.io", Version: "v1alpha1", Resource: ephemeralv1alpha1.EndpointSliceResource, }
GroupVersionResource of the slices this controller owns.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller publishes a virtual workspace's address into the slices of one workspace.
func NewController ¶
func NewController(client dynamic.Interface, opts Options) (*Controller, error)
NewController returns a controller publishing into the workspace its client is scoped to.
func (*Controller) Publish ¶
func (c *Controller) Publish(ctx context.Context, slice *unstructured.Unstructured) error
Publish writes the virtual workspace's URL into one slice, if it is not already there.
It writes a single endpoint and replaces whatever was in the list. That is correct for one virtual workspace serving every shard, and wrong for several instances each serving some: they would overwrite each other. Supporting that means each instance owning its own entry in the list.
func (*Controller) Start ¶
func (c *Controller) Start(ctx context.Context)
Start publishes until the context is cancelled.
func (*Controller) Sync ¶
func (c *Controller) Sync(ctx context.Context) error
Sync brings every slice in the workspace in line with where the virtual workspace is.
func (*Controller) URLFor ¶
func (c *Controller) URLFor(cluster logicalcluster.Name, exportName string) string
URLFor builds the address the virtual workspace serves an export's ephemeral resources on. It has to agree with what that server answers, which is <prefix>/<name>/<cluster>/<export>.
type Options ¶
type Options struct {
// ExternalURL is where kcp should reach the virtual workspace, without a
// path: https://ephemeral.example.com:6454.
ExternalURL string
// RootPathPrefix and VirtualWorkspaceName are the path the virtual
// workspace answers on, and have to match what it was started with, or the
// published URL points at nothing.
RootPathPrefix string
VirtualWorkspaceName string
// ExportName, when set, limits publishing to slices for that APIExport.
// Empty means every slice in the workspace.
ExportName string
// Shards selects which shards should use the published URL. The zero value
// publishes matchAll, meaning every shard -- one virtual workspace for the
// whole installation, which is what a webhook-backed resource wants: there
// is nothing shard-local about asking a provider a question.
//
// Naming shards here is how an installation running one virtual workspace
// per shard would describe itself, but see Publish: this writes a single
// endpoint, so several instances would overwrite each other rather than
// each contributing one.
Shards ephemeralv1alpha1.EndpointSelector
// ResyncInterval bounds how long a newly created slice waits for its URL.
//
// A watch would be tidier. This is a loop because the kind is defined by a
// provider's CRD and may not exist when this starts, which a typed informer
// does not survive but a list does.
ResyncInterval time.Duration
}
Options configure the controller.