Skip to content

Commit 8dfac7a

Browse files
committed
Support patching installer manifests
With this change, you can use new API field `ClusterDeployment.Spec.Provisioning.CustomizationRef` to point to a ClusterDeploymentCustomization (hereinafter "CDC") object in the same namespace as the ClusterDeployment (CD). ClusterDeploymentCustomizations: CDC accepts a new subfield, `Spec.InstallerManifestPatches`, which consists of: - `Glob`: a string representing a file glob, relative to the installer working directory, matching one or more manifest files. - `Patches`: a list of `PatchEntity` representing RFC6902 JSON patches to apply to the matched manifest(s). Also, I got really annoyed having to type out `clusterdeploymentcustomizations` on the CLI, so I added abbreviation `cdc` to the schema. ClusterPools: CDC was already being used by ClusterPool-owned CDs to allow patching the install-config generated from the template referred to by `ClusterPool.Spec.InstallConfigSecretTemplateRef`. With this change, ClusterPool-owned CDs can start using manifest patches in two ways (not mutually exclusive): - Patches specific to the CD can be included in the `InstallerManifestPatches` field of the existing Inventory CDCs. - Patches applicable to all CDs in the pool can be provided by a CDC referenced via a new ClusterPool.Spec.CustomizationRef field. HIVE-1793
1 parent 41f153f commit 8dfac7a

23 files changed

+1013
-81
lines changed

apis/hive/v1/clusterdeployment_types.go

