rules

package
v0.13.10 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetadataKeyExpression added in v0.13.10

func MetadataKeyExpression(selector string) runtime.ExpressionRegex

MetadataKeyExpression converts a metadata key selector into the regular expression used by admission validation and runtime matching. Asterisks are convenient wildcards, while the rest of the selector retains regexp syntax.

Types

type ActionType

type ActionType string

+kubebuilder:validation:Enum=allow;deny;audit

const (
	ActionTypeAllow ActionType = "allow"
	ActionTypeDeny  ActionType = "deny"
	ActionTypeAudit ActionType = "audit"
)

func (ActionType) OrDefault

func (a ActionType) OrDefault() ActionType

type Audience added in v0.13.10

type Audience struct {
	// +kubebuilder:validation:Enum=User;Group;ServiceAccount;Custom
	Kind AudienceKind `json:"kind"`
	Name string       `json:"name"`
}

+kubebuilder:object:generate=true

func (*Audience) DeepCopy added in v0.13.10

func (in *Audience) DeepCopy() *Audience

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

func (*Audience) DeepCopyInto added in v0.13.10

func (in *Audience) DeepCopyInto(out *Audience)

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

type AudienceKind added in v0.13.10

type AudienceKind string
const (
	AudienceKindUser           AudienceKind = "User"
	AudienceKindGroup          AudienceKind = "Group"
	AudienceKindServiceAccount AudienceKind = "ServiceAccount"
	AudienceKindCustom         AudienceKind = "Custom"
)

type CustomAudience added in v0.13.10

type CustomAudience string
const (
	CustomAudienceCapsuleUser   CustomAudience = "CapsuleUser"
	CustomAudienceAdministrator CustomAudience = "Administrator"
	CustomAudienceTenantOwner   CustomAudience = "TenantOwner"
	CustomAudienceController    CustomAudience = "Controller"
)

type ImagePullPolicySpec

type ImagePullPolicySpec string

+kubebuilder:validation:Enum=Always;Never;IfNotPresent

func (ImagePullPolicySpec) String

func (i ImagePullPolicySpec) String() string

type IngressType added in v0.13.10

type IngressType string

+kubebuilder:validation:Enum=Ingress;Route;ListenerSet;HTTPRoute;Gateway;TLSRoute;GRPCRoute

const (
	IngressTypeIngress     IngressType = "Ingress"
	IngressTypeRoute       IngressType = "Route"
	IngressTypeListenerSet IngressType = "ListenerSet"
	IngressTypeHTTPRoute   IngressType = "HTTPRoute"
	IngressTypeGateway     IngressType = "Gateway"
	IngressTypeTLSRoute    IngressType = "TLSRoute"
	IngressTypeGRPCRoute   IngressType = "GRPCRoute"
)

type MetadataRule added in v0.13.8

type MetadataRule struct {
	runtime.VersionKinds `json:",inline"`

	// Labels defines metadata policies by label key.
	//
	// +optional
	Labels map[string]MetadataValueRule `json:"labels,omitempty"`

	// Annotations defines metadata policies by annotation key.
	//
	// +optional
	Annotations map[string]MetadataValueRule `json:"annotations,omitempty"`
}

MetadataRule defines metadata constraints for namespaced resources.

+kubebuilder:object:generate=true +kubebuilder:validation:XValidation:rule="has(self.labels) || has(self.annotations)",message="at least one of labels or annotations must be set"

func (*MetadataRule) DeepCopy added in v0.13.8

func (in *MetadataRule) DeepCopy() *MetadataRule

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

func (*MetadataRule) DeepCopyInto added in v0.13.8

func (in *MetadataRule) DeepCopyInto(out *MetadataRule)

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

func (MetadataRule) MatchesGroupVersionKind added in v0.13.10

func (r MetadataRule) MatchesGroupVersionKind(gvk schema.GroupVersionKind) bool

MatchesGroupVersionKind matches metadata targets. Namespace is deliberately opt-in: wildcard kind selectors never include it, so cluster-scoped namespace admission cannot be enabled accidentally.

type MetadataValueRule added in v0.13.8

