v1alpha1

package
v1.5.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package v1alpha1 contains API Schema definitions for the tenant v1alpha1 API group. +kubebuilder:object:generate=true +groupName=tenant.otterscale.io

Index

Constants

This section is empty.

Variables

View Source
var (
	// SchemeGroupVersion is group version used to register these objects.
	// This name is used by applyconfiguration generators (e.g. controller-gen).
	SchemeGroupVersion = schema.GroupVersion{Group: "tenant.otterscale.io", Version: "v1alpha1"}

	// GroupVersion is an alias for SchemeGroupVersion, for backward compatibility.
	GroupVersion = SchemeGroupVersion

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
	SchemeBuilder = runtime.NewSchemeBuilder(func(scheme *runtime.Scheme) error {
		metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
		return nil
	})

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

Functions

This section is empty.

Types

type MemberRole

type MemberRole string

MemberRole defines the role of a member in the workspace. It determines the RBAC permissions granted within the target namespace.

Each role name is also the name of the ClusterRole bound in the workspace namespace, so adding a role means updating three places that cannot be derived from these constants: the Enum marker below, the controller's +kubebuilder:rbac clusterroles/bind resourceNames, and harborRoleID's mapping onto Harbor project roles. +kubebuilder:validation:Enum=admin;edit;view +enum

const (
	// MemberRoleAdmin has full control over the workspace resources.
	MemberRoleAdmin MemberRole = "admin"
	// MemberRoleEdit can create/update application resources but cannot modify role bindings.
	MemberRoleEdit MemberRole = "edit"
	// MemberRoleView has read-only access to resources.
	MemberRoleView MemberRole = "view"
)

func AllMemberRoles

func AllMemberRoles() []MemberRole

AllMemberRoles returns every MemberRole, ordered from most to least privileged. Callers that need to act on all roles iterate this rather than restating the list, so the enumeration lives in one place.

type NetworkIsolationSpec

type NetworkIsolationSpec struct {
	// Enabled toggles the enforcement of network isolation.
	// If true, default deny-all ingress rules are applied except for allowed namespaces.
	// +optional
	Enabled bool `json:"enabled"`

	// AllowedNamespaces specifies a list of external namespaces permitted to access this workspace
	// when isolation is enabled. Essential system namespaces (e.g., 'istio-system', 'monitoring')
	// should be included here if required.
	// +listType=set
	// +kubebuilder:validation:MaxItems=64
	// +kubebuilder:validation:items:MinLength=1
	// +kubebuilder:validation:items:MaxLength=63
	// +kubebuilder:validation:items:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?)$`
	// +optional
	AllowedNamespaces []string `json:"allowedNamespaces,omitempty"`
}

NetworkIsolationSpec configures network policies for the workspace. It is enforced with a standard Kubernetes NetworkPolicy restricting ingress. +kubebuilder:validation:XValidation:rule="!has(self.allowedNamespaces) || size(self.allowedNamespaces) == 0 || self.enabled",message="allowedNamespaces can only be set when network isolation is enabled"

func (*NetworkIsolationSpec) DeepCopy

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

func (*NetworkIsolationSpec) DeepCopyInto

func (in *NetworkIsolationSpec) DeepCopyInto(out *NetworkIsolationSpec)

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

type ResourceReference

type ResourceReference struct {
	// Name is the name of the referenced resource.
	// +required
	Name string `json:"name"`

	// Namespace is the namespace of the referenced resource.
	// Empty for cluster-scoped resources.
	// +optional
	Namespace string `json:"namespace,omitempty"`
}

ResourceReference is a lightweight reference to a Kubernetes resource managed by the operator.

func (*ResourceReference) DeepCopy

func (in *ResourceReference) DeepCopy() *ResourceReference

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

func (*ResourceReference) DeepCopyInto

func (in *ResourceReference) DeepCopyInto(out *ResourceReference)

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

type Workspace

type Workspace struct {
	metav1.TypeMeta `json:",inline"`

	// Standard object's metadata.
	// +optional
	metav1.ObjectMeta `json:"metadata,omitzero"`

	// Spec defines the desired behavior of the Workspace.
	// +required
	Spec WorkspaceSpec `json:"spec"`

	// Status represents the current information about the Workspace.
	// +optional
	Status WorkspaceStatus `json:"status,omitzero"`
}

Workspace is the Schema for the workspaces API. A Workspace represents a logical isolation unit (Namespace) with associated policies, quotas, and member access.

func (*Workspace) DeepCopy

func (in *Workspace) DeepCopy() *Workspace

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

func (*Workspace) DeepCopyInto

func (in *Workspace) DeepCopyInto(out *Workspace)

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

func (*Workspace) DeepCopyObject

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

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

type WorkspaceList

type WorkspaceList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitzero"`
	Items           []Workspace `json:"items"`
}

WorkspaceList contains a list of Workspace resources.

func (*WorkspaceList) DeepCopy

func (in *WorkspaceList) DeepCopy() *WorkspaceList

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

func (*WorkspaceList) DeepCopyInto

func (in *WorkspaceList) DeepCopyInto(out *WorkspaceList)

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

func (*WorkspaceList) DeepCopyObject

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

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

type WorkspaceMember

