Skip to content
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

Add patches for Kustomize to add objectSelectors to pod webhook configurations #362

Merged
merged 3 commits into from
Dec 21, 2023

Conversation

danielvegamyhre
Copy link
Contributor

@danielvegamyhre danielvegamyhre commented Dec 21, 2023

Fixes #361

Note I originally tried using the add JSON Patch op type to simply add objectSelector field into the existing webhook manifests, but it seems to add the objectSelector as a new element in the webhooks array, rather than adding the field to the element at index 1 in the array.

- objectSelector:
       matchExpression: ...

instead of:

  objectSelector:
       matchExpression: ...

The only way I could get it to work was by completely replacing it. This isn't ideal since manifest changes done via kubebuilder markers in the Go code will just get replaced, so we'd need to update the patch every time we update the markers. However, I don't anticipate us needing to update that marker frequently (or ever, really).

References:

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 21, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielvegamyhre

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

The pull request process is described 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 k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 21, 2023
@@ -0,0 +1,26 @@
- op: replace
Copy link
Contributor

Choose a reason for hiding this comment

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

does this override the the configuration for the jobset webhooks? the one named "mutate-jobset-x-k8s-io-v1alpha2-jobset"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, just the mutating webhook configuration at index 1 in the mutating-webhook-configuration webhooks array, which is the pod mutating webhook:

- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate--v1-pod
failurePolicy: Fail
name: mpod.kb.io
rules:
- apiGroups:
- ""
apiVersions:
- v1
operations:
- CREATE
resources:
- pods

Same goes for the validating-webhook-configuration patch.

@ahg-g
Copy link
Contributor

ahg-g commented Dec 21, 2023

Thanks @danielvegamyhre; we should create a minor release with this important fix.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 21, 2023
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 21, 2023
@ahg-g
Copy link
Contributor

ahg-g commented Dec 21, 2023

/lgtm
/hold

lift the hold once you feel comfortable merging

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Dec 21, 2023
@danielvegamyhre
Copy link
Contributor Author

danielvegamyhre commented Dec 21, 2023

Ok I manually tested these changes by installing JobSet on a live cluster which has nodes with insufficient CPU resources to run the controller manager deployment pod, meaning the webhook configuration objects are installed on the cluster, but the deployment pod is unschedulable / in a pending state.

This effectively reproduces the scenario in #361 and the expected behavior is that other pods in the cluster are NOT blocked from being created, since Jobset's pod webhook should not be selecting those pods. To test this, I deployed a random Job and the job pods were created successfully.

@danielvegamyhre
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 21, 2023
@k8s-ci-robot k8s-ci-robot merged commit 41d026a into kubernetes-sigs:main Dec 21, 2023
10 checks passed
k8s-ci-robot added a commit that referenced this pull request Dec 21, 2023
…-#362-upstream-release-0.3

Automated cherry pick of #362: add webhook patches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
3 participants