Commit Graph

401 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
e6616033cb
Merge pull request #120844 from bzsuni/cleanup/sets/kubelet
[kubelet] Use a generic Set instead of a specified Set
2024-06-14 09:09:17 -07: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
Kubernetes Prow Robot
a8d51f4f05 Use a generic Set instead of a specified Set in kubelet
Signed-off-by: bzsuni <bingzhe.sun@daocloud.io>
2024-06-04 14:25:43 +08: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
Davanum Srinivas
fd06dcd604
Switch hard error to a WARNING for kernel version check
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-05-12 20:23:48 -04:00
Davanum Srinivas
8597b343fa
Enforce the Minimum Kernel Version 6.3 for UserNamespacesSupport feature
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-05-07 16:01:42 -04:00
HirazawaUi
7a4531c5ba add ContainerStatusUnknown constant 2024-05-03 00:27:19 +08:00
Kubernetes Prow Robot
ef2c682635
Merge pull request #122082 from carlory/remove-keep-terminated-pod-volumes
keep-terminated-pod-volumes flag on kubelet is removed
2024-04-17 23:59:54 -07:00
Maksym Pavlenko
be4b7176dc
Fix Abs path validation on Windows (#124084)
* Windows: Consider slash-prefixed paths as absolute

filepath.IsAbs does not consider "/" or "\" as absolute paths, even
though files can be addressed as such. [1][2]

Currently, there are some unit tests that are failing on Windows due to
this reason.

[1] https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#traditional-dos-paths
[2] https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#fully-qualified-vs-relative-paths

* Add test to verify IsAbs for windows

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Fix abs path validation on windows

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Skipp path clean check for podLogDir on windows

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Implement IsPathClean to validate path

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Add warn comment for IsAbs

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

---------

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
Co-authored-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2024-04-10 10:13:59 -07:00
Akihiro Suda
8963e73f12
kubelet: fix mixing up runtime classes with runtime handlers
Fix issue 123906

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-03-14 08:14:48 +09:00
Akihiro Suda
4a776f66ec
kubelet: silence "unknown runtime class" errors when unsupported
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-03-14 07:08:42 +09: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
Akihiro Suda
6f12e1d8e5
kubelet: expose containerStatuses.volumeMounts
For KEP-3857: Recursive Read-only (RRO) mounts

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
carlory
b47c73ee26 keep-terminated-pod-volumes flag on kubelet is removed 2024-03-01 18:42:15 +08: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
Giuseppe Scrivano
b2a92406ef
KEP-127: check for runtime handler userns support
block the creation of a pod that requires a user namespace, unless the
runtime handler has support for it.

If the pod requested for a user namespace, and the handler does not
support it then return an error regardless of the feature gate.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-27 12:01:00 +01: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
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
Qian Xiao
0944c00778 Fix some typo in kubelet component source code 2023-08-03 23:56:50 -07:00
Kubernetes Prow Robot
d17f3ba2cf
Merge pull request #119168 from gjkim42/sidecar-allow-probes-and-lifecycle-hooks
Allow all probes and lifecycle for restartable init containers
2023-07-17 18:11:07 -07:00
Gunju Kim
9d6c1030db
Generate containers ready condition including restartable init containers 2023-07-18 08:12:24 +09: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
Michal Wozniak
17013d3960 Review remarks to improve HandlePodCleanups in kubelet 2023-06-22 10:55:39 +02:00
Michal Wozniak
e3ee9b9adc Fix the deletion of rejected pods 2023-06-22 09:18:34 +02: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
Kubernetes Prow Robot
bdbfbffef3
Merge pull request #117371 from smarterclayton/minimal_podmanager
kubelet: Don't reference the pod manager interface directly from components
2023-05-16 14:34:33 -07:00
Kubernetes Prow Robot
03b2e84183
Merge pull request #113209 from luozhiwenn/personal/etc-host
ensure etc-host file permission is 644 whatever umask is
2023-05-16 01:41:35 -07:00
Clayton Coleman
bb568844b6
kubelet: Separate the MirrorClient from the PodManager
The two are not coupled except accidentally. Separate them and
update callsites. This will reduce the scope of PodManager interface
to make exposing the pod worker cleaner.
2023-05-12 12:57:26 -04:00
Clayton Coleman
80b1aca580
kubelet: Remove dispatchWork and inline calls to UpdatePod
The HandlePod* methods are all structurally similar, but accrued
subtle differences. In general the only point for Handle is to
process admission and to update the pod worker with the desired
state of the kubelet's config (so that pod worker can make it
the actual state).

Add a new GetPodAndMirrorPod() method that handles when the config
pod is ambiguous (pod or mirror pod) and inline the structure.
Add comments on questionable additions in the config methods for
future improvement.

Move the metric observation of container count closer to where
pods are actually started (in the pod worker). A future change
can likely move it to syncPod.
2023-05-12 12:57:26 -04:00
Clayton Coleman
e7207c8546
kubelet: Merge orphaned mirror pod names into GetPodsAndMirrorPods
There is only one caller and both sets of data are part of the
resync operation between kubelet's desired state and the actual
state of the pod workers. Reduces the size of the interface so
that it is easier to create another pod manager.
2023-05-12 12:57:26 -04: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
dd7af241c1
Replace diff.ObjectDiff with cmp.Equal
More obvious and cheaper, and ObjectDiff is already written in terms of
cmp.
2023-04-12 08:45:32 -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
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
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