Skip to content

Migrate remaining bootstrap-only validations from admission webhook to CEL #449

Description

@vishnukothakapu

Is your feature request related to a problem or existing issue? Please describe.

As discussed with @ajaysundark in PR #418:

Currently, some configuration constraints for the bootstrap-only enforcement mode are implemented in the Go admission webhook rather than natively via CRD CEL validation (+kubebuilder:validation:XValidation).

The constraints currently living in the webhook are:

  1. defaultStatus should not be used with bootstrap-only mode.
  2. anyOf conditionPolicy is not supported with bootstrap-only mode.

Describe the solution you'd like

To move closer to our goal of eventually deprecating and removing the validating webhook entirely in favor of native Kubernetes CEL, we should migrate the remaining bootstrap-only validations to CEL expressions on the NodeReadinessRuleSpec.

We can enforce these natively by adding the following XValidation markers:

// +kubebuilder:validation:XValidation:rule="!has(self.enforcementMode) || self.enforcementMode != 'bootstrap-only' || !has(self.conditionPolicy) || self.conditionPolicy != 'anyOf'",message="anyOf conditionPolicy is not supported with bootstrap-only enforcementMode"
// +kubebuilder:validation:XValidation:rule="!has(self.enforcementMode) || self.enforcementMode != 'bootstrap-only' || !has(self.conditions) || self.conditions.all(c, !has(c.defaultStatus))",message="defaultStatus should not be used with bootstrap-only enforcementMode"

Once these are added and tested, the corresponding Go validation logic and unit tests can be cleanly removed from internal/webhook/nodereadinessgaterule_webhook.go.

Describe alternatives you've considered

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kind/featureCategorizes issue or PR as related to a new feature.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions