-
Notifications
You must be signed in to change notification settings - Fork 253
Support patching installer manifests #2499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support patching installer manifests #2499
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 2uasimojo The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test e2e |
677edab to
6e54c52
Compare
786df32 to
61ae998
Compare
|
This is going well: mycdc looks like: apiVersion: hive.openshift.io/v1
kind: ClusterDeploymentCustomization
metadata:
name: mycdc
namespace: efried
spec:
installerManifestPatches:
- manifestSelector:
glob: cluster-api/*/*machine*.yaml
patches:
- op: add
path: /metadata/labels
valueJSON: |
{"efried.openshift.io/foo": "bar"}The installmanager logs include: and a sample manifest in the in-progress provision pod was correctly patched: apiVersion: cluster.x-k8s.io/v1beta1
kind: Machine
metadata:
creationTimestamp: null
labels:
efried.openshift.io/foo: bar # <=== L@@K
name: efried416-ttb8s-master-0
spec:
bootstrap:
dataSecretName: efried416-ttb8s-master
clusterName: efried416-ttb8s
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachine
name: efried416-ttb8s-master-0
status:
bootstrapReady: false
infrastructureReady: false |
|
I just need to test the clusterpool path (and maybe noodle how the error conditions manifest) and we'll be good to land this. |
|
/cc @abraverm |
|
In Clusterpool we do reservation of the CDC, should this mechanism somewhat migrate/copied to CD controller? |
For pool inventory, reserving CDCs makes sense because they're intended to enable exclusive/unique settings such as reserved IP addresses. And manifest-patching CDCs used for clusterpool inventory will still be subject to reservation as usual. But for this use case -- CDs' CustomizationRef-named CDCs -- I think we explicitly want manifest patching to be usable by multiple CDs without restriction. Does that make sense? |
4c36dc3 to
ea46045
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2499 +/- ##
==========================================
+ Coverage 49.86% 49.92% +0.06%
==========================================
Files 281 281
Lines 32968 33135 +167
==========================================
+ Hits 16439 16544 +105
- Misses 15196 15257 +61
- Partials 1333 1334 +1
🚀 New features to boost your workflow:
|
ea46045 to
4239df0
Compare
2uasimojo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to submit these queued up comments that came out of the live review we did on 11/19.
pkg/controller/clusterdeployment/clusterdeployment_controller.go
Outdated
Show resolved
Hide resolved
pkg/controller/clusterdeployment/clusterdeployment_controller_test.go
Outdated
Show resolved
Hide resolved
pkg/controller/clusterdeployment/clusterdeployment_controller_test.go
Outdated
Show resolved
Hide resolved
pkg/controller/clusterdeployment/clusterdeployment_controller_test.go
Outdated
Show resolved
Hide resolved
4239df0 to
c8f29d8
Compare
|
@2uasimojo: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
c8f29d8 to
a44905f
Compare
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
a44905f to
8dfac7a
Compare
8dfac7a
into
openshift:master
suhanime
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post merge review
Did 2 passes so I think we're good? Just a few nits/minor changes if you feel a fup is worthwhile @2uasimojo
| // CustomizationRef is a reference to a ClusterDeploymentCustomization containing | ||
| // InstallerManifestPatches to be applied to the manifests generated by openshift-install prior | ||
| // to starting the installation. (InstallConfigPatches will be ignored -- those changes should | ||
| // be made directly to the install-config.yaml referenced by InstallConfigSecretRef.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the point of this note, but I feel that cdc related things should be added as a comment right before the definition of cdc struct, that way, in case the cdc is expanded in the future, the comment is more likely to be amended and not go out-of-date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't follow. This is CD's type file, not CDC's. InstallConfigPatches are not ignored when this is used in an inventory CDC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh it's fine, I'm not too attached to moving the comment either ways. When I commented on it, I was thinking about what if an option 3 is introduced in cdc def in the future, and we forget to edit the comment here to say 3 will also be ignored? But it's fine, you have a similar comment on clusterpool's cdc ref, so we can let it be.
| return matchingCDs | ||
| })), | ||
| ); err != nil { | ||
| return errors.Wrap(err, "cannot start watch on ClusterDeploymentCustomizations") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name/namespace here would help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an error setting up the Watch() for any instance of CDC. We don't have a ns/name in this context. (The resolution done in the func is only triggered for a specific instance when the Watch() actually pops.)
|
|
||
| "github.com/pkg/errors" | ||
| log "github.com/sirupsen/logrus" | ||
| "k8s.io/apimachinery/pkg/runtime" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Add a space before this line to keep the k8s deps separate
|
|
||
| log "github.com/sirupsen/logrus" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/types" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Not related to your PR but the logrus dep above should be separate from k8s dep
| // return a nil object and a nil error (this is not considered an error condition). | ||
| // Any other error -- including if the referenced CDC doesn't exist -- is bubbled up. | ||
| func LoadManifestPatches(c client.Client, cd *hivev1.ClusterDeployment, log log.FieldLogger) ([]hivev1.InstallerManifestPatch, error) { | ||
| // Leetle helper to avoid chains of conditionals checking for nils along object paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in Leetle? Or can leave, apparently it was the spelling using in the 1600s. Love the helper!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, this is just me trying to be cute.
|
With this change, you can use new API field
ClusterDeployment.Spec.Provisioning.CustomizationRefto 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 ofPatchEntityrepresenting RFC6902 JSON patches to apply to the matched manifest(s).Also, I got really annoyed having to type out
clusterdeploymentcustomizationson the CLI, so I added abbreviationcdcto 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):InstallerManifestPatchesfield of the existing Inventory CDCs.HIVE-1793