Skip to content

Commit

Permalink
update api validation on minimumKubeletVersion
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hunt <[email protected]>
  • Loading branch information
origin-release-container authored and haircommander committed Oct 30, 2024
1 parent 0a8ec78 commit 786be86
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "Node"
crdName: nodes.config.openshift.io
featureGate: MinimumKubeletVersion
tests:
onCreate:
- name: Should be able to create a minimal Node
Expand All @@ -12,3 +13,21 @@ tests:
apiVersion: config.openshift.io/v1
kind: Node
spec: {}
- name: Should be able to create a minimumKubeletVersion
initial: |
apiVersion: config.openshift.io/v1
kind: Node
spec:
minimumKubeletVersion: 1.30.0
expected: |
apiVersion: config.openshift.io/v1
kind: Node
spec:
minimumKubeletVersion: 1.30.0
- name: Should fail to create a bogus version
initial: |
apiVersion: config.openshift.io/v1
kind: Node
spec:
minimumKubeletVersion: bogus
expectedError: "Invalid value: \"string\": minmumKubeletVersion must be in a semver compatible format of x.y.z, or empty"
14 changes: 11 additions & 3 deletions config/v1/types_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,22 @@ type NodeSpec struct {
// +optional
WorkerLatencyProfile WorkerLatencyProfileType `json:"workerLatencyProfile,omitempty"`

// MinimumKubeletVersion is the lowest version of a kubelet that can meaningfully join the cluster.
// minimumKubeletVersion is the lowest version of a kubelet that can join the cluster.
// Specifically, the apiserver will deny most authorization requests of kubelets that are older
// than the specified version, only allowing the kubelet to get and update its node object, and perform
// subjectaccessreviews.
// +kubebuilder:validation:Pattern=`^[0-9]*\.[0-9]*\.[0-9]*$`
// This means the kubelet won't be able to view API objects it's responsible for running,
// and will eventually be marked as NotReady.
// Its max length is 8, so maximum version allowed is either "9.999.99" or "99.99.99".
// Since the kubelet reports the version of the kubernetes release, not openshift, this field references
// the underlying kubernetes version this version of openshift is based off of.
// In other words: if an admin wishes to ensure no nodes run an older version than Openshift 4.17, then
// they should set the minimumKubeletVersion to 1.30.0.
// +kubebuilder:validation:XValidation:rule="self == \"\" || self.matches('^[0-9]*.[0-9]*.[0-9]*$')",message="minmumKubeletVersion must be in a semver compatible format of x.y.z, or empty"
// +kubebuilder:validation:MaxLength:=8
// +openshift:enable:FeatureGate=MinimumKubeletVersion
// +optional
MinimumKubeletVersion string `json:"minimumKubeletVersion,omitempty"`
MinimumKubeletVersion string `json:"minimumKubeletVersion"`
}

