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

chore: Add pods/resize subresource to mutating and validating webhooks #3778

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

ianstanton
Copy link

What this PR does / why we need it:
Add pod/resize subresource to mutating and validating webhooks.

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

Special notes for your reviewer:
@JaydipGabani Please let me know if there's anything else we need for this one

@ianstanton ianstanton requested a review from a team as a code owner January 14, 2025 02:32
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add the list of subresources for mutating-webhook-configuration as well?

 - pods/ephemeralcontainers
  - pods/exec
  - pods/log
  - pods/eviction
  - pods/portforward
  - pods/proxy
  - pods/attach
  - pods/binding
  - pods/resize
  - deployments/scale
  - replicasets/scale
  - statefulsets/scale
  - replicationcontrollers/scale
  - services/proxy
  - nodes/proxy
  - services/status

Copy link
Author

Choose a reason for hiding this comment

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

✔️ Updated the kubebuilder annotation in pkg/webhook/mutation.go with these values

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR @ianstanton!

Adding these resources to the MutatingWebhookConfiguration can introduce security risks and, performance impacts. I recommend removing these from the default. Users can always add if needed for their specific use cases based on their own security and performance analysis.

Security Risks:

pods/exec: Allowing exec operations can be risky as it enables direct command execution within containers, which can be exploited if not properly controlled.
pods/log: Access to logs can expose sensitive information.
pods/proxy, services/proxy, nodes/proxy: Proxy operations can be exploited to redirect traffic, potentially exposing internal services.
pods/attach: Attaching to pods can provide direct access to the container's processes and data.
pods/ephemeralcontainers: These can be used to add ephemeral containers to running pods, which could be exploited if proper security measures are not in place.
pods/binding: This operation binds a Pod to a specific Node, which can be misused to affect workload scheduling and performance.
pods/resize: Resizing pods can impact resource allocation and disrupt services.

Performance Impact:

The webhook will intercept more requests, potentially increasing the latency and load on the API server.
Frequent mutations on high-traffic resources (like pods/exec or pods/log) can lead to performance bottlenecks.

We need to balance the need for mutation with the potential risks and performance overhead it introduces. Limiting the scope to only necessary resources and operations is a good practice.

Copy link
Author

Choose a reason for hiding this comment

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

@ritazh Good call, thanks for pointing this out. I'll revert this piece soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

changes in deploy dir are overwritten with each release, so please remove any changes in gatekeeper.yaml file.

Copy link
Author

Choose a reason for hiding this comment

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

👍 Removed these changes

Copy link
Contributor

Choose a reason for hiding this comment

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

Any changes in charts dir is overwritten in release, please remove any changes in this dir.

Copy link
Author

Choose a reason for hiding this comment

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

Got it! Looks like these changes are applied in the manifest_staging dir when we run make generate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yip! that is fine. We want these changes to manifest_staging. You can find out more on contributing to helm chart and overall here - https://open-policy-agent.github.io/gatekeeper/website/docs/help#contributing-to-helm-chart. Thanks again for the PR!

@JaydipGabani
Copy link
Contributor

@ianstanton Thanks for the PR, few changes and we should be good.

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.77%. Comparing base (3350319) to head (9c0769d).
Report is 250 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (3350319) and HEAD (9c0769d). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (9c0769d)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3778      +/-   ##
==========================================
- Coverage   54.49%   47.77%   -6.73%     
==========================================
  Files         134      235     +101     
  Lines       12329    19861    +7532     
==========================================
+ Hits         6719     9488    +2769     
- Misses       5116     9485    +4369     
- Partials      494      888     +394     
Flag Coverage Δ
unittests 47.77% <ø> (-6.73%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JaydipGabani JaydipGabani added this to the v3.20.0 milestone Mar 19, 2025
@ianstanton ianstanton requested a review from JaydipGabani March 27, 2025 11:58
@ianstanton
Copy link
Author

@JaydipGabani @ritazh I've addressed the feedback here #3778 (comment). Please let me know if you'd like to see any other changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pod/resize sub resource to webhooks
4 participants