v1alpha1

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

+k8s:deepcopy-gen=package,register +groupName=workload.kcp.io +k8s:openapi-gen=true

Index

Constants

View Source
const (
	// ResourceSchemaPendingState is the initial state indicating that the syncer has not report compatibility of the resource.
	ResourceSchemaPendingState = "Pending"
	// ResourceSchemaAcceptedState is the state that the resource schema is compatible and can be synced by syncer.
	ResourceSchemaAcceptedState = "Accepted"
	// ResourceSchemaIncompatibleState is the state that the resource schema is incompatible for syncer.
	ResourceSchemaIncompatibleState = "Incompatible"
)
View Source
const (
	// SyncerReady means the syncer is ready to transfer resources between KCP and the SyncTarget.
	SyncerReady conditionsv1alpha1.ConditionType = "SyncerReady"

	// APIImporterReady means the APIImport component is ready to import APIs from the SyncTarget.
	APIImporterReady conditionsv1alpha1.ConditionType = "APIImporterReady"

	// HeartbeatHealthy means the HeartbeatManager has seen a heartbeat for the SyncTarget within the expected interval.
	HeartbeatHealthy conditionsv1alpha1.ConditionType = "HeartbeatHealthy"

	// SyncerAuthorized means the syncer is authorized to sync resources to downstream cluster.
	SyncerAuthorized conditionsv1alpha1.ConditionType = "SyncerAuthorized"

	// ErrorHeartbeatMissedReason indicates that a heartbeat update was not received within the configured threshold.
	ErrorHeartbeatMissedReason = "ErrorHeartbeat"
)

Conditions and ConditionReasons for the kcp SyncTarget object.