type NodeStatus struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@ spec:
type: string
minimumKubeletVersion:
description: |-
MinimumKubeletVersion is the lowest version of a kubelet that can meaningfully join the cluster.
minimumKubeletVersion is the lowest version of a kubelet that can join the cluster.
Specifically, the apiserver will deny most authorization requests of kubelets that are older
than the specified version, only allowing the kubelet to get and update its node object, and perform
subjectaccessreviews.
pattern: ^[0-9]*\.[0-9]*\.[0-9]*$
This means the kubelet won't be able to view API objects it's responsible for running,
and will eventually be marked as NotReady.
Its max length is 8, so maximum version allowed is either "9.999.99" or "99.99.99".
Since the kubelet reports the version of the kubernetes release, not openshift, this field references
the underlying kubernetes version this version of openshift is based off of.
In other words: if an admin wishes to ensure no nodes run an older version than Openshift 4.17, then
they should set the minimumKubeletVersion to 1.30.0.
maxLength: 8
type: string
x-kubernetes-validations:
- message: minmumKubeletVersion must be in a semver compatible format
of x.y.z, or empty
rule: self == "" || self.matches('^[0-9]*.[0-9]*.[0-9]*$')
workerLatencyProfile:
description: |-
WorkerLatencyProfile determins the how fast the kubelet is updating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@ spec:
type: string
minimumKubeletVersion:
description: |-
MinimumKubeletVersion is the lowest version of a kubelet that can meaningfully join the cluster.
minimumKubeletVersion is the lowest version of a kubelet that can join the cluster.
Specifically, the apiserver will deny most authorization requests of kubelets that are older
than the specified version, only allowing the kubelet to get and update its node object, and perform
subjectaccessreviews.
pattern: ^[0-9]*\.[0-9]*\.[0-9]*$
This means the kubelet won't be able to view API objects it's responsible for running,
and will eventually be marked as NotReady.
Its max length is 8, so maximum version allowed is either "9.999.99" or "99.99.99".
Since the kubelet reports the version of the kubernetes release, not openshift, this field references
the underlying kubernetes version this version of openshift is based off of.
In other words: if an admin wishes to ensure no nodes run an older version than Openshift 4.17, then
they should set the minimumKubeletVersion to 1.30.0.
maxLength: 8
type: string
x-kubernetes-validations:
- message: minmumKubeletVersion must be in a semver compatible format
of x.y.z, or empty
rule: self == "" || self.matches('^[0-9]*.[0-9]*.[0-9]*$')
workerLatencyProfile:
description: |-
WorkerLatencyProfile determins the how fast the kubelet is updating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@ spec:
type: string
minimumKubeletVersion:
description: |-
MinimumKubeletVersion is the lowest version of a kubelet that can meaningfully join the cluster.
minimumKubeletVersion is the lowest version of a kubelet that can join the cluster.
Specifically, the apiserver will deny most authorization requests of kubelets that are older
than the specified version, only allowing the kubelet to get and update its node object, and perform
subjectaccessreviews.
pattern: ^[0-9]*\.[0-9]*\.[0-9]*$
This means the kubelet won't be able to view API objects it's responsible for running,
and will eventually be marked as NotReady.
Its max length is 8, so maximum version allowed is either "9.999.99" or "99.99.99".
Since the kubelet reports the version of the kubernetes release, not openshift, this field references
the underlying kubernetes version this version of openshift is based off of.
In other words: if an admin wishes to ensure no nodes run an older version than Openshift 4.17, then
they should set the minimumKubeletVersion to 1.30.0.
maxLength: 8
type: string
x-kubernetes-validations:
- message: minmumKubeletVersion must be in a semver compatible format
of x.y.z, or empty
rule: self == "" || self.matches('^[0-9]*.[0-9]*.[0-9]*$')
workerLatencyProfile:
description: |-
WorkerLatencyProfile determins the how fast the kubelet is updating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@ spec:
type: string
minimumKubeletVersion:
description: |-
MinimumKubeletVersion is the lowest version of a kubelet that can meaningfully join the cluster.
minimumKubeletVersion is the lowest version of a kubelet that can join the cluster.
Specifically, the apiserver will deny most authorization requests of kubelets that are older
than the specified version, only allowing the kubelet to get and update its node object, and perform
subjectaccessreviews.
pattern: ^[0-9]*\.[0-9]*\.[0-9]*$
This means the kubelet won't be able to view API objects it's responsible for running,
and will eventually be marked as NotReady.
Its max length is 8, so maximum version allowed is either "9.999.99" or "99.99.99".
Since the kubelet reports the version of the kubernetes release, not openshift, this field references
the underlying kubernetes version this version of openshift is based off of.
In other words: if an admin wishes to ensure no nodes run an older version than Openshift 4.17, then
they should set the minimumKubeletVersion to 1.30.0.
maxLength: 8
type: string
x-kubernetes-validations:
- message: minmumKubeletVersion must be in a semver compatible format
of x.y.z, or empty
rule: self == "" || self.matches('^[0-9]*.[0-9]*.[0-9]*$')
workerLatencyProfile:
description: |-
WorkerLatencyProfile determins the how fast the kubelet is updating
Expand Down
2 changes: 1 addition & 1 deletion config/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion kubecontrolplane/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,19 @@ type KubeAPIServerConfig struct {
// TODO this needs to be removed.
APIServerArguments map[string]Arguments `json:"apiServerArguments"`

// MinimumKubeletVersion is the lowest version of a kubelet that can meaningfully join the cluster.
// minimumKubeletVersion is the lowest version of a kubelet that can join the cluster.
// Specifically, the apiserver will deny most authorization requests of kubelets that are older
// than the specified version, only allowing the kubelet to get and update its node object, and perform
// subjectaccessreviews.
// This means the kubelet won't be able to view API objects it's responsible for running,
// and will eventually be marked as NotReady.
// Its max length is 8, so maximum version allowed is either "9.999.99" or "99.99.99".
// Since the kubelet reports the version of the kubernetes release, not Openshift, this field references
// the underlying kubernetes version this version of Openshift is based off of.
// In other words: if an admin wishes to ensure no nodes run an older version than Openshift 4.17, then
// they should set the minimumKubeletVersion to 1.30.0.
// +kubebuilder:validation:XValidation:rule="self == \"\" || self.matches('^[0-9]*.[0-9]*.[0-9]*$')",message="minmumKubeletVersion must be in a semver compatible format of x.y.z, or empty"
// +kubebuilder:validation:MaxLength:=8
// +openshift:enable:FeatureGate=MinimumKubeletVersion
MinimumKubeletVersion string `json:"minimumKubeletVersion,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion kubecontrolplane/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions openapi/generated_openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 786be86

Please sign in to comment.