type MetadataValueRule struct {
	// Required enforces that the metadata key must be present.
	//
	// This is mainly meaningful with action=allow. Deny and audit rules remain
	// value matchers and do not require missing metadata to exist.
	//
	// +optional
	// +kubebuilder:default:=false
	Required bool `json:"required,omitempty"`

	// Values defines allowed, denied, or audited values for the metadata key.
	//
	// If Required=true and Values is empty, only presence is enforced.
	//
	// +optional
	Values []runtime.ExpressionMatch `json:"values,omitempty"`

	// Default is applied by admission mutation when the concrete metadata key is absent.
	// It is not reconciled after admission.
	// +optional
	Default *string `json:"default,omitempty"`

	// Managed is enforced by admission mutation and reconciled by the RuleStatus
	// controller using server-side apply when the rule configuration changes.
	// +optional
	Managed *string `json:"managed,omitempty"`
}

+kubebuilder:object:generate=true

func (*MetadataValueRule) DeepCopy added in v0.13.8

func (in *MetadataValueRule) DeepCopy() *MetadataValueRule

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

func (*MetadataValueRule) DeepCopyInto added in v0.13.8

func (in *MetadataValueRule) DeepCopyInto(out *MetadataValueRule)

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

type NamespaceRuleBodyNamespace

type NamespaceRuleBodyNamespace struct {
	// Audience limits this rule to matching request subjects.
	// An empty audience matches every request.
	// +optional
	Audience []Audience `json:"audience,omitempty"`

	// Enforcement for given rule
	//+optional
	Enforce *NamespaceRuleEnforceBody `json:"enforce,omitzero"`
}

For future implementation where users might manage RuleStatus CRs themselves +kubebuilder:object:generate=true

func (*NamespaceRuleBodyNamespace) DeepCopy

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

func (*NamespaceRuleBodyNamespace) DeepCopyInto

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

type NamespaceRuleBodyTenant

