v1alpha2

package
v0.0.0-...-44dad58 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 5 Imported by: 8

Documentation

Overview

Package v1 contains API Schema definitions for the hnc v1 API group +kubebuilder:object:generate=true +groupName=hnc.x-k8s.io

Index

Constants

View Source
const (
	Singleton               = "hierarchy"
	HierarchyConfigurations = "hierarchyconfigurations"
)

Constants for types and well-known names

View Source
const (
	MetaGroup                 = "hnc.x-k8s.io"
	LabelInheritedFrom        = MetaGroup + "/inherited-from"
	FinalizerHasSubnamespace  = MetaGroup + "/hasSubnamespace"
	LabelTreeDepthSuffix      = ".tree." + MetaGroup + "/depth"
	AnnotationManagedBy       = MetaGroup + "/managed-by"
	AnnotationPropagatePrefix = "propagate." + MetaGroup

	AnnotationSelector     = AnnotationPropagatePrefix + "/select"
	AnnotationTreeSelector = AnnotationPropagatePrefix + "/treeSelect"
	AnnotationNoneSelector = AnnotationPropagatePrefix + "/none"

	// LabelManagedByStandard will eventually replace our own managed-by annotation (we didn't know
	// about this standard label when we invented our own).
	LabelManagedByApps = "app.kubernetes.io/managed-by"

	// LabelExcludedNamespace is the label added by users on the namespaces that
	// should be excluded from our validators, e.g. "kube-system".
	LabelExcludedNamespace = MetaGroup + "/excluded-namespace"
)

Constants for labels and annotations

View Source
const (
	// Condition types.
	ConditionActivitiesHalted string = "ActivitiesHalted"
	ConditionBadConfiguration string = "BadConfiguration"

	// Condition reasons.
	ReasonAncestor      string = "AncestorHaltActivities"
	ReasonDeletingCRD   string = "DeletingCRD"
	ReasonInCycle       string = "InCycle"
	ReasonParentMissing string = "ParentMissing"
	ReasonIllegalParent string = "IllegalParent"
	ReasonAnchorMissing string = "SubnamespaceAnchorMissing"
)
View Source
const (
	// EventCannotPropagate is for events when a namespace contains an object that
	// couldn't be propagated *out* of the namespace, to one or more of its
	// descendants. If the object couldn't be propagated to *any* descendants - for
	// example, because it has a finalizer on it (HNC can't propagate objects with
	// finalizers), the error message will point to the object in this namespace.
	// Otherwise, if it couldn't be propagated to *some* descendant, the error
	// message will point to the descendant.
	EventCannotPropagate string = "CannotPropagateObject"
	// EventCannotUpdate is for events when a namespace has an object that couldn't
	// be propagated *into* this namespace - that is, it couldn't be created in
	// the first place, or it couldn't be updated. The error message will point to
	// the source namespace.
	EventCannotUpdate string = "CannotUpdateObject"
	// EventCannotGetSelector is for events when an object has annotations that cannot be
	// parsed into a valid selector
	EventCannotParseSelector string = "CannotParseSelector"
)
View Source
const (
	HNCConfigSingleton  = "config"
	HNCConfigSingletons = "hncconfigurations"
	RBACGroup           = "rbac.authorization.k8s.io"
	RoleResource        = "roles"
	RoleKind            = "Role"
	RoleBindingResource = "rolebindings"
	RoleBindingKind     = "RoleBinding"
)

Constants for resources and well-known names.

View Source
const (
	// Condition types.
	ConditionBadTypeConfiguration = "BadConfiguration"
	ConditionOutOfSync            = "OutOfSync"
	// NamespaceCondition is set if there are namespace conditions, which are set
	// in the HierarchyConfiguration objects. The condition reasons would be the
	// condition types in HierarchyConfiguration, e.g. "ActivitiesHalted".
	ConditionNamespace = "NamespaceCondition"

	// Condition reasons for BadConfiguration
	ReasonMultipleConfigsForType = "MultipleConfigurationsForType"
	ReasonResourceNotFound       = "ResourceNotFound"

	// Condition reason for OutOfSync, e.g. errors when creating a reconciler.
	ReasonUnknown = "Unknown"
)
View Source
const (
	Anchors          = "subnamespaceanchors"
	AnchorKind       = "SubnamespaceAnchor"
	AnchorAPIVersion = MetaGroup + "/v1alpha2"
	SubnamespaceOf   = MetaGroup + "/subnamespace-of"
)

Constants for the subnamespace anchor resource type and namespace annotation.

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	GroupVersion = schema.GroupVersion{Group: "hnc.x-k8s.io", Version: "v1alpha2"}

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

	// AddToScheme adds the types in this group-version to the given scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

