Skip to content

Commit

Permalink
Additional field updates for GA MOSC/MOSB
Browse files Browse the repository at this point in the history
Update from PodImageBuilder to JobImageBuilder, and add a MachineOSBuild
reference to MachineOSConfig.

This matches MCO changes, and add more description around the fields.
  • Loading branch information
yuqi-zhang committed Nov 20, 2024
1 parent c6619bf commit 44656cf
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
baseImagePullSecret:
name: foo
Expand All @@ -36,7 +36,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
baseImagePullSecret:
name: foo
Expand All @@ -59,7 +59,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
baseImagePullSecret:
name: foo
Expand All @@ -80,7 +80,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
baseImagePullSecret:
name: foo
Expand All @@ -102,7 +102,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
baseImagePullSecret:
name: foo
Expand All @@ -125,7 +125,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: foo.bar
baseImagePullSecret:
name: foo
Expand All @@ -148,7 +148,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
baseOSExtensionsImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
renderedImagePushSecret:
Expand All @@ -167,7 +167,7 @@ tests:
name: worker
buildInputs:
imageBuilder:
imageBuilderType: PodImageBuilder
imageBuilderType: JobImageBuilder
baseOSImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
baseOSExtensionsImagePullspec: example.io/my-project/image-v1.0_23@sha256:2c3ea52ac3a41c6d58e85977c3149413e3fa4b70eb2397426456863adbf43306
renderedImagePushSecret:
Expand Down
8 changes: 2 additions & 6 deletions machineconfiguration/v1/types_machineosbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,13 @@ type MachineOSBuildStatus struct {
}

// MachineOSBuilderReference describes which ImageBuilder backend to use for this build
// +union
// +kubebuilder:validation:XValidation:rule="has(self.imageBuilderType) && self.imageBuilderType == 'PodImageBuilder' ? has(self.buildPod) : !has(self.buildPod)",message="buildPod is required when imageBuilderType is PodImageBuilder, and forbidden otherwise"
type MachineOSBuilderReference struct {
// ImageBuilderType describes the image builder set in the MachineOSConfig
// +unionDiscriminator
ImageBuilderType MachineOSImageBuilderType `json:"imageBuilderType"`

// relatedObjects is a list of objects that are related to the build process.
// +unionMember
// ImageBuilderRef is a reference to the object that is managing the image build
// +optional
PodImageBuilder *ObjectReference `json:"buildPod,omitempty"`
ImageBuilderRef *ObjectReference `json:"ImageBuilderRef,omitempty"`
}

// BuildProgess highlights some of the key phases of a build to be tracked in Conditions.
Expand Down
12 changes: 8 additions & 4 deletions machineconfiguration/v1/types_machineosconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ type MachineOSConfigStatus struct {
// +kubebuilder:validation:XValidation:rule=`(self.split('@')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$'))`,message="the OCI Image name should follow the host[:port][/namespace]/name format, resembling a valid URL without the scheme"
// +optional
CurrentImagePullspec string `json:"currentImagePullspec,omitempty"`
// machineOSBuild is a reference to the MachineOSBuild object for this MachineOSConfig, which contains the status for the image build
// +optional
MachineOSBuild *ObjectReference `json:"machineOSBuild,omitempty"`
}