type NamespaceRuleBodyTenant struct {
	*NamespaceRuleBodyNamespace `json:",inline"`

	// Select namespaces which are going to be targeted with this rule
	NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`

	// Permissions for given rule
	//+optional
	Permissions NamespaceRulePermissionBody `json:"permissions,omitempty"`
}

Rules Distributed via Tenants +kubebuilder:object:generate=true

func (*NamespaceRuleBodyTenant) DeepCopy

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

func (*NamespaceRuleBodyTenant) DeepCopyInto

func (in *NamespaceRuleBodyTenant) DeepCopyInto(out *NamespaceRuleBodyTenant)

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

type NamespaceRuleEnforceBody

type NamespaceRuleEnforceBody struct {
	// Declare the action being performed on the enforcement rule:
	// deny: On match, deny admission request
	// allow: On match, allowed admission request
	// audit: On match, audit (post event) of admission request
	//+kubebuilder:default:=deny
	Action ActionType `json:"action,omitempty"`

	// Enforcement for Workloads (Pods)
	Workloads NamespaceRuleEnforceWorkloadsBody `json:"workloads,omitempty"`

	// Enforcement for Services.
	// +optional
	Services NamespaceRuleEnforceServicesBody `json:"services,omitempty"`

	// Enforcement for object metadata on namespaced resources.
	//
	// +optional
	Metadata []MetadataRule `json:"metadata,omitempty"`

	// Enforcement for Ingress and Gateway API resource hostnames.
	// +optional
	Ingress NamespaceRuleEnforceIngressBody `json:"ingress,omitempty"`
}

+kubebuilder:object:generate=true

func (*NamespaceRuleEnforceBody) DeepCopy

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

func (*NamespaceRuleEnforceBody) DeepCopyInto

func (in *NamespaceRuleEnforceBody) DeepCopyInto(out *NamespaceRuleEnforceBody)

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

func (NamespaceRuleEnforceBody) GetWorkloadTargets

func (e NamespaceRuleEnforceBody) GetWorkloadTargets(target WorkloadValidationTarget) bool

func (NamespaceRuleEnforceBody) WorkloadTargetsAny

func (e NamespaceRuleEnforceBody) WorkloadTargetsAny(targets ...WorkloadValidationTarget) bool

type NamespaceRuleEnforceIngressBody added in v0.13.10

type NamespaceRuleEnforceIngressBody struct {
	// Types defines the resource kinds to which hostname enforcement applies.
	//
	// +kubebuilder:validation:MinItems=1
	Types []IngressType `json:"types,omitempty"`

	// Hostnames defines allowed, denied, or audited hostname expressions.
	// A resource targeted by an allow or deny rule must declare non-empty values
	// in all hostname fields. Audit-only rules record missing hostnames without
	// denying them.
	//
	// +kubebuilder:validation:MinItems=1
	Hostnames []runtime.ExpressionMatch `json:"hostnames,omitempty"`
}

NamespaceRuleEnforceIngressBody defines hostname enforcement for Kubernetes Ingress and Gateway API resources.

+kubebuilder:object:generate=true

func (*NamespaceRuleEnforceIngressBody) DeepCopy added in v0.13.10

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

func (*NamespaceRuleEnforceIngressBody) DeepCopyInto added in v0.13.10

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

type NamespaceRuleEnforceServicesBody added in v0.13.7

type NamespaceRuleEnforceServicesBody struct {
	// Types defines the Service types matched by this rule.
	//
	// Supported values:
	// - ClusterIP
	// - NodePort
	// - LoadBalancer
	// - ExternalName
	//
	// +optional
	// +kubebuilder:validation:items:Enum=ClusterIP;NodePort;LoadBalancer;ExternalName
	Types []ServiceType `json:"types,omitempty"`

	// LoadBalancers defines additional constraints for Services of type LoadBalancer.
	// +optional
	LoadBalancers *ServiceLoadBalancerRule `json:"loadBalancers,omitempty"`

	// ExternalNames defines additional constraints for Services of type ExternalName.
	// +optional
	ExternalNames *ServiceExternalNameRule `json:"externalNames,omitempty"`

	// NodePorts defines additional constraints for nodePort values.
	// +optional
	NodePorts *ServiceNodePortRule `json:"nodePorts,omitempty"`
}

+kubebuilder:object:generate=true

func (*NamespaceRuleEnforceServicesBody) DeepCopy added in v0.13.7

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

func (*NamespaceRuleEnforceServicesBody) DeepCopyInto added in v0.13.7

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

type NamespaceRuleEnforceWorkloadsBody

type NamespaceRuleEnforceWorkloadsBody struct {
	// Define the enforcement targets this rule applies to.
	// If empty, each webhook applies its own backwards-compatible default.
	// +optional
	Targets []WorkloadValidationTarget `json:"targets,omitempty"`

	// Define Pod QoS classes matched by this enforcement rule.
	// Supported values are Guaranteed, Burstable and BestEffort.
	// +optional
	QoSClasses []corev1.PodQOSClass `json:"qosClasses,omitempty"`

	// Define registries which are allowed to be used within this tenant
	// The rules are aggregated, since you can use Regular Expressions the match registry endpoints
	// +optional
	Registries []OCIRegistry `json:"registries,omitempty"`

	// Schedulers defines schedulerName matchers for Pod admission.
	//
	// The rule is evaluated against pod.spec.schedulerName.
	// Empty schedulerName is ignored and is not normalized to default-scheduler.
	//
	// +optional
	Schedulers []runtime.ExpressionMatch `json:"schedulers,omitempty"`
}

+kubebuilder:object:generate=true

func (*NamespaceRuleEnforceWorkloadsBody) DeepCopy

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

func (*NamespaceRuleEnforceWorkloadsBody) DeepCopyInto

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

type NamespaceRulePermissionBody

type NamespaceRulePermissionBody struct {
	// Bindings defines additional RoleBindings for namespaces selected by this rule.
	Bindings []rbac.AdditionalRoleBindingsSpec `json:"bindings,omitempty"`

	// Define Promotion Rules which distributed additional ClusterRoles across the Tenant
	// for promoted ServiceAccounts.
	Promotions []*NamespaceRulePromotionRule `json:"promotions,omitempty"`
}

+kubebuilder:object:generate=true

func (*NamespaceRulePermissionBody) DeepCopy

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

func (*NamespaceRulePermissionBody) DeepCopyInto

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

type NamespaceRulePromotionRule

type NamespaceRulePromotionRule struct {
	// ClusterRoles granted to the promoted ServiceAccounts across the Tenant
	// kubebuilder:validation:Minimum=1
	ClusterRoles []string `json:"clusterRoles,omitempty"`

	// Match ServiceAccounts which are promoted which are granted these additional ClusterRoles
	// across the Tenant
	Selector *metav1.LabelSelector `json:"selector,omitempty"`
}

+kubebuilder:object:generate=true

func (*NamespaceRulePromotionRule) DeepCopy

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

func (*NamespaceRulePromotionRule) DeepCopyInto

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

type OCIRegistry

type OCIRegistry struct {
	runtime.ExpressionMatch `json:",inline"`

	// Allowed PullPolicy for the given registry. Supplying no value allows all policies.
	// +optional
	// +kubebuilder:validation:Items:Enum=Always;Never;IfNotPresent
	Policy []corev1.PullPolicy `json:"policy,omitempty"`
}

+kubebuilder:object:generate=true

func (*OCIRegistry) DeepCopy

func (in *OCIRegistry) DeepCopy() *OCIRegistry

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

func (*OCIRegistry) DeepCopyInto

func (in *OCIRegistry) DeepCopyInto(out *OCIRegistry)

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

type RuleDecision

type RuleDecision struct {
	Action ActionType
	Rule   *NamespaceRuleBodyNamespace
}

type ServiceExternalNameRule added in v0.13.7

type ServiceExternalNameRule struct {
	// Hostnames restricts spec.externalName.
	// Empty means no additional hostname restriction once ExternalName is allowed by types.
	// +optional
	Hostnames []runtime.ExpressionMatch `json:"hostnames,omitempty"`
}

+kubebuilder:object:generate=true

func (*ServiceExternalNameRule) DeepCopy added in v0.13.7

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

func (*ServiceExternalNameRule) DeepCopyInto added in v0.13.7

func (in *ServiceExternalNameRule) DeepCopyInto(out *ServiceExternalNameRule)

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

type ServiceLoadBalancerRule added in v0.13.7

type ServiceLoadBalancerRule struct {
	// CIDRs restricts spec.loadBalancerIP and spec.loadBalancerSourceRanges.
	// Empty means no additional CIDR restriction once LoadBalancer is allowed by types.
	// +optional
	CIDRs []string `json:"cidrs,omitempty"`
}

+kubebuilder:object:generate=true

func (*ServiceLoadBalancerRule) DeepCopy added in v0.13.7

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

func (*ServiceLoadBalancerRule) DeepCopyInto added in v0.13.7

func (in *ServiceLoadBalancerRule) DeepCopyInto(out *ServiceLoadBalancerRule)

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

type ServiceNodePortRange added in v0.13.7

type ServiceNodePortRange struct {
	// +kubebuilder:validation:Minimum=1
	// +kubebuilder:validation:Maximum=65535
	From int32 `json:"from"`

	// +kubebuilder:validation:Minimum=1
	// +kubebuilder:validation:Maximum=65535
	To int32 `json:"to"`
}

+kubebuilder:object:generate=true

func (*ServiceNodePortRange) DeepCopy added in v0.13.7

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

func (*ServiceNodePortRange) DeepCopyInto added in v0.13.7

func (in *ServiceNodePortRange) DeepCopyInto(out *ServiceNodePortRange)

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

type ServiceNodePortRule added in v0.13.7

type ServiceNodePortRule struct {
	// Ports restricts explicitly requested nodePort values.
	// Empty means no additional port restriction once NodePort is allowed by types.
	// +optional
	Ports []ServiceNodePortRange `json:"ports,omitempty"`
}

+kubebuilder:object:generate=true

func (*ServiceNodePortRule) DeepCopy added in v0.13.7

func (in *ServiceNodePortRule) DeepCopy() *ServiceNodePortRule

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

func (*ServiceNodePortRule) DeepCopyInto added in v0.13.7

func (in *ServiceNodePortRule) DeepCopyInto(out *ServiceNodePortRule)

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

type ServiceType added in v0.13.7

type ServiceType string

+kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer;ExternalName

const (
	ServiceTypeClusterIP    ServiceType = "ClusterIP"
	ServiceTypeNodePort     ServiceType = "NodePort"
	ServiceTypeLoadBalancer ServiceType = "LoadBalancer"
	ServiceTypeExternalName ServiceType = "ExternalName"
)

type WorkloadValidationTarget

type WorkloadValidationTarget string

+kubebuilder:validation:Enum=pod/initcontainers;pod/ephemeralcontainers;pod/containers;pod/volumes

const (
	DeprecatedValidateImages WorkloadValidationTarget = "pod/images"

	ValidateInitContainers      WorkloadValidationTarget = "pod/initcontainers"
	ValidateEphemeralContainers WorkloadValidationTarget = "pod/ephemeralcontainers"
	ValidateContainers          WorkloadValidationTarget = "pod/containers"
	ValidateVolumes             WorkloadValidationTarget = "pod/volumes"
)

Jump to

Keyboard shortcuts

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