AllConditions have all the conditions by type and reason. Please keep this list in alphabetic order. This is specifically used to clear (set to 0) conditions in the metrics.

View Source
var EnforcedTypes = []ResourceSpec{
	{Group: RBACGroup, Resource: RoleResource, Mode: Propagate},
	{Group: RBACGroup, Resource: RoleBindingResource, Mode: Propagate},
}

EnforcedTypes are the types enforced by HNC that they should not show up in the spec and only in the status. Any configurations of the enforced types in the spec would cause 'MultipleConfigurationsForType' condition.

Functions

func IsEnforcedType

func IsEnforcedType(grm ResourceSpec) bool

IsEnforcedType returns true if configuration is on an enforced type.

Types

type Condition

type Condition struct {
	// type of condition in CamelCase or in foo.example.com/CamelCase.
	// ---
	// Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
	// useful (see .node.status.conditions), the ability to deconflict is important.
	// The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`
	// +kubebuilder:validation:MaxLength=316
	Type string `json:"type" protobuf:"bytes,1,opt,name=type"`
	// status of the condition, one of True, False, Unknown.
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Enum=True;False;Unknown
	Status metav1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"`
	// observedGeneration represents the .metadata.generation that the condition was set based upon.
	// For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
	// with respect to the current state of the instance.
	// +optional
	// +kubebuilder:validation:Minimum=0
	ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"`
	// lastTransitionTime is the last time the condition transitioned from one status to another.
	// This should be when the underlying condition changed.  If that is not known, then using the time when the API field changed is acceptable.
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Type=string
	// +kubebuilder:validation:Format=date-time
	LastTransitionTime metav1.Time `json:"lastTransitionTime" protobuf:"bytes,4,opt,name=lastTransitionTime"`
	// reason contains a programmatic identifier indicating the reason for the condition's last transition.
	// Producers of specific condition types may define expected values and meanings for this field,
	// and whether the values are considered a guaranteed API.
	// The value should be a CamelCase string.
	// This field may not be empty.
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=1024
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:Pattern=`^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$`
	Reason string `json:"reason" protobuf:"bytes,5,opt,name=reason"`
	// message is a human readable message indicating details about the transition.
	// This may be an empty string.
	// +required
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=32768
	Message string `json:"message" protobuf:"bytes,6,opt,name=message"`
}

Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example,