View Source
const (
	// InternalClusterDeletionTimestampAnnotationPrefix is the prefix of the annotation
	//
	//   deletion.internal.workload.kcp.io/<sync-target-name>
	//
	// on upstream resources storing the timestamp when the sync target resource
	// state was changed to "Delete". The syncer will see this timestamp as the deletion
	// timestamp of the object.
	//
	// The format is RFC3339.
	//
	// TODO(sttts): use sync-target-uid instead of sync-target-name.
	InternalClusterDeletionTimestampAnnotationPrefix = "deletion.internal.workload.kcp.io/"

	// ClusterFinalizerAnnotationPrefix is the prefix of the annotation
	//
	//   finalizers.workload.kcp.io/<sync-target-name>
	//
	// on upstream resources storing a comma-separated list of finalizer names that are set on
	// the sync target resource in the view of the syncer. This blocks the deletion of the
	// resource on that sync target. External (custom) controllers can set this annotation
	// create back-pressure on the resource.
	//
	// TODO(sttts): use sync-target-uid instead of sync-target-name.
	ClusterFinalizerAnnotationPrefix = "finalizers.workload.kcp.io/"

	// ClusterResourceStateLabelPrefix is the prefix of the label
	//
	//   state.workload.kcp.io/<sync-target-name>
	//
	// on upstream resources storing the state of the sync target syncer state machine.
	// The workload controllers will set this label and the syncer will react and drive the
	// life-cycle of the synced objects on the sync target.
	//
	// The format is a string, namely:
	// - "": the object is assigned, but the syncer will ignore the object. A coordination
	//       controller will have to set the value to "Sync" after initializion in order to
	//       start the sync process.
	// - "Sync": the object is assigned and the syncer will start the sync process.
	//
	// While being in "Sync" state, a deletion timestamp in deletion.internal.workload.kcp.io/<sync-target-name>
	// will signal the start of the deletion process of the object. During the deletion process
	// the object will stay in "Sync" state. The syncer will block deletion while
	// finalizers.workload.kcp.io/<sync-target-name> exists and is non-empty, and it
	// will eventually remove state.workload.kcp.io/<sync-target-name> after
	// the object has been deleted downstream.
	//
	// The workload controllers will consider the object deleted from the sync target when
	// the label is removed. They then set the placement state to "Unbound".
	ClusterResourceStateLabelPrefix = "state.workload.kcp.io/"

	// InternalSyncerViewAnnotationPrefix is the prefix of the annotation
	//
	//   diff.syncer.internal.kcp.io/<sync-target-key>
	//
	// on upstream resources storing the value of fields as they have been reported by the Syncer for the given SyncTarget,
	// so possibly different from the field value in the upstream resource itself, and overriding it for the given SyncTarget.
	//
	// The format is a Json object, whose keys are fields identifiers (for example "status" or "spec.clusterIP"),
	// and values are overriding field values.
	InternalSyncerViewAnnotationPrefix = "diff.syncer.internal.kcp.io/"

	// InternalClusterStatusAnnotationPrefix is the prefix of the annotation
	//
	//   experimental.status.workload.kcp.io/<sync-target-name>
	//
	// on upstream resources storing the status of the downstream resource per sync target.
	// Note that this is experimental and will disappear in the future without prior notice. It
	// is used temporarily in the case that a resource is scheduled to multiple sync targets.
	//
	// The format is JSON.
	InternalClusterStatusAnnotationPrefix = "experimental.status.workload.kcp.io/"

	// ClusterSpecDiffAnnotationPrefix is the prefix of the annotation
	//
	//   experimental.spec-diff.workload.kcp.io/<sync-target-name>
	//
	// on upstream resources storing the desired spec diffs to be applied to the resource when syncing
	// down to the <sync-target-name>. This feature requires the "Advanced Scheduling" feature gate
	// to be enabled.
	//
	// The patch will be applied to the resource Spec field of the resource, so the JSON root path is the
	// resource's Spec field.
	//
	// The format for the value of this annotation is: JSON Patch (https://tools.ietf.org/html/rfc6902).
	ClusterSpecDiffAnnotationPrefix = "experimental.spec-diff.workload.kcp.io/"

	// ExperimentalSummarizingRulesAnnotation
	//
	//   experimental.summarizing.workload.kcp.io
	//
	// on upstream resources storing the JSON-encoded summarizing rules for this instance of the resource.
	// The drives what fields should be overridden in the syncer view, and available for summarizing,
	// and how they should be managed.
	//
	// To express that only the "status" field should be summarized, and promoted to the upstream
	// resource when scheduled on only 1 SyncTarget, the annotation would be:
	//
	//    [{"fieldPath": "status", "promoteToUpstream": true}]
	//
	// The format for the value of this annotation is a JSON Array of objects with 2 fields:
	//   - fieldPath: defines that path (dot-separated) of a field that should be summarized
	//   - promoteToUpstream: defines whether this field should be promoted to upstream when the
	//     resource is scheduled to only one SyncTarget.
	ExperimentalSummarizingRulesAnnotation = "experimental.summarizing.workload.kcp.io"

	// InternalDownstreamClusterLabel is a label with the upstream cluster name applied on the downstream cluster
	// instead of state.workload.kcp.io/<sync-target-name> which is used upstream.
	InternalDownstreamClusterLabel = "internal.workload.kcp.io/cluster"

	// AnnotationSkipDefaultObjectCreation is the annotation key for an apiexport or apibinding indicating the other default resources
	// has been created already. If the created default resource is deleted, it will not be recreated.
	AnnotationSkipDefaultObjectCreation = "workload.kcp.io/skip-default-object-creation"

	// InternalSyncTargetPlacementAnnotationKey is an internal annotation key on placement API to mark the synctarget scheduled
	// from this placement. The value is a hash of the SyncTarget cluster name + SyncTarget name, generated with the ToSyncTargetKey(..) helper func.
	InternalSyncTargetPlacementAnnotationKey = "internal.workload.kcp.io/synctarget"

	// InternalSyncTargetKeyLabel is an internal label set on a SyncTarget resource that contains the full hash of the SyncTargetKey, generated with the ToSyncTargetKey(..)
	// helper func, this label is used for reverse lookups of a syncTargetKey to SyncTarget.
	InternalSyncTargetKeyLabel = "internal.workload.kcp.io/key"

	// ComputeAPIExportAnnotationKey is an annotation key set on an APIExport when it will be used for compute,
	// and its APIs are expected to be synced to a SyncTarget by the Syncer. The annotation will be continuously
	// synced from the APIExport to all the APIBindings bound to this APIExport. The workload scheduler will
	// check all the APIBindings with this annotation for scheduling purpose.
	ComputeAPIExportAnnotationKey = "extra.apis.kcp.io/compute.workload.kcp.io"

	// ExperimentalUpsyncDerivedResourcesAnnotationKey is an annotation that can be set on a syncable resource.
	// It defines the resource types of derived resources (i.e. resources created from the syncable resource
	// by some controller and that will not exist without it) intended to be upsynced to KCP.
	//
	// It contains a command-separated list of stringified GroupResource (<resource>.<group>).
	//
	// To allow upsyncing an Endpoints resource related to a synced service, the Service instance should be annotated with:
	//
	//   experimental.workload.kcp.io/upsync-derived-resources: endpoints
	//
	// For now, only endpoints can be upsynced on demand by the syncer with this mechanism,
	// but the list of such resources would increase in the future.
	//
	// Of course using this annotation also requires having, on the physical cluster, the appropriate logic
	// that will effectively label the derived resources for Upsync.
	// This logic should guard against upsyncing unexpected resources.
	// In addition, Upsyncing is limited to a limited, well-defined list of resource types on the KCP side,
	// so that simply adding this annotation on a synced resource will not be a security risk.
	//
	// This annotation is user-facing and would typically be set by the client creating the synced resource
	// in the KCP workspace, be it the end-user or a third-party controller.
	//
	// It is experimental since the provided user-experience is unsatisfactory,
	// and further work should be done to define such (up)syncing strategies at a more appropriate level
	// (SyncTarget, KCP namespace, KCP workspace ?).
	ExperimentalUpsyncDerivedResourcesAnnotationKey = "experimental.workload.kcp.io/upsync-derived-resources"

	// InternalWorkspaceURLAnnotationKey is an annotation dynamically added on resources exposed
	// by the Syncer Virtual Workspace to be synced by the Syncer.
	// It contains the external URL of the workspace the resource is part of.
	//
	// The Syncer doesn't have this information and needs it to correctly point some created downstream
	// resources back to the right KCP workspace.
	//
	//   internal.workload.kcp.io/workspace-url
	//
	InternalWorkspaceURLAnnotationKey = "internal.workload.kcp.io/workspace-url"
)
View Source
const ImportedAPISExportName = "imported-apis"

