Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CEL rules to AdmissionCheck #1975

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apis/kueue/v1beta1/admissioncheck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type AdmissionCheckSpec struct {
// controllerName is name of the controller which will actually perform
// the checks. This is the name with which controller identifies with,
// not necessarily a K8S Pod or Deployment name. Cannot be empty.
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="field is immutable"
ControllerName string `json:"controllerName"`

// RetryDelayMinutes specifies how long to keep the workload suspended
Expand All @@ -67,10 +69,16 @@ type AdmissionCheckSpec struct {

type AdmissionCheckParametersReference struct {
// ApiGroup is the group for the resource being referenced.
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern="^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"
APIGroup string `json:"apiGroup"`
// Kind is the type of the resource being referenced.
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern="^(?i)[a-z]([-a-z0-9]*[a-z0-9])?$"
Kind string `json:"kind"`
// Name is the name of the resource being referenced.
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern="^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
Name string `json:"name"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,27 @@ spec:
the checks. This is the name with which controller identifies with,
not necessarily a K8S Pod or Deployment name. Cannot be empty.
type: string
x-kubernetes-validations:
- message: field is immutable
rule: self == oldSelf
parameters:
description: Parameters identifies the resource providing additional
check parameters.
properties:
apiGroup:
description: ApiGroup is the group for the resource being referenced.
maxLength: 253
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
kind:
description: Kind is the type of the resource being referenced.
maxLength: 63
pattern: ^(?i)[a-z]([-a-z0-9]*[a-z0-9])?$
type: string
name:
description: Name is the name of the resource being referenced.
maxLength: 63
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
required:
- apiGroup
Expand Down
20 changes: 0 additions & 20 deletions charts/kueue/templates/webhook/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -540,26 +540,6 @@ webhooks:
resources:
- rayjobs
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: '{{ include "kueue.fullname" . }}-webhook-service'
namespace: '{{ .Release.Namespace }}'
path: /validate-kueue-x-k8s-io-v1beta1-admissioncheck
failurePolicy: Fail
name: vadmissioncheck.kb.io
rules:
- apiGroups:
- kueue.x-k8s.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- admissionchecks
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,27 @@ spec:
the checks. This is the name with which controller identifies with,
not necessarily a K8S Pod or Deployment name. Cannot be empty.
type: string
x-kubernetes-validations:
- message: field is immutable
rule: self == oldSelf
parameters:
description: Parameters identifies the resource providing additional
check parameters.
properties:
apiGroup:
description: ApiGroup is the group for the resource being referenced.
maxLength: 253
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
kind:
description: Kind is the type of the resource being referenced.
maxLength: 63
pattern: ^(?i)[a-z]([-a-z0-9]*[a-z0-9])?$
type: string
name:
description: Name is the name of the resource being referenced.
maxLength: 63
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
required:
- apiGroup
Expand Down
20 changes: 0 additions & 20 deletions config/components/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -496,26 +496,6 @@ webhooks:
resources:
- rayjobs
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-kueue-x-k8s-io-v1beta1-admissioncheck
failurePolicy: Fail
name: vadmissioncheck.kb.io
rules:
- apiGroups:
- kueue.x-k8s.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- admissionchecks
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
Expand Down
104 changes: 0 additions & 104 deletions pkg/webhooks/admissioncheck_webhook.go

This file was deleted.

Loading