type FooStatus struct{
    // Represents the observations of a foo's current state.
    // Known .status.conditions.type are: "Available", "Progressing", and "Degraded"
    // +patchMergeKey=type
    // +patchStrategy=merge
    // +listType=map
    // +listMapKey=type
    Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`

    // other fields
}

func NewCondition

func NewCondition(tp, reason, msg string) Condition

NewCondition fills some required field with default values for schema validation, e.g. Status and LastTransitionTime.

func (*Condition) DeepCopy

func (in *Condition) DeepCopy() *Condition

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

func (*Condition) DeepCopyInto

func (in *Condition) DeepCopyInto(out *Condition)

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

func (Condition) String

func (c Condition) String() string

type HNCConfiguration

type HNCConfiguration struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   HNCConfigurationSpec   `json:"spec,omitempty"`
	Status HNCConfigurationStatus `json:"status,omitempty"`
}

HNCConfiguration is a cluster-wide configuration for HNC as a whole. See details in http://bit.ly/hnc-type-configuration

func (*HNCConfiguration) DeepCopy

func (in *HNCConfiguration) DeepCopy() *HNCConfiguration

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

func (*HNCConfiguration) DeepCopyInto

func (in *HNCConfiguration) DeepCopyInto(out *HNCConfiguration)

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

func (*HNCConfiguration) DeepCopyObject

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

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

type HNCConfigurationList

type HNCConfigurationList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []HNCConfiguration `json:"items"`
}

HNCConfigurationList contains a list of HNCConfiguration.

func (*HNCConfigurationList) DeepCopy

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

func (*HNCConfigurationList) DeepCopyInto

func (in *HNCConfigurationList) DeepCopyInto(out *HNCConfigurationList)

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

func (*HNCConfigurationList) DeepCopyObject

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

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

type HNCConfigurationSpec

type HNCConfigurationSpec struct {
	// Resources defines the cluster-wide settings for resource synchronization.
	// Note that 'roles' and 'rolebindings' are pre-configured by HNC with
	// 'Propagate' mode and are omitted in the spec. Any configuration of 'roles'
	// or 'rolebindings' are not allowed. To learn more, see
	// https://github.com/kubernetes-sigs/multi-tenancy/blob/master/incubator/hnc/docs/user-guide/how-to.md#admin-types
	Resources []ResourceSpec `json:"resources,omitempty"`
}

HNCConfigurationSpec defines the desired state of HNC configuration.

func (*HNCConfigurationSpec) DeepCopy

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

func (*HNCConfigurationSpec) DeepCopyInto

func (in *HNCConfigurationSpec) DeepCopyInto(out *HNCConfigurationSpec)

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

type HNCConfigurationStatus

type HNCConfigurationStatus struct {
	// Resources indicates the observed synchronization states of the resources.
	Resources []ResourceStatus `json:"resources,omitempty"`

	// Conditions describes the errors, if any. If there are any conditions with
	// "ActivitiesHalted" reason, this means that HNC cannot function in the
	// affected namespaces. The HierarchyConfiguration object in each of the
	// affected namespaces will have more information. To learn more about
	// conditions, see https://github.com/kubernetes-sigs/multi-tenancy/blob/master/incubator/hnc/docs/user-guide/concepts.md#admin-conditions.
	Conditions []Condition `json:"conditions,omitempty"`
}

HNCConfigurationStatus defines the observed state of HNC configuration.

func (*HNCConfigurationStatus) DeepCopy

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

func (*HNCConfigurationStatus) DeepCopyInto

func (in *HNCConfigurationStatus) DeepCopyInto(out *HNCConfigurationStatus)

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

type HierarchyConfiguration

type HierarchyConfiguration struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   HierarchyConfigurationSpec   `json:"spec,omitempty"`
	Status HierarchyConfigurationStatus `json:"status,omitempty"`
}

Hierarchy is the Schema for the hierarchies API

func (*HierarchyConfiguration) DeepCopy

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

func (*HierarchyConfiguration) DeepCopyInto

func (in *HierarchyConfiguration) DeepCopyInto(out *HierarchyConfiguration)

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

func (*HierarchyConfiguration) DeepCopyObject

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

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

type HierarchyConfigurationList

type HierarchyConfigurationList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []HierarchyConfiguration `json:"items"`
}

HierarchyList contains a list of Hierarchy

func (*HierarchyConfigurationList) DeepCopy

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

func (*HierarchyConfigurationList) DeepCopyInto

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

func (*HierarchyConfigurationList) DeepCopyObject

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

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

type HierarchyConfigurationSpec

type HierarchyConfigurationSpec struct {

	// Parent indicates the parent of this namespace, if any.
	Parent string `json:"parent,omitempty"`

	// AllowCascadingDeletion indicates if the subnamespaces of this namespace are
	// allowed to cascading delete.
	AllowCascadingDeletion bool `json:"allowCascadingDeletion,omitempty"`
}

HierarchySpec defines the desired state of Hierarchy

func (*HierarchyConfigurationSpec) DeepCopy

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

func (*HierarchyConfigurationSpec) DeepCopyInto

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

type HierarchyConfigurationStatus

type HierarchyConfigurationStatus struct {

	// Children indicates the direct children of this namespace, if any.
	Children []string `json:"children,omitempty"`

	// Conditions describes the errors, if any.
	Conditions []Condition `json:"conditions,omitempty"`
}

HierarchyStatus defines the observed state of Hierarchy

func (*HierarchyConfigurationStatus) DeepCopy

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

func (*HierarchyConfigurationStatus) DeepCopyInto

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

type ResourceSpec

type ResourceSpec struct {
	// Group of the resource defined below. This is used to unambiguously identify
	// the resource. It may be omitted for core resources (e.g. "secrets").
	Group string `json:"group,omitempty"`
	// Resource to be configured.
	Resource string `json:"resource"`
	// Synchronization mode of the kind. If the field is empty, it will be treated
	// as "Propagate".
	// +optional
	// +kubebuilder:validation:Enum=Propagate;Ignore;Remove
	Mode SynchronizationMode `json:"mode,omitempty"`
}

ResourceSpec defines the desired synchronization state of a specific resource.

func (*ResourceSpec) DeepCopy

func (in *ResourceSpec) DeepCopy() *ResourceSpec

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

func (*ResourceSpec) DeepCopyInto

func (in *ResourceSpec) DeepCopyInto(out *ResourceSpec)

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

type ResourceStatus

type ResourceStatus struct {
	// The API group of the resource being synchronized.
	Group string `json:"group"`

	// The API version used by HNC when propagating this resource.
	Version string `json:"version"`

	// The resource being synchronized.
	Resource string `json:"resource"`

	// Mode describes the synchronization mode of the kind. Typically, it will be the same as the mode
	// in the spec, except when the reconciler has fallen behind or for resources with an enforced
	// default synchronization mode, such as RBAC objects.
	Mode SynchronizationMode `json:"mode,omitempty"`

	// Tracks the number of objects that are being propagated to descendant namespaces. The propagated
	// objects are created by HNC.
	// +kubebuilder:validation:Minimum=0
	// +optional
	NumPropagatedObjects *int `json:"numPropagatedObjects,omitempty"`

	// Tracks the number of objects that are created by users.
	// +kubebuilder:validation:Minimum=0
	// +optional
	NumSourceObjects *int `json:"numSourceObjects,omitempty"`
}

ResourceStatus defines the actual synchronization state of a specific resource.

func (*ResourceStatus) DeepCopy

func (in *ResourceStatus) DeepCopy() *ResourceStatus

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

func (*ResourceStatus) DeepCopyInto

func (in *ResourceStatus) DeepCopyInto(out *ResourceStatus)

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

type SubnamespaceAnchor

type SubnamespaceAnchor struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Status SubnamespaceAnchorStatus `json:"status,omitempty"`
}

SubnamespaceAnchor is the Schema for the subnamespace API. See details at http://bit.ly/hnc-self-serve-ux.

func (*SubnamespaceAnchor) DeepCopy

func (in *SubnamespaceAnchor) DeepCopy() *SubnamespaceAnchor

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

func (*SubnamespaceAnchor) DeepCopyInto

func (in *SubnamespaceAnchor) DeepCopyInto(out *SubnamespaceAnchor)

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

func (*SubnamespaceAnchor) DeepCopyObject

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

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

type SubnamespaceAnchorList

type SubnamespaceAnchorList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []SubnamespaceAnchor `json:"items"`
}

SubnamespaceAnchorList contains a list of SubnamespaceAnchor.

func (*SubnamespaceAnchorList) DeepCopy

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

func (*SubnamespaceAnchorList) DeepCopyInto

func (in *SubnamespaceAnchorList) DeepCopyInto(out *SubnamespaceAnchorList)

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

func (*SubnamespaceAnchorList) DeepCopyObject

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

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

type SubnamespaceAnchorState

type SubnamespaceAnchorState string

SubnamespaceAnchorState describes the state of the subnamespace. The state could be "Missing", "Ok", "Conflict" or "Forbidden". The definitions will be described below.

const (
	Missing   SubnamespaceAnchorState = "Missing"
	Ok        SubnamespaceAnchorState = "Ok"
	Conflict  SubnamespaceAnchorState = "Conflict"
	Forbidden SubnamespaceAnchorState = "Forbidden"
)

Anchor states, which are documented in the comment to SubnamespaceAnchorStatus.State.

type SubnamespaceAnchorStatus

type SubnamespaceAnchorStatus struct {
	// Describes the state of the subnamespace anchor.
	//
	// Currently, the supported values are:
	//
	// - "Missing": the subnamespace has not been created yet. This should be the default state when
	// the anchor is just created.
	//
	// - "Ok": the subnamespace exists. This is the only good state of the anchor.
	//
	// - "Conflict": a namespace of the same name already exists. The admission controller will
	// attempt to prevent this.
	//
	// - "Forbidden": the anchor was created in a namespace that doesn't allow children, such as
	// kube-system or hnc-system. The admission controller will attempt to prevent this.
	State SubnamespaceAnchorState `json:"status,omitempty"`
}

SubnamespaceAnchorStatus defines the observed state of SubnamespaceAnchor.

func (*SubnamespaceAnchorStatus) DeepCopy

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

func (*SubnamespaceAnchorStatus) DeepCopyInto

func (in *SubnamespaceAnchorStatus) DeepCopyInto(out *SubnamespaceAnchorStatus)

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

type SynchronizationMode

type SynchronizationMode string

SynchronizationMode describes propagation mode of objects of the same kind. The only three modes currently supported are "Propagate", "Ignore", and "Remove". See detailed definition below. An unsupported mode will be treated as "ignore".

const (
	// Propagate objects from ancestors to descendants and deletes obsolete descendants.
	Propagate SynchronizationMode = "Propagate"

	// Ignore the modification of this resource. New or changed objects will not be propagated, and
	// obsolete objects will not be deleted. The inheritedFrom label is not removed.  Any unknown mode
	// is treated as Ignore.
	Ignore SynchronizationMode = "Ignore"

	// Remove all existing propagated copies.
	Remove SynchronizationMode = "Remove"
)

Jump to

Keyboard shortcuts

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