786 Commits

Author SHA1 Message Date
yliao
34a64db2c7 extended resource backed by DRA: implementation 2025-07-29 18:55:21 +00:00
Kubernetes Prow Robot
fd3c879a5b Merge pull request #132443 from utam0k/clearn-nnn-bind-api
Clear pod.Status.NominatedNodeName when pod is bound
2025-07-29 10:12:26 -07:00
utam0k
60fa65db88 Clear pod.Status.NominatedNodeName when pod is bound
Signed-off-by: utam0k <k0ma@utam0k.jp>
2025-07-29 23:48:11 +09:00
Rodrigo Campos
48f8458c41 validation: Fix user-namespaces test case name
hostPath is a supported volume since Kubernetes 1.28. Let's update it.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-07-28 16:54:08 +02:00
Rodrigo Campos
50a7a8af4d validation: Align usage of hostUsers in error messages
Other validation errors, like using hostNetwork, don't put
pod.spec.HostNetwork in the error message.

Let's remove align with that.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-07-28 16:54:08 +02:00
Rodrigo Campos
5f7e611f73 validation: Return error if hostUsers=false && volumeDevices
Now if a pod tries to use user namespaces (hostUsers: false) and a
volume device, it will see this error:
	$ kubectl apply -f pod.yaml
	...
	* spec.ephemeralContainers[0].volumeDevices: Forbidden: when `pod.Spec.HostUsers` is false
	* spec.initContainers[0].volumeDevices: Forbidden: when `pod.Spec.HostUsers` is false
	* spec.containers[0].volumeDevices: Forbidden: when `pod.Spec.HostUsers` is false

Note that if a pod is already created with volumeDevices and userns,
then we allow modifications to that object.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-07-28 16:54:08 +02:00
Kubernetes Prow Robot
3fd1251165 Merge pull request #131089 from KevinTMtz/pod-level-hugepage-cgroups
[PodLevelResources] Propagate Pod level hugepage cgroup to containers
2025-07-24 19:08:26 -07:00
Kevin Torres
9f5b09eb7b Unit test pod level hugepage Default and Validation logic 2025-07-24 21:29:04 +00:00
Kevin Torres
845e94d370 Validation logic and Defaulting update for pod level hugepages
The hugepage aggregated container limits cannot be greater than pod-level limits.