ImportedAPISExportName is singleton name of compute service exports in location workspace.

Variables

View Source
var (
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
	AddToScheme   = SchemeBuilder.AddToScheme
)
View Source
var SchemeGroupVersion = schema.GroupVersion{Group: workload.GroupName, Version: "v1alpha1"}

SchemeGroupVersion is group version used to register these objects.

Functions

func Kind

func Kind(kind string) schema.GroupKind

Kind takes an unqualified kind and returns back a Group qualified GroupKind.

func Resource

func Resource(resource string) schema.GroupResource

Resource takes an unqualified resource and returns a Group qualified GroupResource.

func ToSyncTargetKey

func ToSyncTargetKey(clusterName logicalcluster.Name, syncTargetName string) string

ToSyncTargetKey hashes the SyncTarget workspace and the SyncTarget name to a string that is used to identify in a unique way the synctarget in annotations/labels/finalizers.

Types

type ResourceCompatibleState

type ResourceCompatibleState string

type ResourceState

type ResourceState string
const (
	// ResourceStatePending is the initial state of a resource after placement onto
	// a sync target. Either some workload controller or some external coordination
	// controller will set this to "Sync" when the resource is ready to be synced.
	ResourceStatePending ResourceState = ""
	// ResourceStateSync is the state of a resource when it is synced to the sync target.
	// This includes the deletion process until the resource is deleted downstream and the
	// syncer removes the state.workload.kcp.io/<sync-target-name> label.
	ResourceStateSync ResourceState = "Sync"
	// ResourceStateUpsync is the state of a resource when it is synced up from the sync target.
	// Compared to Sync state, this state is exclusive, meaning that only one sync target can
	// be up-syncing a resource, and in addition, others sync targets cannot sync from this resource
	// because the up-syncer is owning both the spec and the status of that resource.
	ResourceStateUpsync ResourceState = "Upsync"
)

