server

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 142 Imported by: 4

Documentation

Index

Constants

View Source
const (
	HomeBucketClusterWorkspaceType = "homebucket"
	HomeClusterWorkspaceType       = "home"
)

Variables

View Source
var SystemCRDLogicalCluster = logicalcluster.New("system:system-crds")

SystemCRDLogicalCluster is the logical cluster we install system CRDs into for now. These are needed to start wildcard informers until a "real" workspace gets them installed.

Functions

func IdentityFromContext added in v0.6.0

func IdentityFromContext(ctx context.Context) string

IdentityFromContext retrieves the APIExport identity from the context, if any.

func NewTableConverterProvider added in v0.6.0

func NewTableConverterProvider() *tableConverterProvider

func UserAgentFrom added in v0.6.0

func UserAgentFrom(ctx context.Context) string

func WithAcceptHeader added in v0.6.0

func WithAcceptHeader(apiHandler http.Handler) http.Handler

WithAcceptHeader makes the Accept header available for code in the handler chain. It is needed for Wildcard requests, when finding the CRD with a common schema. For PartialObjectMeta requests we cand weaken the schema requirement and allow different schemas across workspaces.

func WithAuditAnnotation added in v0.6.0

func WithAuditAnnotation(handler http.Handler) http.HandlerFunc

WithAuditAnnotation initializes audit annotations in the context. Without initialization kaudit.AddAuditAnnotation isn't preserved.

func WithClusterAnnotation added in v0.6.0

func WithClusterAnnotation(handler http.Handler) http.HandlerFunc

WithClusterAnnotation adds the cluster name into the annotation of an audit event. Needs initialized annotations.

func WithClusterScope

func WithClusterScope(apiHandler http.Handler) http.HandlerFunc

func WithHomeWorkspaces added in v0.6.0

func WithHomeWorkspaces(
	apiHandler http.Handler,
	a authorizer.Authorizer,
	kubeClusterClient kubernetesclient.ClusterInterface,
	kcpClusterClient kcpclient.ClusterInterface,
	kubeSharedInformerFactory kubernetesinformers.SharedInformerFactory,
	kcpSharedInformerFactory kcpinformers.SharedInformerFactory,
	externalHost string,
	creationDelaySeconds int,
	homePrefix logicalcluster.Name,
	bucketLevels,
	bucketSize int,
) http.Handler

WithHomeWorkspaces implements an HTTP handler, in the KCP server, which:

- creates a Home workspace on-demand for requests that target the home workspace or its descendants, taking care of the optional creation of bucket workspaces, - supports a special 'kubectl get workspace ~' request which can return the user home workspace definition even before it exists.

When the Home workspace is still not Ready, the handler returns a Retry-After response with a delay in seconds that is configurable (creationDelaySeconds), so that client-go clients will automatically retry the request after this delay.

- homePrefix is the workspace that will contains all the user home workspaces, partitioned by bucket workspaces - bucketLevels is the number of bucket workspaces met before reaching a home workspace from the homePefix workspace - bucketSize is the number of chars comprising each bucket.

Bucket workspace names are calculated based on the user name hash.

func WithIdentity added in v0.6.0

func WithIdentity(ctx context.Context, identity string) context.Context

WithIdentity adds an APIExport identity to the context.

func WithInClusterServiceAccountRequestRewrite added in v0.6.0

func WithInClusterServiceAccountRequestRewrite(handler http.Handler) http.Handler

WithInClusterServiceAccountRequestRewrite adds the /clusters/<clusterName> prefix to the request path if the request comes from an InCluster service account requests (InCluster clients don't support prefixes).

func WithUserAgent added in v0.6.0

func WithUserAgent(handler http.Handler) http.Handler

func WithWildcardIdentity added in v0.6.0

func WithWildcardIdentity(handler http.Handler) http.Handler

WithWildcardIdentity checks wildcard list/watch requests for an APIExport identity for the resource in the path. If it finds one (e.g. /api/v1/services:identityabcd1234/default/my-service), it places the identity from the path to the context, updates the request to remove the identity from the path, and updates requestInfo.Resource to also remove the identity. Finally, it hands off to the passed in handler to handle the request.

func WithWildcardListWatchGuard

func WithWildcardListWatchGuard(apiHandler http.Handler) http.HandlerFunc

func WithWorkspaceProjection added in v0.6.0

func WithWorkspaceProjection(apiHandler http.Handler, shardVirtualWorkspaceURL *url.URL) http.HandlerFunc

WithWorkspaceProjection maps the personal virtual workspace "workspaces" resource into the cluster workspace URL space. This means you can do `kubectl get workspaces` from an org workspace.

Types

type CompletedConfig added in v0.7.0

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

type Config added in v0.7.0

type Config struct {
	Options *kcpserveroptions.CompletedOptions

	EmbeddedEtcd *embeddedetcd.Config

	GenericConfig  *genericapiserver.Config // the config embedded into MiniAggregator, the head of the delegation chain
	MiniAggregator *aggregator.MiniAggregatorConfig
	Apis           *apis.Config
	ApiExtensions  *apiextensionsapiserver.Config

	ExtraConfig
}

func NewConfig added in v0.7.0

func NewConfig(opts *kcpserveroptions.CompletedOptions) (*Config, error)

func (*Config) Complete added in v0.7.0

func (c *Config) Complete() (CompletedConfig, error)

Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.

type ExtraConfig added in v0.7.0

type ExtraConfig struct {

	// clients
	DynamicClusterClient       dynamic.ClusterInterface
	KubeClusterClient          kubernetesclient.ClusterInterface
	DeepSARClient              kubernetesclient.ClusterInterface
	ApiExtensionsClusterClient apiextensionsclient.ClusterInterface
	KcpClusterClient           kcpclient.ClusterInterface
	RootShardKcpClusterClient  kcpclient.ClusterInterface

	// informers
	KcpSharedInformerFactory              kcpinformers.SharedInformerFactory
	KubeSharedInformerFactory             kubernetesinformers.SharedInformerFactory
	ApiExtensionsSharedInformerFactory    apiextensionsexternalversions.SharedInformerFactory
	DynamicDiscoverySharedInformerFactory *informer.DynamicDiscoverySharedInformerFactory

	// TODO(p0lyn0mial):  get rid of TemporaryRootShardKcpSharedInformerFactory, in the future
	//                    we should have multi-shard aware informers
	//
	// TODO(p0lyn0mial): wire it to the root shard, this will be needed to get bindings,
	//                   eventually it will be replaced by replication
	//
	// TemporaryRootShardKcpSharedInformerFactory bring data from the root shard
	TemporaryRootShardKcpSharedInformerFactory kcpinformers.SharedInformerFactory
	// contains filtered or unexported fields
}

type Server

type Server struct {
	CompletedConfig

	*genericcontrolplane.ServerChain
	// contains filtered or unexported fields
}

func NewServer

func NewServer(c CompletedConfig) (*Server, error)

func (*Server) AddPostStartHook

func (s *Server) AddPostStartHook(name string, hook genericapiserver.PostStartHookFunc) error

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

type TableConverterFunc added in v0.6.0

type TableConverterFunc func(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)

func (TableConverterFunc) ConvertToTable added in v0.6.0

func (tcf TableConverterFunc) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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