Skip to content

Conversation

@hjoshi123
Copy link

What this PR does / why we need it:

Allow JSON merge patches and RFC6902 for provider manifests, this makes it possible to modify provider manifests consistently across releases, for example, if the user needs to change labels/annotations on objects, example usage:

patches:
    - patch: |-
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: not-used
        spec:
          template:
            metadata:
              annotations:
                cluster-autoscaler.kubernetes.io/safe-to-evict: "true"        
      target:
        kind: Deployment
        name: hello-world
        namespace: sample

This still uses the same patch library. This PR doesn't remove the existing field but introduces a new one and in the future versions of the operator we can deprecate the existing manifestPatches field in favor of a more generic patches field.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #792

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign furkatgofurov7 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Welcome @hjoshi123!

It looks like this is your first PR to kubernetes-sigs/cluster-api-operator 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-operator has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 30, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @hjoshi123. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions 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.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 30, 2025
@netlify
Copy link

netlify bot commented Nov 30, 2025

Deploy Preview for kubernetes-sigs-cluster-api-operator ready!

Name Link
🔨 Latest commit 3834a50
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-cluster-api-operator/deploys/693111ea7e8b2f0008084ae9
😎 Deploy Preview https://deploy-preview-937--kubernetes-sigs-cluster-api-operator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hjoshi123 hjoshi123 force-pushed the feat/rfc6902-implementation branch from 5fbe651 to 06a4c41 Compare November 30, 2025 21:40
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 30, 2025
Copy link
Contributor

@nalum nalum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a few comments.

One question I have on the merge patch is around the requirement for the apiVersion key. I know you don't likely have an answer for the reasoning behind that but is that still the case for the new patching setup?

Comment on lines +77 to +84
patches: []*operatorv1.Patch{
{
Patch: addServiceAccoungPatchRBAC,
Target: &operatorv1.PatchSelector{
Group: "rbac.authorization.k8s.io",
Kind: "ClusterRoleBinding",
},
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it will fail the test based on the existing test.

I would update this to use it's own set of patch data as you want to test all patch types that this supports.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am writing more tests. The one I added was just a basic test to see if merge patch works.. and I ran the tests in local and it does patch and tests pass.. I will add more for RFC6902 patches

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did add a test regarding jsonpatch and it passed.. let me know if the code looks good.

@nalum
Copy link
Contributor

nalum commented Dec 1, 2025

Should also update the patching provider manifests page.

Signed-off-by: Hemant Joshi <[email protected]>
@hjoshi123 hjoshi123 force-pushed the feat/rfc6902-implementation branch from 06a4c41 to 3834a50 Compare December 4, 2025 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support RFC6902 json patches for manifests

4 participants