type ResourceToSync

type ResourceToSync struct {
	apisv1alpha1.GroupResource `json:","`

	// versions are the resource versions the syncer can choose to sync depending on
	// availability on the downstream cluster. Conversion to the storage version, if necessary,
	// will be done on the kcp side. The versions are ordered by precedence and the
	// first version compatible is preferred by syncer.
	// +kubebuilder:validation:MinItems=1
	// +required
	// +kubebuilder:validation:Required
	Versions []string `json:"versions"`

	// identityHash is the identity for a given APIExport that the APIResourceSchema belongs to.
	// The hash can be found on APIExport and APIResourceSchema's status.
	// It will be empty for core types.
	// +optional
	IdentityHash string `json:"identityHash"`

	// state indicate whether the resources schema is compatible to the SyncTarget. It must be updated
	// by syncer after checking the API compatibility on SyncTarget.
	// +kubebuilder:validation:Enum=Pending;Accepted;Incompatible
	// +kubebuilder:default=Pending
	// +optional
	State ResourceCompatibleState `json:"state,omitempty"`
}

func (*ResourceToSync) DeepCopy

func (in *ResourceToSync) DeepCopy() *ResourceToSync

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceToSync.

func (*ResourceToSync) DeepCopyInto

func (in *ResourceToSync) DeepCopyInto(out *ResourceToSync)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SyncTarget

type SyncTarget struct {
	metav1.TypeMeta `json:",inline"`
	// +optional
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Spec holds the desired state.
	// +optional
	Spec SyncTargetSpec `json:"spec,omitempty"`

	// Status communicates the observed state.
	// +optional
	Status SyncTargetStatus `json:"status,omitempty"`
}

SyncTarget describes a member cluster capable of running workloads.

+crd +genclient +genclient:nonNamespaced +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +kubebuilder:subresource:status +kubebuilder:resource:scope=Cluster,categories=kcp +kubebuilder:printcolumn:name="Location",type="string",JSONPath=`.metadata.name`,priority=1 +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status`,priority=2 +kubebuilder:printcolumn:name="Synced API resources",type="string",JSONPath=`.status.syncedResources`,priority=3 +kubebuilder:printcolumn:name="Key",type="string",JSONPath=`.metadata.labels['internal\.workload\.kcp\.dev/key']`,priority=4 +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

func (*SyncTarget) DeepCopy

func (in *SyncTarget) DeepCopy() *SyncTarget

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncTarget.

func (*SyncTarget) DeepCopyInto

func (in *SyncTarget) DeepCopyInto(out *SyncTarget)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*SyncTarget) DeepCopyObject

func (in *SyncTarget) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*SyncTarget) GetConditions

func (in *SyncTarget) GetConditions() conditionsv1alpha1.Conditions

func (*SyncTarget) SetConditions

func (in *SyncTarget) SetConditions(conditions conditionsv1alpha1.Conditions)

type SyncTargetList

type SyncTargetList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata"`

	Items []SyncTarget `json:"items"`
}

SyncTargetList is a list of SyncTarget resources

+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*SyncTargetList) DeepCopy

func (in *SyncTargetList) DeepCopy() *SyncTargetList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncTargetList.

func (*SyncTargetList) DeepCopyInto

func (in *SyncTargetList) DeepCopyInto(out *SyncTargetList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*SyncTargetList) DeepCopyObject