type WorkspaceMember struct {
	// Role defines the authorization level (Admin, Edit, View).
	// +required
	Role MemberRole `json:"role"`

	// Subject is the unique identifier of the member (e.g., OIDC subject or username).
	// This identifier maps directly to the Kubernetes RBAC Subject.
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:MaxLength=253
	// +required
	Subject string `json:"subject"`

	// Username is the member's Harbor registry username.
	// When set, this value is used as the Harbor project member identity
	// instead of Subject.
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:MaxLength=253
	// +optional
	Username *string `json:"username,omitempty"`

	// Name is the human-readable display name of the member.
	// +optional
	Name *string `json:"name,omitempty"`

	// ServiceAccount indicates whether this member is a service account
	// rather than a human user.
	// +optional
	ServiceAccount bool `json:"serviceAccount,omitempty"`
}

WorkspaceMember defines a single member entity associated with a workspace.

func (*WorkspaceMember) DeepCopy

func (in *WorkspaceMember) DeepCopy() *WorkspaceMember

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

func (*WorkspaceMember) DeepCopyInto

func (in *WorkspaceMember) DeepCopyInto(out *WorkspaceMember)

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

type WorkspaceSpec

type WorkspaceSpec struct {
	// Namespace is the name of the Kubernetes Namespace to be created for this workspace.
	// It must be unique across all Workspaces.
	// When omitted, a 6-character name is auto-generated by the mutating webhook.
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern=`^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable"
	// +kubebuilder:validation:XValidation:rule="!(self in ['default','kube-system','kube-public','kube-node-lease','otterscale-system'])",message="namespace is reserved and cannot be used for a workspace"
	// +optional
	Namespace string `json:"namespace,omitempty"`

	// Members is the list of members granted access to this workspace.
	// +listType=atomic
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:validation:XValidation:rule="self.exists(u, u.role == 'admin')",message="at least one workspace member must have role 'admin'"
	// +required
	Members []WorkspaceMember `json:"members"`

	// ResourceQuota defines the compute resource constraints (CPU, Memory, etc.) applied to the underlying namespace.
	// +optional
	ResourceQuota *corev1.ResourceQuotaSpec `json:"resourceQuota,omitempty"`

	// LimitRange defines the default resource limits and requests for pods in the workspace.
	// +optional
	LimitRange *corev1.LimitRangeSpec `json:"limitRange,omitempty"`

	// NetworkIsolation defines the ingress traffic rules for the workspace.
	// +optional
	NetworkIsolation NetworkIsolationSpec `json:"networkIsolation,omitzero"`
}

WorkspaceSpec defines the desired state of the Workspace. It includes member management, resource constraints, and network security settings.

func (*WorkspaceSpec) DeepCopy

func (in *WorkspaceSpec) DeepCopy() *WorkspaceSpec

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

func (*WorkspaceSpec) DeepCopyInto

func (in *WorkspaceSpec) DeepCopyInto(out *WorkspaceSpec)

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

type WorkspaceStatus

type WorkspaceStatus struct {
	// ObservedGeneration is the most recent generation observed by the controller.
	// It corresponds to the Workspace's generation, which is updated on mutation by the API Server.
	// This allows clients to determine whether the controller has processed the latest spec changes.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	// NamespaceRef is a reference to the Namespace managed by this Workspace.
	// +optional
	NamespaceRef *ResourceReference `json:"namespaceRef,omitempty"`

	// ResourceQuotaRef is a reference to the ResourceQuota managed by this Workspace.
	// +optional
	ResourceQuotaRef *ResourceReference `json:"resourceQuotaRef,omitempty"`

	// LimitRangeRef is a reference to the LimitRange managed by this Workspace.
	// +optional
	LimitRangeRef *ResourceReference `json:"limitRangeRef,omitempty"`

	// ConfigMapRef is a reference to the ConfigMap managed by this Workspace.
	// +optional
	ConfigMapRef *ResourceReference `json:"configMapRef,omitempty"`

	// RoleBindingRefs contains references to all RBAC RoleBindings created for the workspace members.
	// +listType=map
	// +listMapKey=name
	// +optional
	RoleBindingRefs []ResourceReference `json:"roleBindingRefs,omitempty"`

	// NetworkPolicyRef is a reference to the NetworkPolicy enforcing network isolation.
	// +optional
	NetworkPolicyRef *ResourceReference `json:"networkPolicyRef,omitempty"`

	// ImagePullSecretRef is a reference to the docker-registry Secret
	// containing Harbor robot credentials for image pull/push.
	// +optional
	ImagePullSecretRef *ResourceReference `json:"imagePullSecretRef,omitempty"`

	// HelmRepositoryRef is a reference to the FluxCD HelmRepository for this workspace's Harbor OCI registry.
	// +optional
	HelmRepositoryRef *ResourceReference `json:"helmRepositoryRef,omitempty"`

	// Conditions store the status conditions of the Workspace (e.g., Ready, Failed).
	// +listType=map
	// +listMapKey=type
	// +optional
	Conditions []metav1.Condition `json:"conditions,omitempty"`
}

WorkspaceStatus defines the observed state of the Workspace. It contains references to the actual Kubernetes resources created by the operator.

func (*WorkspaceStatus) DeepCopy

func (in *WorkspaceStatus) DeepCopy() *WorkspaceStatus

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

func (*WorkspaceStatus) DeepCopyInto

func (in *WorkspaceStatus) DeepCopyInto(out *WorkspaceStatus)

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