This was already enforced with the defaulted requests from the specfied
limits, however it did not make it clear about both hugepage requests and limits.
2025-07-24 21:29:01 +00:00
Yuan Wang
af595a44ae Add container restart rules to API 2025-07-24 16:49:52 +00:00
Kubernetes Prow Robot
9adc49ffd4 Merge pull request #133046 from toVersus/reject-windows-in-api-server
[PodLevelResources] Add validation for Windows OS
2025-07-23 19:56:33 -07:00
Kubernetes Prow Robot
6ef2215eb7 Merge pull request #132558 from HirazawaUi/Implement-4762
KEP-4762: Allows setting any FQDN as the pod's hostname
2025-07-23 16:26:27 -07:00
Kubernetes Prow Robot
041974709c Merge pull request #132106 from AndrewSirenko/vac-valid
[KEP-3751] Allow PVC VACName to go from non-nil to nil
2025-07-23 12:52:30 -07:00
Drew Sirenko
f7109ed281 [KEP-3751] Allow PVC VACName to update to nil or empty when status.currentVAC is nil 2025-07-23 10:59:18 -04:00
HirazawaUi
88b7621434 Add validation for the HostnameOverride field. 2025-07-23 22:57:08 +08:00
Anna Song
e2c308aff9 Check OS for PodLevelResources in API server
Reject Pod with PodLevelResources in spec if Pod targets Windows OS.
2025-07-23 07:08:14 +09:00
Bing Hongtao
6f3b6b91f0 KEP-3721: Support for env files (#132626)
* Add FileKeyRef field and struct to the Pod API

* Add the implementation code in the kubelet.

* Add validation code

* Add basic functionality e2e tests

* add codes for drop disabled pod fields

* update go.mod
2025-07-22 13:40:42 -07:00
Taahir Ahmed
4624cb9bb9 Pod Certificates: Basic implementation
* Define feature gate
* Define and serve PodCertificateRequest
* Implement Kubelet projected volume source
* kube-controller-manager GCs PodCertificateRequests
* Add agnhost subcommand that implements a toy signer for testing

Change-Id: Id7ed030d449806410a4fa28aab0f2ce4e01d3b10
2025-07-21 21:49:57 +00:00
Kubernetes Prow Robot
4a80270b30 Merge pull request #133012 from tallclair/mem-lim-decrease
[FG:InPlacePodVerticalScaling] Support reducing memory limits
2025-07-17 17:10:39 -07:00
Kubernetes Prow Robot
99f55ae4ef Merge pull request #132662 from gnufied/bump-recovery-feature-ga
Bump recovery feature ga
2025-07-17 17:10:25 -07:00
Tim Allclair
c7a78185c2 Remove the restriction on memory limit decrease 2025-07-17 13:17:35 -07:00
Kubernetes Prow Robot
190b3cca2b Merge pull request #132212 from astraw99/fix-sts-validation
Add validation of `volumeClaimTemplates` in StatefulSet
2025-07-16 11:04:23 -07:00
astraw99
6e93244532 Add validation of volumeClaimTemplates in StatefulSet 2025-07-16 12:24:35 +08:00
Hemant Kumar
c126870ebc Bump RecoverVolumeExpansionFailure to GA 2025-07-10 12:19:31 -04:00
Kubernetes Prow Robot
b8450dc451 Merge pull request #132806 from PatrickLaabs/132749-toPtr
chore: replacement of toPtr helper functions with ptr packge
2025-07-08 14:33:40 -07:00
colg
c6fef9752c fix: improve the pod level request validation (#132551)
* fix: improve the pod level request validation

The pod level request should be larger than the aggregated container
requests. The fix is to skip those resources not supported at the pod
level for better efficiency.

A minor unit test is also added.

* Align with the limit check section using the pod spec to check
existence.
2025-07-08 13:25:26 -07:00
Kubernetes Prow Robot
9fbd2dae14 Merge pull request #132339 from adrianmoisey/relaxed-validation-for-services-names
KEP-5311 Relaxed validation for Services names
2025-07-08 09:03:26 -07:00
PatrickLaabs
e909e0cf73 chore: replacement of toPtr helper functions with ptr packge 2025-07-08 09:48:56 +02:00
ylink-lfs
d9de37d931 chore: typo invaILd occurrence replacement 2025-07-08 00:08:34 +08:00
Adrian Moisey
37a90b7c24 Add unit test for Service relaxed validation
Test the behaviour of feature gate RelaxedServiceNameValidation.
2025-07-02 12:57:32 +02:00
Adrian Moisey
487eb8a9e4 Allow Service names to be validated with apimachineryvalidation.NameIsDNSLabel
Only validate when feature gate RelaxedServiceNameValidation is enabled.
Also remove name validation on Service updates, as the name is
immutable.

Move ValidateObjectMeta out of ValidateService
Put it into ValidateServiceCreate(), making the code path as such:
```
pkg/registry/core/service/strategy.go
Validate       -> validation.ValidateServiceCreate -> ValidateObjectMeta
                                                   -> ValidateService

ValidateUpdate -> validation.ValidateServiceUpdate -> ValidateObjectMetaUpdate
                                                   -> ValidateService
```

Other resources I checked pass the update objects through
ValidateObjectMeta and ValidateObjectMetaUpdate, so this breaks the
pattern, but it seems to be how the
ValidateObjectMeta/ValidateObjectMetaUpdate functions are designed to
operate.
2025-07-02 12:55:53 +02:00
xiaoweim
8632257c93 Cleanup: Remove redundant detail messages in field.Required 2025-06-26 21:24:43 +00:00
Davanum Srinivas
03afe6471b Add a replacement for cmp.Diff using json+go-difflib
Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-06-16 17:10:42 -04:00
Dan Winship
dacafec88c KEP-3015: PreferSameTrafficDistribution to Beta 2025-06-10 08:46:34 -04:00
Kubernetes Prow Robot
889cd833a2 Merge pull request #131844 from pohly/dra-no-static-pods
DRA node: reject static pods which reference ResourceClaims
2025-05-20 07:07:24 -07:00
Keita Mochizuki
a3097010fa Change the implementation design of matchLabelKeys in PodTopologySpread to be aligned with PodAffinity (#129874)
* Change the implementation design of matchLabelKeys in PodTopologySpread to be aligned with PodAffinity

* fix1
2025-05-07 13:01:15 -07:00
Patrick Ohly
1ec7231f63 DRA node: reject static pods which reference ResourceClaims
If someone gains the ability to create static pods, they might try to use that
ability to run code which gets access to the resources associated with some
existing claim which was previously allocated for some other pod. Such an
attempt already fails because the claim status tracks which pods are allowed to
use the claim, the static pod is not in that list, the node is not authorized
to add it, and the kubelet checks that list before starting the pod in
195803cde5/pkg/kubelet/cm/dra/manager.go (L218-L222).

Even if the pod were started, DRA drivers typically manage node-local resources
which can already be accessed via such an attack without involving DRA. DRA
drivers which manage non-node-local resources have to consider access by a
compromised node as part of their threat model.

Nonetheless, it is better to not accept static pods which reference
ResourceClaims or ResourceClaimTemplates in the first place because there
is no valid use case for it.

This is done at different levels for defense in depth:
- configuration validation in the kubelet
- admission checking of node restrictions
- API validation

Co-authored-by: Jordan Liggitt <liggitt@google.com>

Code changes by Jordan, with one small change (resourceClaims -> resourceclaims).
Unit tests by Patrick.
2025-05-05 14:21:25 +02:00
carlory
88fbccd698 Fix the allocatedResourceStatuses Field name mismatch in PVC status validation 2025-04-09 16:21:38 +08:00
Sreeram
0380f2c41c Validation 2025-03-25 01:58:04 +05:30
Kubernetes Prow Robot
838f3c0852 Merge pull request #130577 from KevinTMtz/pod-level-hugepages
[PodLevelResources] Pod Level Hugepage Resources
2025-03-20 15:34:38 -07:00
Kevin Torres
b9e0d4ad66 Unit tests for pod level hugepage resources 2025-03-20 17:54:39 +00:00
Shingo Omura
eda274ed7e KEP-3619: merge SupplementalGroupsPolicy dedicated validation tests into standard ones 2025-03-20 13:45:22 +09:00
Shingo Omura
64a4e34989 KEP-3619: fix field path in validating ContainerUsers in PodStatusUpdate 2025-03-20 13:45:22 +09:00
Dan Winship
4435ead24a Add PreferSameTrafficDistribution feature gate and associated API. 2025-03-19 08:39:13 -04:00
Itamar Holder
1ae091e718 Add validation for the NodeSwapStatus field
Signed-off-by: Itamar Holder <iholder@redhat.com>
2025-03-16 11:59:29 +02:00
Tim Hockin
1059dbdee1 Declaratively validate minimum value of RC.Spec.MinReadySeconds
# Conflicts:
#	staging/src/k8s.io/api/core/v1/types.go
2025-03-13 21:24:50 -04:00
Tim Hockin
0f4786536f Declaratively validate RC.Spec.Replicas optionality
The existing test run both declarative and manual validation and it
still passes.
2025-03-13 21:24:50 -04:00
Tim Hockin
e08bbf254c Declaratively validate minimum value of RC.Spec.Replicas 2025-03-13 21:23:18 -04:00
Tim Hockin
7315d0a687 Change internal-version RC.Spec.Replicas to a ptr
This is needed to make declaratve validation clean.  Past me thought
this was clever (pointer versioned, non-pointer internal) but it is just
confusing.
2025-03-13 08:47:19 -07:00
Kubernetes Prow Robot
7b6c56e5fb Merge pull request #130135 from saschagrunert/image-volume-beta
[KEP-4639] Graduate image volume sources to beta
2025-03-12 18:03:58 -07:00