func (in *SyncTargetList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type SyncTargetSpec

type SyncTargetSpec struct {
	// Unschedulable controls cluster schedulability of new workloads. By
	// default, cluster is schedulable.
	// +optional
	// +kubebuilder:default=false
	Unschedulable bool `json:"unschedulable"`

	// EvictAfter controls cluster schedulability of new and existing workloads.
	// After the EvictAfter time, any workload scheduled to the cluster
	// will be unassigned from the cluster.
	// By default, workloads scheduled to the cluster are not evicted.
	EvictAfter *metav1.Time `json:"evictAfter,omitempty"`

	// SupportedAPIExports defines a set of APIExports supposed to be supported by this SyncTarget. The SyncTarget
	// will be selected to deploy the workload only when the resource schema on the SyncTarget is compatible
	// with the resource schema included in the exports.
	SupportedAPIExports []tenancyv1alpha1.APIExportReference `json:"supportedAPIExports,omitempty"`

	// Cells is a set of labels to identify the cells the SyncTarget belongs to. SyncTargets with the same cells run as
	// they are in the same physical cluster. Each key/value pair in the cells should be added and updated by service providers
	// (i.e. a network provider updates one key/value, while the storage provider updates another.)
	Cells map[string]string `json:"cells,omitempty"`
}

SyncTargetSpec holds the desired state of the SyncTarget (from the client).

func (*SyncTargetSpec) DeepCopy

func (in *SyncTargetSpec) DeepCopy() *SyncTargetSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncTargetSpec.

func (*SyncTargetSpec) DeepCopyInto

func (in *SyncTargetSpec) DeepCopyInto(out *SyncTargetSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SyncTargetStatus

type SyncTargetStatus struct {

	// Allocatable represents the resources that are available for scheduling.
	// +optional
	Allocatable *corev1.ResourceList `json:"allocatable,omitempty"`

	// Capacity represents the total resources of the cluster.
	// +optional
	Capacity *corev1.ResourceList `json:"capacity,omitempty"`

	// Current processing state of the SyncTarget.
	// +optional
	Conditions conditionsv1alpha1.Conditions `json:"conditions,omitempty"`

	// SyncedResources represents the resources that the syncer of the SyncTarget can sync. It MUST be
	// updated by kcp server.
	// +optional
	SyncedResources []ResourceToSync `json:"syncedResources,omitempty"`

	// A timestamp indicating when the syncer last reported status.
	// +optional
	LastSyncerHeartbeatTime *metav1.Time `json:"lastSyncerHeartbeatTime,omitempty"`

	// VirtualWorkspaces contains all virtual workspace URLs.
	// +optional
	VirtualWorkspaces []VirtualWorkspace `json:"virtualWorkspaces,omitempty"`

	// TunnelWorkspaces contains all URLs (one per shard) that point to the SyncTarget
	// workspace in order to setup the tunneler.
	// +optional
	TunnelWorkspaces []TunnelWorkspace `json:"tunnelWorkspaces,omitempty"`
}

SyncTargetStatus communicates the observed state of the SyncTarget (from the controller).

func (*SyncTargetStatus) DeepCopy

func (in *SyncTargetStatus) DeepCopy() *SyncTargetStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncTargetStatus.

func (*SyncTargetStatus) DeepCopyInto

func (in *SyncTargetStatus) DeepCopyInto(out *SyncTargetStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type TunnelWorkspace

type TunnelWorkspace struct {
	// url is the URL the Syncer should use to connect
	// to the Syncer tunnel for a given shard.
	//
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:format:URL
	// +required
	URL string `json:"url"`
}

func (*TunnelWorkspace) DeepCopy

func (in *TunnelWorkspace) DeepCopy() *TunnelWorkspace

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TunnelWorkspace.

func (*TunnelWorkspace) DeepCopyInto

func (in *TunnelWorkspace) DeepCopyInto(out *TunnelWorkspace)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type VirtualWorkspace

type VirtualWorkspace struct {
	// SyncerURL is the URL of the syncer virtual workspace.
	//
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:format:URL
	// +required
	SyncerURL string `json:"syncerURL"`

	// UpsyncerURL is the URL of the upsyncer virtual workspace.
	//
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:format:URL
	// +required
	UpsyncerURL string `json:"upsyncerURL"`
}

func (*VirtualWorkspace) DeepCopy

func (in *VirtualWorkspace) DeepCopy() *VirtualWorkspace

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualWorkspace.

func (*VirtualWorkspace) DeepCopyInto

func (in *VirtualWorkspace) DeepCopyInto(out *VirtualWorkspace)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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