rules

package
v0.13.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 ImagePullPolicySpec

type ImagePullPolicySpec string

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

func (ImagePullPolicySpec) String

func (i ImagePullPolicySpec) String() string

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.

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"`
}

+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 {
	// 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"`
}

+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 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 {
	// 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