Commit Graph

175 Commits

Author SHA1 Message Date
Gunju Kim
0bee0bcaa7 Promote SidecarContainers feature to GA 2025-02-02 17:45:36 +09:00
Tim Allclair
8342d39956 Equate CPU limits below the minimum effective limit (10m) 2024-11-12 17:23:17 -08:00
Tim Allclair
25cf2a2aac Allow adding limits 2024-11-11 12:04:36 -08:00
Tim Allclair
5a3a40cd19 Handle resize edge cases around min CPU shares 2024-11-07 17:02:25 -08:00
zhifei92
bed96b4eb6 fix: fix the issue of losing the pending phase after a node restart. 2024-11-07 21:10:11 +08:00
Tim Allclair
d37634a930 Fixup linting 2024-11-01 14:02:58 -07:00
Tim Allclair
32e6eac753 Fix clearing pod resize status 2024-11-01 14:02:58 -07:00
Tim Allclair
61c1beeda2 Always set status Resources, default to allocated 2024-11-01 14:02:58 -07:00
Tim Allclair
0f0e27d226 Move container status AllocatedResources behind a separate feature gate 2024-11-01 14:02:58 -07:00
Kubernetes Prow Robot
d67e6545b1 Merge pull request #124227 from iholder101/in-pod-vertical-scaling/extended-resources
[FG:InPlacePodVerticalScaling] Add extended resources to ContainerStatuses[i].Resources
2024-10-17 01:39:03 +01:00
Matthieu MOREL
f736cca0e5 fix: enable expected-actual rule from testifylint in module k8s.io/kubernetes
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-27 07:56:31 +02:00
Itamar Holder
772cdfc28c unit test: Add limits and request processing for storage resources
Signed-off-by: Itamar Holder <iholder@redhat.com>
2024-08-28 16:27:04 +03:00
Itamar Holder
47207f9aad unit test: Add extended resources to ContainerStatuses[i].Resources
Signed-off-by: Itamar Holder <iholder@redhat.com>
2024-08-28 15:36:56 +03:00
Kubernetes Prow Robot
2d4514e169 Merge pull request #125802 from mmorel-35/testifylint/len+empty
fix: enable empty and len rules from testifylint on pkg and staging package
2024-07-11 23:12:06 -07:00
Matthieu MOREL
f014b754fb fix: enable empty and len rules from testifylint on pkg package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
2024-07-06 23:15:43 +00:00
Michal Wozniak
bf0c9885a4 Graduate PodDisruptionConditions to stable 2024-06-28 16:36:51 +02:00
Kubernetes Prow Robot
009a291573 Merge pull request #124677 from HirazawaUi/add-const-ContainerStatusUnknown
kubelet: Use constant replace same value variables of the ContainerStateTerminated Reason field
2024-06-06 17:05:23 -07:00
Shingo Omura
552fd7e850 KEP-3619: Fine-grained SupplementalGroups control (#117842)
* Add `Linux{Sandbox,Container}SecurityContext.SupplementalGroupsPolicy` and `ContainerStatus.user` in cri-api

* Add `PodSecurityContext.SupplementalGroupsPolicy`, `ContainerStatus.User` and its featuregate

* Implement DropDisabledPodFields for PodSecurityContext.SupplementalGroupsPolicy and ContainerStatus.User fields

* Implement kubelet so to wire between SecurityContext.SupplementalGroupsPolicy/ContainerStatus.User and cri-api in kubelet

* Clarify `SupplementalGroupsPolicy` is an OS depdendent field.

* Make `ContainerStatus.User` is initially attached user identity to the first process in the ContainerStatus

It is because, the process identity can be dynamic if the initially attached identity
has enough privilege calling setuid/setgid/setgroups syscalls in Linux.

* Rewording suggestion applied

* Add TODO comment for updating SupplementalGroupsPolicy default value in v1.34

* Added validations for SupplementalGroupsPolicy and ContainerUser

* No need featuregate check in validation when adding new field with no default value

* fix typo: identitiy -> identity
2024-05-29 15:40:29 -07:00
HirazawaUi
7a4531c5ba add ContainerStatusUnknown constant 2024-05-03 00:27:19 +08:00
Marek Siarkowicz
3ee8178768 Cleanup defer from SetFeatureGateDuringTest function call 2024-04-24 20:25:29 +02:00
Akihiro Suda
c7f52b34f3 kubelet: KEP-3857: Recursive Read-only (RRO) mounts
See <https://kep.k8s.io/3857>.

An example manifest:
```yaml
apiVersion: v1
kind: Pod
metadata:
  name: rro
spec:
  volumes:
    - name: mnt
      hostPath:
        # tmpfs is mounted on /mnt/tmpfs
        path: /mnt
  containers:
    - name: busybox
      image: busybox
      args: ["sleep", "infinity"]
      volumeMounts:
        # /mnt-rro/tmpfs is not writable
        - name: mnt
          mountPath: /mnt-rro
          readOnly: true
          mountPropagation: None
          recursiveReadOnly: IfPossible
        # /mnt-ro/tmpfs is writable
        - name: mnt
          mountPath: /mnt-ro
          readOnly: true
        # /mnt-rw/tmpfs is writable
        - name: mnt
          mountPath: /mnt-rw
```

Requirements:
- Feature gate "RecursiveReadOnlyMounts" to be enabled
- Linux kernel >= 5.12
- runc >= 1.1

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-03-10 03:00:59 +09:00
Kubernetes Prow Robot
87f9b3891e Merge pull request #123385 from HirazawaUi/allow-special-characters
Allow almost all printable ASCII characters in environment variables
2024-03-05 17:31:06 -08:00
HirazawaUi
fa3c101439 relax validation pod envfrom 2024-03-05 17:09:15 +08:00
Kubernetes Prow Robot
4ed7f6b4c4 Merge pull request #123583 from saschagrunert/image-id-container-status
Add `image_id` to CRI `ContainerStatus` message
2024-03-04 11:23:41 -08:00
Giuseppe Scrivano
87a057d417 KEP-127: kubelet: honor kubelet user mappings
allow to specify what IDs must be used by the kubelet to create user
namespaces.

If no additional UIDs/GIDs are not allocated to the "kubelet" user,
then the kubelet assumes it can use any ID on the system.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-03-02 12:15:39 +01:00
Sascha Grunert
e38531e9a2 Add image_id to CRI ContainerStatus message
There is a conversion function `ConvertPodStatusToRunningPod`, which
can override the `Container.ImageID` into a digested reference from the
`ContainerStatus` CRI RPC, which gets mapped from the `image_ref`:

411c29c39f/pkg/kubelet/container/helpers.go (L259-L292)

To avoid that failure case, we now introduce the same `image_id` into
the container status and let runtimes separate the fields.

We also add a note that the mapping from the digested reference of the
CRI to the Kubernetes Pod API `ImageID` field is intentional and should
not change.

Follow-up on: https://github.com/kubernetes/kubernetes/pull/123508

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-02-29 12:41:55 +01:00
Shiming Zhang
d303cec118 Update test 2024-02-29 11:48:18 +08:00
Kubernetes Prow Robot
375e9ee7c4 Merge pull request #120145 from LingyanYin/inplace_vpa_inprogress_custom_resource_fix
fix inplace VPA stuck in InProgress when custom resources are specified
2023-11-01 09:59:32 +01:00
Kevin Hannon
c94240e2e2 move kubelet constant for podreadytostart to staging 2023-10-12 11:18:11 -04:00
Lingyan Yin
f47661e1b7 fix inplace VPA stuck in InProgress when custom resources are specified
added unit tests

Co-authored-by: Shengjie Xue <3150104939@zju.edu.cn>
Co-authored-by: Zewei Ding <horace.d@outlook.com>
Co-authored-by: Jiaxin Shan <seedjeffwan@gmail.com>
2023-09-06 10:17:39 -07:00
Shiming Zhang
335d905ce9 Downward API support for status.hostIPs 2023-07-14 09:35:30 +08:00
Shiming Zhang
e6bdd224c1 Add HostIPs for kubelet 2023-07-14 09:35:30 +08:00
Kubernetes Prow Robot
1e0b4c84cf Merge pull request #116879 from lzhecheng/fix-generateAPIPodStatus-dualstack
[Dual-stack] Fix generateAPIPodStatus() of kubelet handling Secondary IP
2023-07-07 20:37:04 -07:00
Gunju Kim
b94fa250c2 Sidecar: Implement lifecycle of the restartable init container
- Implement `computeInitContainerActions` to sets the actions for the
  init containers, including those with `RestartPolicyAlways`.
- Allow StartupProbe on the restartable init containers.
- Update PodPhase considering the restartable init containers.
- Update PodInitialized status and status manager considering the
  restartable init containers.

Co-authored-by: Matthias Bertschy <matthias.bertschy@gmail.com>
2023-07-08 07:26:12 +09:00
Zhecheng Li
985cf718a4 [Dual-stack] Fix generateAPIPodStatus() of kubelet handling Secondary IP
hostIPs order may not be be consistent. If secondary IP is before
primary one, current logic adds primary IP twice into PodIPs, which
leads to error: "may specify no more than one IP for each IP family".
In this case, the second IP shouldn't be added.

Co-authored-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2023-07-03 06:47:15 +00:00
Kubernetes Prow Robot
c3c731890c Merge pull request #117927 from kaisoz/add-FailedToRetrieveImagePullSecret-event
Log a warning if a ImagePullSecrets does not exist
2023-06-28 11:14:31 -07:00
Kubernetes Prow Robot
18d05b646d Merge pull request #117702 from kannon92/pod-ready-to-start-rename
feat: rename PodHasNetwork to PodReadyToStartContainers
2023-06-11 18:59:48 -07:00
Sascha Grunert
db9fcfeed2 Move cri/streaming to k8s.io/kubelet staging repository
Container runtimes like CRI-O and containerd reuse the code by copying
it from Kubernetes. To have a single source of truth for the streaming
server we now move the already isolated implementation to the
k8s.io/kubelet staging repository. This way runtimes can re-use the code
without copying the parts.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2023-06-05 08:08:18 +02:00
Tomas Tormo
a10ff53d8e Reword the event message to read better for a single secret
Co-authored-by: Steven E. Harris <seh@panix.com>
2023-05-18 13:47:49 +00:00
Tomas Tormo
5a75a03a77 Improve warning message
Co-authored-by: Steven E. Harris <seh@panix.com>
2023-05-17 18:50:54 +00:00
Tomas Tormo
123845da88 Log a warning if a ImagePullSecrets does not exist 2023-05-11 09:33:14 +00:00
kannon92
5f489a3327 feat: rename PodHasNetwork to PodReadyToStartContainers 2023-05-02 19:52:23 +00:00
Tim Hockin
bc302fa414 Replace uses of ObjectReflectDiff with cmp.Diff
ObjectReflectDiff is already a shim over cmp.Diff, so no actual output
or behavior changes
2023-04-12 08:48:03 -07:00
Kubernetes Prow Robot
74ad7c397d Merge pull request #116723 from SergeyKanzhelev/ExperimentalHostUserNamespaceDefaulting
deprecate ExperimentalHostUserNamespaceDefaulting
2023-04-11 21:16:57 -07:00
Kubernetes Prow Robot
036807ae35 Merge pull request #116995 from smarterclayton/pending_update
kubelet: Ensure pods that have not started track a pendingUpdate
2023-04-11 19:17:37 -07:00
Kubernetes Prow Robot
d48c883372 Merge pull request #116690 from smarterclayton/handle_twice
kubelet: HandlePodCleanups takes an extra sync to restart pods
2023-04-11 18:19:23 -07:00
Clayton Coleman
ed48dcd2d7 kubelet: Ensure pods that have not started track a pendingUpdate
A pod that cannot be started yet (due to static pod fullname
exclusion when UIDs are reused) must be accounted for in the
pod worker since it is considered to have been admitted and will
eventually start.

Due to a bug we accidentally cleared pendingUpdate for pods that
cannot start yet which means we can't report the right metric to
users in kubelet_working_pods and in theory we might fail to start
the pod in the future (although we currently have not observed
that in tests that should catch such an error). Describe, implement,
and test the invariant that when startPodSync returns in every path
that either activeUpdate OR pendingUpdate is set on the status, but
never both, and is only nil when the pod can never start.

This bug was detected by a "programmer error" assertion we added
on metrics that were not being reported, suggesting that we should
be more aggressive on using log assertions and automating detection
in tests.
2023-03-29 15:29:59 -04:00
Sergey Kanzhelev
eb60dce33b deprecate ExperimentalHostUserNamespaceDefaulting 2023-03-17 22:07:25 +00:00
Clayton Coleman
d25572c389 kubelet: HandlePodCleanups takes an extra sync to restart pods
HandlePodCleanups is responsible for restarting pods that are no
longer running (usually due to delete and recreation with the same
UID in quick succession). We have to filter the list of pods to
restart from podManager to get the list of admitted pods, which
uses filterOutInactivePods on the kubelet. That method excludes
pods the pod worker has already terminated. Since a restarted
pod will be in the terminated state before HandlePodCleanups
calls SyncKnownPods, we have to call filterOutInactivePods after
SyncKnownPods, otherwise the to-be-restarted pod is ignored and
we have to wait for the next houskeeping cycle to restart it.

Since static pods are often critical system components, this
extra 2s wait is undesirable and we should restart as soon as
we can. Add a failing test that passes after we move the filter
call after SyncKnownPods.
2023-03-16 15:18:44 -06:00
Michal Wozniak
3d68f362c3 Give terminal phase correctly to all pods that will not be restarted 2023-03-16 21:25:29 +01:00