Commit graph

1268 commits

Author SHA1 Message Date
carlory
f8e8e55f1d
locked the feature-gate VolumeAttributesClass to default (true) and switch storage version from v1beta1 to v1
Signed-off-by: carlory <baofa.fan@daocloud.io>
2025-12-18 15:59:33 +08:00
yliao
3e34de29c4 fixed the loophole that allows user to get around resource quota set by system admin 2025-12-18 00:56:20 +00:00
Heba
aceb89debc
KEP-5471: Extend tolerations operators (#134665)
* Add numeric operations to tolerations

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* code review feedback

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* add default feature gate

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add integration tests

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add toleration value validation

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add validate options for new operators

Signed-off-by: helayoty <heelayot@microsoft.com>

* Remove log

Signed-off-by: helayoty <heelayot@microsoft.com>

* Update feature gate check

Signed-off-by: helayoty <heelayot@microsoft.com>

* emove IsValidNumericString func

Signed-off-by: helayoty <heelayot@microsoft.com>

* Implement IsDecimalInteger

Signed-off-by: helayoty <heelayot@microsoft.com>

* code review feedback

Signed-off-by: helayoty <heelayot@microsoft.com>

* Add logs to v1/toleration

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
Signed-off-by: helayoty <heelayot@microsoft.com>

* Update integration tests and address code review feedback

Signed-off-by: helayoty <heelayot@microsoft.com>

* Add feature gate to the scheduler framework

Signed-off-by: helayoty <heelayot@microsoft.com>

* Remove extra test

Signed-off-by: helayoty <heelayot@microsoft.com>

* Fix integration test

Signed-off-by: helayoty <heelayot@microsoft.com>

* pass feature gate via TolerationsTolerateTaint

Signed-off-by: helayoty <heelayot@microsoft.com>

---------

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
Signed-off-by: helayoty <heelayot@microsoft.com>
2025-11-10 12:42:54 -08:00
Kubernetes Prow Robot
b869afe68d
Merge pull request #133389 from pravk03/node-capabilities
Introduce node declared features framework
2025-11-06 01:32:54 -08:00
Praveen Krishna
e7a42e8e8e feat(admission): Add NodeDeclaredFeatures admission plugin 2025-11-06 01:21:17 +00:00
yliao
870062df4f adjusts DRA extended resource quota to include devices usages from regular resource claims 2025-11-05 23:24:24 +00:00
Peter Hunt
e8bd3f629d drop UserNamespacesPodSecurityStandards feature gate
this feature gate was meant to be ephemeral, and only was used for guaranteeing a
cluster admin didn't accidentally relax PSA policies before the kubelet would deny a pod
was created if it didn't support user namespaces. As of kube 1.33, the supported apiserver version
skew of n-3 guarantees that all supported kubelets are of 1.30 or later, meaning they do this.

Now, we can unconditionally relax PSA policy if a pod is in a user namespace.

This PR reserves older policies default behavior by never relaxing

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2025-10-31 14:08:21 -04:00
Patrick Ohly
8b6f98b06e DRA: lock to default-on
The core functionality was enabled by default in 1.34 without any issues that
would have suggested turning it off, so now we can lock it to on-by-default.

Tests which cover disabling the feature must use version emulation.
2025-10-24 20:04:20 +02:00
Jordan Liggitt
4b0eeeb618
Make pod-security-admission honor emulation version 2025-09-17 15:32:32 -04:00
Jordan Liggitt
7f4ee652ea
Delete temporary ProbeHostPodSecurityStandards feature gate 2025-09-17 15:23:32 -04:00
Jordan Liggitt
55419eca7a
Plumb effective version into admission initializer 2025-09-17 15:23:31 -04:00
Patrick Ohly
fa1f9d444c apiserver: avoid default toleration seconds data race for all tests
This reverts commit 2e756e7412,
which addressed the data race only for test/integration/apiserver/oidc.
It also occurs for test/integration/controlplane/transformation:

    WARNING: DATA RACE
    Read at 0x000008b9de38 by goroutine 104616:
      k8s.io/kubernetes/plugin/pkg/admission/defaulttolerationseconds.RegisterFlags()
          /home/prow/go/src/k8s.io/kubernetes/plugin/pkg/admission/defaulttolerationseconds/admission.go:42 +0x30
      k8s.io/kubernetes/pkg/kubeapiserver/options.registerAllAdmissionPluginFlags()
          /home/prow/go/src/k8s.io/kubernetes/pkg/kubeapiserver/options/plugins.go:115 +0x64
      k8s.io/kubernetes/pkg/kubeapiserver/options.(*AdmissionOptions).AddFlags()
          /home/prow/go/src/k8s.io/kubernetes/pkg/kubeapiserver/options/admission.go:73 +0x55
      k8s.io/kubernetes/pkg/controlplane/apiserver/options.(*Options).AddFlags()
          /home/prow/go/src/k8s.io/kubernetes/pkg/controlplane/apiserver/options/options.go:154 +0x388
      k8s.io/kubernetes/cmd/kube-apiserver/app/options.(*ServerRunOptions).Flags()
          /home/prow/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/options/options.go:101 +0x73
      k8s.io/kubernetes/cmd/kube-apiserver/app/testing.StartTestServer()
          /home/prow/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/testing/testserver.go:219 +0xb77
      k8s.io/kubernetes/test/integration/controlplane/transformation.newTransformTest()
          /home/prow/go/src/k8s.io/kubernetes/test/integration/controlplane/transformation/transformation_test.go:131 +0x6d0
      k8s.io/kubernetes/test/integration/controlplane/transformation.TestKMSv2Healthz()
          /home/prow/go/src/k8s.io/kubernetes/test/integration/controlplane/transformation/kmsv2_transformation_test.go:874 +0x1c8
      testing.tRunner()
          /usr/local/go/src/testing/testing.go:1792 +0x225
      testing.(*T).Run.gowrap1()
          /usr/local/go/src/testing/testing.go:1851 +0x44

    Previous write at 0x000008b9de38 by goroutine 111926:
      github.com/spf13/pflag.newInt64Value()
          /home/prow/go/src/k8s.io/kubernetes/vendor/github.com/spf13/pflag/int64.go:9 +0x49
      github.com/spf13/pflag.(*FlagSet).Int64Var()
          /home/prow/go/src/k8s.io/kubernetes/vendor/github.com/spf13/pflag/int64.go:41 +0x3d
      k8s.io/kubernetes/plugin/pkg/admission/defaulttolerationseconds.RegisterFlags()
          /home/prow/go/src/k8s.io/kubernetes/plugin/pkg/admission/defaulttolerationseconds/admission.go:42 +0x25
      k8s.io/kubernetes/pkg/kubeapiserver/options.registerAllAdmissionPluginFlags()
          /home/prow/go/src/k8s.io/kubernetes/pkg/kubeapiserver/options/plugins.go:115 +0x64
      k8s.io/kubernetes/pkg/kubeapiserver/options.(*AdmissionOptions).AddFlags()
          /home/prow/go/src/k8s.io/kubernetes/pkg/kubeapiserver/options/admission.go:73 +0x55
      k8s.io/kubernetes/pkg/controlplane/apiserver/options.(*Options).AddFlags()
          /home/prow/go/src/k8s.io/kubernetes/pkg/controlplane/apiserver/options/options.go:154 +0x388
      k8s.io/kubernetes/cmd/kube-apiserver/app/options.(*ServerRunOptions).Flags()
          /home/prow/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/options/options.go:101 +0x73
      k8s.io/kubernetes/cmd/kube-apiserver/app/testing.StartTestServer()
          /home/prow/go/src/k8s.io/kubernetes/cmd/kube-apiserver/app/testing/testserver.go:219 +0xb77
      k8s.io/kubernetes/test/integration/controlplane/transformation.newTransformTest()
          /home/prow/go/src/k8s.io/kubernetes/test/integration/controlplane/transformation/transformation_test.go:131 +0x6d0
      k8s.io/kubernetes/test/integration/controlplane/transformation.TestKMSv2FeatureFlag()
          /home/prow/go/src/k8s.io/kubernetes/test/integration/controlplane/transformation/kmsv2_transformation_test.go:1009 +0x117
      testing.tRunner()
          /usr/local/go/src/testing/testing.go:1792 +0x225
      testing.(*T).Run.gowrap1()
          /usr/local/go/src/testing/testing.go:1851 +0x44

A more general solution is to lock while registering the variables (= write)
and while reading the variables once in InspectFeatureGates.
2025-09-02 21:01:04 +02:00
Sergey Kanzhelev
944b0a4923 do not allow the node to update it's owner reference 2025-08-10 14:38:24 -07:00
yliao
34a64db2c7 extended resource backed by DRA: implementation 2025-07-29 18:55:21 +00:00
Jordan Liggitt
27e1675153
Make PSA host enforcement honor emulation version 2025-07-24 12:36:26 -04:00
Kubernetes Prow Robot
cc674e7470
Merge pull request #128010 from ahmedtd/pod-certificates-types
Pod Certificates: Preliminary implementation of KEP-4317
2025-07-21 19:26:30 -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
558e903fb1
Merge pull request #132462 from munnerz/update-pod-topology-domain
podtopologylabels: update topology.k8s.io->topology.kubernetes.io
2025-07-21 13:06:35 -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
Kubernetes Prow Robot
d5b2a0438d
Merge pull request #132401 from togettoyou/refactor-admission-plugin-flags
Refactor: isolate flag registration to kube-apiserver to eliminate global state
2025-07-15 22:44:29 -07:00
Junhao Zou
ae4a43de6d Refactor: isolate flag registration to kube-apiserver to eliminate global state 2025-07-16 11:01:37 +08:00
Hemant Kumar
c126870ebc Bump RecoverVolumeExpansionFailure to GA 2025-07-10 12:19:31 -04:00
PatrickLaabs
c530b02257 chore: depr. pointer pkg replacement for pkg/security and plugin/pkg 2025-07-08 11:22:07 +02:00
James Munnelly
38bf213271 podtopologylabels: update topology.k8s.io->topology.kubernetes.io 2025-07-03 08:37:23 +01:00
Kubernetes Prow Robot
b7c9333f5c
Merge pull request #131837 from sreeram-venkitesh/static-pod-strict-validation-for-api-object-reference
Deny pod admission for static pods referencing API objects
2025-06-26 12:18:30 -07:00
sreeram-venkitesh
f9a5aec318 Added unit tests 2025-06-25 23:59:44 +05:30
sreeram-venkitesh
5390f75360 Added podutil.HasAPIObjectReference to deny admission for static pods referencing API objects 2025-06-25 23:59:26 +05:30
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
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
Kubernetes Prow Robot
070f0ad3bd
Merge pull request #129970 from mortent/AddResourceV1beta2API
Add resource v1beta2 API
2025-03-26 09:10:47 -07:00
Morten Torkildsen
39507d911f Add resource v1beta2 API 2025-03-26 14:41:09 +00:00
James Munnelly
8cfb9adbf6 overwrite existing labels during pod Binding storage 2025-03-20 22:39:38 +00:00
James Munnelly
01ae1b1b5a remove kubernetes.io/hostname label copying 2025-03-20 20:19:53 +00:00
James Munnelly
934e247030 Remove kubernetes.io/hostname label copying, skip overriding, and support direct spec.nodeName changes. 2025-03-20 20:19:53 +00:00
James Munnelly
6ddabb6ee6 updating to reflect latest KEP design 2025-03-20 20:19:53 +00:00
James Munnelly
5e7e1e7cf1 KEP-4742: Node Topology Labels via Downward API 2025-03-20 20:19:51 +00:00
Penghao
a548688ffe fix: add feature-gate is disabled unit tests 2025-03-15 10:41:10 +08:00
Penghao
0393497468 Add protection finalizer to vac when it is created 2025-03-15 10:41:04 +08:00
carlory
27706a0b54 Add quota support for PVC with VolumeAttributesClass
Signed-off-by: carlory <baofa.fan@daocloud.io>
2025-03-13 13:50:44 +08:00
Anish Ramasekar
b09ca8c2c8
Use SAR to allow dynamic audiences for node audience restriction
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2025-03-07 16:25:14 -06:00
carlory
eb0f003d25 Fix a bug where the ResourceQuota admission plugin does not respect ANY scope change when a resource is being updated. i.e. to set/unset an existing pod's terminationGracePeriodSeconds field. 2025-02-25 10:26:34 +08:00
Anish Ramasekar
62809dd0de
node audience restriction: use csi translator to convert intree inline_vol/pv to csi
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2025-02-06 13:17:16 -06:00
Anish Ramasekar
d6c50c391d
node audience restriction: add unit tests to simulate intree inline_vol/pv to csi failure
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2025-02-06 12:13:34 -06:00
Davanum Srinivas
4e05bc20db
Linter to ensure go-cmp/cmp is used ONLY in tests
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-01-24 20:49:14 -05:00
Patrick Ohly
8a908e0c0b remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".
2024-12-02 16:59:34 +01:00
ndixita
28dea49c04 Limit Range changes to validate against Pod Level Resources 2024-11-08 03:00:54 +00:00
Anish Ramasekar
e93d5d5425
Enforce sa token node audience restriction when ServiceAccountNodeAudienceRestriction=true
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2024-11-06 09:51:40 -08:00
Anish Shah
832d7f7dc2 apply feedback 2024-11-06 01:33:15 +00:00
Anish Shah
dc3c4ed559 pod resize support in LimitRanger admission plugin 2024-11-06 01:33:15 +00:00
Tim Allclair
dc45ae38c6 Clarify limit ranger use of status resources 2024-11-05 09:21:22 -08:00