-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Add PSA for blocking .host
on pod probes
#125271
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 PSA for blocking .host
on pod probes
#125271
Conversation
Skipping CI for Draft Pull Request. |
7ff5459
to
24e1078
Compare
.host
on pod probes.host
on pod probes
staging/src/k8s.io/pod-security-admission/policy/check_probes.go
Outdated
Show resolved
Hide resolved
/triage accepted |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
24e1078
to
cc1d5c7
Compare
Hello @tssurya @liggitt |
8cd3341
to
1b05dbf
Compare
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.
a couple nits, then lgtm
please also open the documentation PR to update https://kubernetes.io/docs/concepts/security/pod-security-standards/#baseline for the dev-1.34 branch in https://github.com/kubernetes/website/
staging/src/k8s.io/pod-security-admission/policy/check_hostProbesAndhostLifecycle.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/pod-security-admission/policy/check_hostProbesAndhostLifecycle.go
Show resolved
Hide resolved
thank you @liggitt for taking the time and patiently reviewing this and for your valuable suggestions, I'll fix the last set of comments now.. |
Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
This commit adds the fixture tests for the new .host field restrictions on probe and lifecycle handlers. ran UPDATE_POD_SECURITY_FIXTURE_DATA=true go test -v ./test/... -run TestFixtures Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
The sig-node tests have scenarios of doing probes and lifecycle handler tests with post-start and pre-stop hooks setting the host field to be another pod. In baseline level such things won't be allowed because of the PSA rules we are adding in this PR. So unsetting the host field means it uses the podIP of self for doing the checks and using that in the pre-stop and post-start hooks is tricky because of the timing issues with when the container is actually up v/s running the test. So I have changed the tests to be privileded for them to use the .host fields if they desire to. See kubernetes#133091 which is an issue opened to properly refactor these tests. Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
1b05dbf
to
4c87e60
Compare
/lgtm |
LGTM label has been added. Git tree hash: 9953493bdf0e2230d06acc863906b76cd9a3b1f8
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, tssurya 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 |
It seems like this PR may have broken https://testgrid.k8s.io/sig-api-machinery-emulated-version @tssurya it seems to be breaking poststart hooks, is this also occurring in regular conformance tests? |
@michaelasp : Looking at the test grid link I can see its the same two sig-node tests around Lifecycle Hooks - if the tests are using '.Host' in the life cycle hook then yes I might have broken them :( starting this PR
We added a PSA blocking all Also, those two sig-node tests also need a cleanup (#133091). |
It seems like this might be the first new PSA rule added since KEP-4330: Compatibility Versions in Kubernetes? I think the answer here is that PSA application needs to be based on the |
hrmm... yeah... emulating an older minor should really adjust what PSA sees as the "latest" minor for the checks it chooses to run. I started plumbing emulated version into admission and it got really big really fast. I opened #133176 as a stop-gap for this one feature, will follow up in 1.35 to make admission and PSA generally emulation-version-aware. |
(following up, https://testgrid.k8s.io/sig-testing-kind#compatibility-version-test-n-minus-1 jobs are green again after merge of #133176) |
This one is still failing since 2025-07-24:
|
What type of PR is this?
/kind bug
/kind feature
What this PR does / why we need it:
This PR aims to add the following fields as part of PSA so that users can be blocked/warned when they create probes with the
.Host
field set.Which issue(s) this PR fixes:
Fixes #99425
Fixes kubernetes/enhancements#4940
Special notes for your reviewer:
This is my first PR to pod-security-admission area, so I might need some hand-holding, but I will mark the PR as draft till I get all the pieces done.
So one question I have is should I fix the tests on sig-node side like I have done here today by making them use the privileged mode? Or should I do something like 77fa562
Ran the following tests locally:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
Please use the following format for linking documentation:
.host
field from ProbeHandler and LifecycleHandler enhancements#4940