Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 api/hypershift/v1beta1/nodepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type NodePool struct {
}

// NodePoolSpec is the desired behavior of a NodePool.
// +openshift:validation:FeatureGateAwareXValidation:featureGate=OSStreams,rule="!has(oldSelf.osImageStream) || has(self.osImageStream)",message="osImageStream cannot be removed once set; create a new NodePool instead"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.arch) || has(self.arch)", message="Arch is required once set"
// +kubebuilder:validation:XValidation:rule="self.arch != 'arm64' || has(self.platform.aws) || has(self.platform.azure) || has(self.platform.agent) || self.platform.type == 'GCP' || self.platform.type == 'None'", message="Setting Arch to arm64 is only supported for AWS, Azure, Agent, GCP and None"
// +kubebuilder:validation:XValidation:rule="!has(self.replicas) || !has(self.autoScaling)", message="Both replicas or autoScaling should not be set"
Expand Down Expand Up @@ -261,6 +262,13 @@ type NodePoolSpec struct {
OSImageStream OSImageStreamReference `json:"osImageStream,omitzero"`
}

const (
// OSImageStreamRHEL9 is the OS image stream name for RHEL 9.
OSImageStreamRHEL9 = "rhel-9"
// OSImageStreamRHEL10 is the OS image stream name for RHEL 10.
OSImageStreamRHEL10 = "rhel-10"
)

// OSImageStreamReference references an OSImageStream by name.
type OSImageStreamReference struct {
// name is a required reference to an OSImageStream to be used for the pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,9 @@ spec:
- release
type: object
x-kubernetes-validations:
- message: osImageStream cannot be removed once set; create a new NodePool
instead
rule: '!has(oldSelf.osImageStream) || has(self.osImageStream)'
- message: Arch is required once set
rule: '!has(oldSelf.arch) || has(self.arch)'
- message: Setting Arch to arm64 is only supported for AWS, Azure, Agent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,55 @@ tests:
osImageStream:
name: "rhel-10"

- name: When removing osImageStream from an existing NodePool it should fail
initial: |
apiVersion: hypershift.openshift.io/v1beta1
kind: NodePool
spec:
arch: amd64
clusterName: some-cluster
management:
autoRepair: false
upgradeType: Replace
release:
image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64
replicas: 0
platform:
aws:
instanceProfile: a-profile
instanceType: m6a.2xlarge
rootVolume:
size: 120
type: gp3
subnet:
id: "subnet-any"
type: AWS
osImageStream:
name: "rhel-10"
updated: |
apiVersion: hypershift.openshift.io/v1beta1
kind: NodePool
spec:
arch: amd64
clusterName: some-cluster
management:
autoRepair: false
upgradeType: Replace
release:
image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64
replicas: 0
platform:
aws:
instanceProfile: a-profile
instanceType: m6a.2xlarge
rootVolume:
size: 120
type: gp3
subnet:
id: "subnet-any"
type: AWS
expectedError: "osImageStream cannot be removed once set; create a new NodePool instead"

- name: When adding osImageStream to an existing NodePool it should succeed
initial: |
apiVersion: hypershift.openshift.io/v1beta1
Expand Down

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

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

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