// BuildInputs holds all of the information needed to trigger a build
Expand Down Expand Up @@ -113,6 +116,7 @@ type BuildInputs struct {
// +optional
BaseImagePullSecret *ImageSecretObjectReference `json:"baseImagePullSecret,omitempty"`
// machineOSImageBuilder describes which image builder will be used in each build triggered by this MachineOSConfig
// Currently supported type(s): JobImageBuilder
// +kubebuilder:validation:Required
ImageBuilder *MachineOSImageBuilder `json:"imageBuilder"`
// renderedImagePushSecret is the secret used to connect to a user registry.
Expand Down Expand Up @@ -169,8 +173,8 @@ type BuildOutputs struct {

type MachineOSImageBuilder struct {
// imageBuilderType specifies the backend to be used to build the image.
// +kubebuilder:validation:Enum:=PodImageBuilder
// Valid options are: PodImageBuilder
// +kubebuilder:validation:Enum:=JobImageBuilder
// Valid options are: JobImageBuilder
ImageBuilderType MachineOSImageBuilderType `json:"imageBuilderType"`
}

Expand Down Expand Up @@ -234,6 +238,6 @@ type ImageSecretObjectReference struct {
type MachineOSImageBuilderType string

const (
// describes that the machine-os-builder will use a custom pod builder that uses buildah
PodBuilder MachineOSImageBuilderType = "PodImageBuilder"
// describes that the machine-os-builder will use a Job to spin up a custom pod builder that uses buildah
JobBuilder MachineOSImageBuilderType = "JobImageBuilder"
)
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ spec:
description: BuilderReference describes which ImageBuilder backend
to use for this build
properties:
buildPod:
description: relatedObjects is a list of objects that are related
to the build process.
ImageBuilderRef:
description: ImageBuilderRef is a reference to the object that
is managing the image build
properties:
group:
description: |-
Expand Down Expand Up @@ -172,11 +172,6 @@ spec:
in the MachineOSConfig
type: string
type: object
x-kubernetes-validations:
- message: buildPod is required when imageBuilderType is PodImageBuilder,
and forbidden otherwise
rule: 'has(self.imageBuilderType) && self.imageBuilderType == ''PodImageBuilder''
? has(self.buildPod) : !has(self.buildPod)'
conditions:
description: |-
conditions are state related conditions for the build. Valid types are:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ spec:
description: BuilderReference describes which ImageBuilder backend
to use for this build
properties:
buildPod:
description: relatedObjects is a list of objects that are related
to the build process.
ImageBuilderRef:
description: ImageBuilderRef is a reference to the object that
is managing the image build
properties:
group:
description: |-
Expand Down Expand Up @@ -172,11 +172,6 @@ spec:
in the MachineOSConfig
type: string
type: object
x-kubernetes-validations:
- message: buildPod is required when imageBuilderType is PodImageBuilder,
and forbidden otherwise
rule: 'has(self.imageBuilderType) && self.imageBuilderType == ''PodImageBuilder''
? has(self.buildPod) : !has(self.buildPod)'
conditions:
description: |-
conditions are state related conditions for the build. Valid types are:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ spec:
description: BuilderReference describes which ImageBuilder backend
to use for this build
properties:
buildPod:
description: relatedObjects is a list of objects that are related
to the build process.
ImageBuilderRef:
description: ImageBuilderRef is a reference to the object that
is managing the image build
properties:
group:
description: |-
Expand Down Expand Up @@ -172,11 +172,6 @@ spec:
in the MachineOSConfig
type: string
type: object
x-kubernetes-validations:
- message: buildPod is required when imageBuilderType is PodImageBuilder,
and forbidden otherwise
rule: 'has(self.imageBuilderType) && self.imageBuilderType == ''PodImageBuilder''
? has(self.buildPod) : !has(self.buildPod)'
conditions:
description: |-
conditions are state related conditions for the build. Valid types are:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ spec:
- containerfileArch
x-kubernetes-list-type: map
imageBuilder:
description: machineOSImageBuilder describes which image builder
will be used in each build triggered by this MachineOSConfig
description: |-
machineOSImageBuilder describes which image builder will be used in each build triggered by this MachineOSConfig
Currently supported type(s): JobImageBuilder
properties:
imageBuilderType:
description: |-
imageBuilderType specifies the backend to be used to build the image.
Valid options are: PodImageBuilder
Valid options are: JobImageBuilder
enum:
- PodImageBuilder
- JobImageBuilder
type: string
type: object
releaseVersion:
Expand Down Expand Up @@ -323,6 +324,42 @@ spec:
- message: the OCI Image name should follow the host[:port][/namespace]/name
format, resembling a valid URL without the scheme
rule: (self.split('@')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$'))
machineOSBuild:
description: machineOSBuild is a reference to the MachineOSBuild object
for this MachineOSConfig, which contains the status for the image
build
properties:
group:
description: |-
group of the referent.
This value should consist of only lowercase alphanumeric characters, hyphens and periods.
Example: "", "apps", "build.openshift.io", etc.
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
name:
description: name of the referent.
maxLength: 256
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
namespace:
description: namespace of the referent.
maxLength: 63
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
resource:
description: |-
resource of the referent.
This value should consist of only lowercase alphanumeric characters and hyphens.
Example: "deployments", "deploymentconfigs", "pods", etc.
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
required:
- group
- name
- resource
type: object
observedGeneration:
description: observedGeneration represents the generation observed
by the Machine Config Operator's build controller.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ spec:
- containerfileArch
x-kubernetes-list-type: map
imageBuilder:
description: machineOSImageBuilder describes which image builder
will be used in each build triggered by this MachineOSConfig
description: |-
machineOSImageBuilder describes which image builder will be used in each build triggered by this MachineOSConfig
Currently supported type(s): JobImageBuilder
properties:
imageBuilderType:
description: |-
imageBuilderType specifies the backend to be used to build the image.
Valid options are: PodImageBuilder
Valid options are: JobImageBuilder
enum:
- PodImageBuilder
- JobImageBuilder
type: string
type: object
releaseVersion:
Expand Down Expand Up @@ -323,6 +324,42 @@ spec:
- message: the OCI Image name should follow the host[:port][/namespace]/name
format, resembling a valid URL without the scheme
rule: (self.split('@')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$'))
machineOSBuild:
description: machineOSBuild is a reference to the MachineOSBuild object
for this MachineOSConfig, which contains the status for the image
build
properties:
group:
description: |-
group of the referent.
This value should consist of only lowercase alphanumeric characters, hyphens and periods.
Example: "", "apps", "build.openshift.io", etc.
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
name:
description: name of the referent.
maxLength: 256
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
namespace:
description: namespace of the referent.
maxLength: 63
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
resource:
description: |-
resource of the referent.
This value should consist of only lowercase alphanumeric characters and hyphens.
Example: "deployments", "deploymentconfigs", "pods", etc.
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
required:
- group
- name
- resource
type: object
observedGeneration:
description: observedGeneration represents the generation observed
by the Machine Config Operator's build controller.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ spec:
- containerfileArch
x-kubernetes-list-type: map
imageBuilder:
description: machineOSImageBuilder describes which image builder
will be used in each build triggered by this MachineOSConfig
description: |-
machineOSImageBuilder describes which image builder will be used in each build triggered by this MachineOSConfig
Currently supported type(s): JobImageBuilder
properties:
imageBuilderType:
description: |-
imageBuilderType specifies the backend to be used to build the image.
Valid options are: PodImageBuilder
Valid options are: JobImageBuilder
enum:
- PodImageBuilder
- JobImageBuilder
type: string
type: object
releaseVersion:
Expand Down Expand Up @@ -323,6 +324,42 @@ spec:
- message: the OCI Image name should follow the host[:port][/namespace]/name
format, resembling a valid URL without the scheme
rule: (self.split('@')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$'))
machineOSBuild:
description: machineOSBuild is a reference to the MachineOSBuild object
for this MachineOSConfig, which contains the status for the image
build
properties:
group:
description: |-
group of the referent.
This value should consist of only lowercase alphanumeric characters, hyphens and periods.
Example: "", "apps", "build.openshift.io", etc.
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
name:
description: name of the referent.
maxLength: 256
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
namespace:
description: namespace of the referent.
maxLength: 63
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
resource:
description: |-
resource of the referent.
This value should consist of only lowercase alphanumeric characters and hyphens.
Example: "deployments", "deploymentconfigs", "pods", etc.
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
required:
- group
- name
- resource
type: object
observedGeneration:
description: observedGeneration represents the generation observed
by the Machine Config Operator's build controller.
Expand Down
Loading

0 comments on commit 44656cf

Please sign in to comment.