+7
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ type Provisioning struct {
218218
// +optional
219219
InstallConfigSecretRef *corev1.LocalObjectReference `json:"installConfigSecretRef,omitempty"`
220220

221+
// CustomizationRef is a reference to a ClusterDeploymentCustomization containing
222+
// InstallerManifestPatches to be applied to the manifests generated by openshift-install prior
223+
// to starting the installation. (InstallConfigPatches will be ignored -- those changes should
224+
// be made directly to the install-config.yaml referenced by InstallConfigSecretRef.)
225+
// +optional
226+
CustomizationRef *corev1.LocalObjectReference `json:"customizationRef,omitempty"`
227+
221228
// ReleaseImage is the image containing metadata for all components that run in the cluster, and
222229
// is the primary and best way to specify what specific version of OpenShift you wish to install.
223230
ReleaseImage string `json:"releaseImage,omitempty"`

apis/hive/v1/clusterdeploymentcustomization_types.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const (
2929
// ClusterDeploymentCustomization is the Schema for clusterdeploymentcustomizations API.
3030
// +kubebuilder:subresource:status
3131
// +k8s:openapi-gen=true
32-
// +kubebuilder:resource:scope=Namespaced
32+
// +kubebuilder:resource:shortName=cdc,scope=Namespaced
3333
type ClusterDeploymentCustomization struct {
3434
metav1.TypeMeta `json:",inline"`
3535
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -42,6 +42,27 @@ type ClusterDeploymentCustomization struct {
4242
type ClusterDeploymentCustomizationSpec struct {
4343
// InstallConfigPatches is a list of patches to be applied to the install-config.
4444
InstallConfigPatches []PatchEntity `json:"installConfigPatches,omitempty"`
45+
46+
// InstallerManifestPatches is a list of patches to be applied to installer-generated manifests.
47+
InstallerManifestPatches []InstallerManifestPatch `json:"installerManifestPatches,omitempty"`
48+
}
49+
50+
type InstallerManifestPatch struct {
51+
// ManifestSelector identifies one or more manifests to patch
52+
ManifestSelector ManifestSelector `json:"manifestSelector"`
53+
54+
// Patches is a list of RFC6902 patches to apply to manifests identified by manifestSelector.
55+
Patches []PatchEntity `json:"patches"`
56+
}
57+
58+
type ManifestSelector struct {
59+
// Glob is a file glob (per https://pkg.go.dev/path/filepath#Glob) identifying one or more
60+
// manifests. Paths should be relative to the installer's working directory. Examples:
61+
// - openshift/99_role-cloud-creds-secret-reader.yaml
62+
// - openshift/99_openshift-cluster-api_worker-machineset-*.yaml
63+
// - */*secret*
64+
// It is an error if a glob matches zero manifests.
65+
Glob string `json:"glob"`
4566
}
4667

4768
// PatchEntity represents a json patch (RFC 6902) to be applied

apis/hive/v1/clusterpool_types.go

+7
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ type ClusterPoolSpec struct {
102102
// additional features of the installer.
103103
// +optional
104104
InstallerEnv []corev1.EnvVar `json:"installerEnv,omitempty"`
105+
106+
// CustomizationRef refers to a ClusterDeploymentCustomization object whose InstallerManifestPatches should
107+
// be applied to *all* ClusterDeployments created by this ClusterPool. This is in addition to any CDC from
108+
// Inventory. The CDC must exist in the ClusterPool's namespace. It will be copied to the namespace of each
109+
// ClusterDeployment generated by the ClusterPool.
110+
// +optional
111+
CustomizationRef *corev1.LocalObjectReference `json:"customizationRef,omitempty"`
105112
}
106113

107114
type HibernationConfig struct {

apis/hive/v1/zz_generated.deepcopy.go

+55
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crds/hive.openshift.io_clusterdeploymentcustomizations.yaml

+68
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ spec:
1010
kind: ClusterDeploymentCustomization
1111
listKind: ClusterDeploymentCustomizationList
1212
plural: clusterdeploymentcustomizations
13+
shortNames:
14+
- cdc
1315
singular: clusterdeploymentcustomization
1416
scope: Namespaced
1517
versions:
@@ -79,6 +81,72 @@ spec:
7981
- path
8082
type: object
8183
type: array
84+
installerManifestPatches:
85+
description: InstallerManifestPatches is a list of patches to be applied
86+
to installer-generated manifests.
87+
items:
88+
properties:
89+
manifestSelector:
90+
description: ManifestSelector identifies one or more manifests
91+
to patch
92+
properties:
93+
glob:
94+
description: |-
95+
Glob is a file glob (per https://pkg.go.dev/path/filepath#Glob) identifying one or more
96+
manifests. Paths should be relative to the installer's working directory. Examples:
97+
- openshift/99_role-cloud-creds-secret-reader.yaml
98+
- openshift/99_openshift-cluster-api_worker-machineset-*.yaml
99+
- */*secret*
100+
It is an error if a glob matches zero manifests.
101+
type: string
102+
required:
103+
- glob
104+
type: object
105+
patches:
106+
description: Patches is a list of RFC6902 patches to apply to
107+
manifests identified by manifestSelector.
108+
items:
109+
description: PatchEntity represents a json patch (RFC 6902)
110+
to be applied
111+
properties:
112+
from:
113+
description: From is the json path to copy or move the
114+
value from
115+
type: string
116+
op:
117+
description: Op is the operation to perform.
118+
enum:
119+
- add
120+
- remove
121+
- replace
122+
- move
123+
- copy
124+
- test
125+
type: string
126+
path:
127+
description: Path is the json path to the value to be
128+
modified
129+
type: string
130+
value:
131+
description: |-
132+
Value is the *string* value to be used in the operation. For more complex values, use
133+
ValueJSON.
134+
type: string
135+
valueJSON:
136+
description: |-
137+
ValueJSON is a string representing a JSON object to be used in the operation. As such,
138+
internal quotes must be escaped. If nonempty, Value is ignored.
139+
type: string
140+
required:
141+
- op
142+
- path
143+
type: object
144+
type: array
145+
required:
146+
- manifestSelector
147+
- patches
148+
type: object
149+
type: array
82150
type: object
83151
status:
84152
description: ClusterDeploymentCustomizationStatus defines the observed

config/crds/hive.openshift.io_clusterdeployments.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,24 @@ spec:
10171017
Provisioning contains settings used only for initial cluster provisioning.
10181018
May be unset in the case of adopted clusters.
10191019
properties:
1020+
customizationRef:
1021+
description: |-
1022+
CustomizationRef is a reference to a ClusterDeploymentCustomization containing
1023+
InstallerManifestPatches to be applied to the manifests generated by openshift-install prior
1024+
to starting the installation. (InstallConfigPatches will be ignored -- those changes should
1025+
be made directly to the install-config.yaml referenced by InstallConfigSecretRef.)
1026+
properties:
1027+
name:
1028+
default: ""
1029+
description: |-
1030+
Name of the referent.
1031+
This field is effectively required, but due to backwards compatibility is
1032+
allowed to be empty. Instances of this type with an empty value here are
1033+
almost certainly wrong.
1034+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
1035+
type: string
1036+
type: object
1037+
x-kubernetes-map-type: atomic
10201038
imageSetRef:
10211039
description: |-
10221040
ImageSetRef is a reference to a ClusterImageSet. If a value is specified for ReleaseImage,

config/crds/hive.openshift.io_clusterpools.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@ spec:
9696
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
9797
type: string
9898
type: object
99+
customizationRef:
100+
description: |-
101+
CustomizationRef refers to a ClusterDeploymentCustomization object whose InstallerManifestPatches should
102+
be applied to *all* ClusterDeployments created by this ClusterPool. This is in addition to any CDC from
103+
Inventory. The CDC must exist in the ClusterPool's namespace. It will be copied to the namespace of each
104+
ClusterDeployment generated by the ClusterPool.
105+
properties:
106+
name:
107+
default: ""
108+
description: |-
109+
Name of the referent.
110+
This field is effectively required, but due to backwards compatibility is
111+
allowed to be empty. Instances of this type with an empty value here are
112+
almost certainly wrong.
113+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
114+
type: string
115+
type: object
116+
x-kubernetes-map-type: atomic
99117
hibernateAfter:
100118
description: |-
101119
HibernateAfter will be applied to new ClusterDeployments created for the pool. HibernateAfter will transition

docs/enhancements/clusterpool-inventory.md

+26-27
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@
22

33
[HIVE-1367](https://issues.redhat.com/browse/HIVE-1367)
44

5-
- [Clusterpool for on-prem cloud providers](#clusterpool-for-on-prem-cloud-providers)
6-
- [Summary](#summary)
7-
- [Problem Statement](#problem-statement)
8-
- [Proposal](#proposal)
9-
- [Summary](#summary-1)
10-
- [`ClusterPool.Spec.Inventory`](#clusterpoolspecinventory)
11-
- [How To Use](#how-to-use)
12-
- [Validation](#validation)
13-
- [`Size` and `MaxSize`](#size-and-maxsize)
14-
- [Pool Version](#pool-version)
15-
- [Handling Inventory Updates](#handling-inventory-updates)
16-
- [Adding An Inventory](#adding-an-inventory)
17-
- [Adding An Entry to the Inventory](#adding-an-entry-to-the-inventory)
18-
- [Removing An Entry from the Inventory](#removing-an-entry-from-the-inventory)
19-
- [Deleting The Inventory](#deleting-the-inventory)
20-
- [Maintaining the lease of the ClusterDeploymentCustomization](#maintaining-the-lease-of-the-clusterdeploymentcustomization)
21-
- [Fairness](#fairness)
22-
- [Future](#future)
23-
- [Alternatives](#alternatives)
24-
- [Bespoke Inventory Definition](#bespoke-inventory-definition)
25-
- [Full Spec](#full-spec)
26-
- [Hooks](#hooks)
5+
- [Summary](#summary)
6+
- [Problem Statement](#problem-statement)
7+
- [Proposal](#proposal)
8+
- [Summary](#summary-1)
9+
- [`ClusterPool.Spec.Inventory`](#clusterpoolspecinventory)
10+
- [How To Use](#how-to-use)
11+
- [Validation](#validation)
12+
- [`Size` and `MaxSize`](#size-and-maxsize)
13+
- [Pool Version](#pool-version)
14+
- [Handling Inventory Updates](#handling-inventory-updates)
15+
- [Adding An Inventory](#adding-an-inventory)
16+
- [Adding An Entry to the Inventory](#adding-an-entry-to-the-inventory)
17+
- [Removing An Entry from the Inventory](#removing-an-entry-from-the-inventory)
18+
- [Deleting The Inventory](#deleting-the-inventory)
19+
- [Maintaining the lease of the ClusterDeploymentCustomization](#maintaining-the-lease-of-the-clusterdeploymentcustomization)
20+
- [Fairness](#fairness)
21+
- [Future](#future)
22+
- [Alternatives](#alternatives)
23+
- [Bespoke Inventory Definition](#bespoke-inventory-definition)
24+
- [Full Spec](#full-spec)
25+
- [Hooks](#hooks)
2726

2827
## Summary
2928

@@ -59,7 +58,7 @@ spec:
5958
6059
and ClusterDeploymentCustomization CR will look like
6160
```yaml
62-
apiVersion: v1
61+
apiVersion: hive.openshift.io/v1
6362
kind: ClusterDeploymentCustomization
6463
metadata:
6564
name: foo-cluster-deployment-customization
@@ -115,10 +114,10 @@ For the VSphere case, this allows the administrator to:
115114
- Create a ClusterDeploymentCustomization CR to patch `spec.metadata.name` field of the default install config generated by clusterpool controller. Please refer the section above of a sample CR. The content in `spec.installConfigPatches` field should be as follows
116115
```yaml
117116
spec:
118-
installConfigPatches:
119-
- op: replace
120-
path: metadata/name
121-
value: foo
117+
installConfigPatches:
118+
- op: replace
119+
path: metadata/name
120+
value: foo
122121
```
123122
- Add the name of ClusterDeploymentCustomization CR to `clusterPool.spec.inventory.ClusterDeploymentCustomizations` list. For ClusterDeploymentCustomization with a name `foo-cluster-deployment-customization` the clusterpool should be configured as follows
124123
```yaml

0 commit comments

Comments
 (0)