Commit Graph

94 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
9053b5dc2c
Merge pull request #116119 from vinaykul/restart-free-pod-vertical-scaling-fixes
Restructure resize policy naming and set default resize policy values
2023-03-14 19:26:42 -07:00
vinay kulkarni
9a805db010 Set default resize policy only for specified resource types, rename RestartNotRequired -> NotRequired 2023-03-12 23:46:40 +00:00
vinay kulkarni
8b23497ae7 Restructure naming of resource resize restart policy 2023-03-12 23:11:32 +00:00
Vadim Rutkovsky
556d774945 kubelet: create top-level traces for pod sync and GC
This starts new top level OpenTelemetry spans every time syncPod or image / container GC is invoked
2023-03-11 10:42:14 +01:00
Kubernetes Prow Robot
10802e9be1
Merge pull request #114498 from runzhliu/patch-2
Update kuberuntime_manager_test.go
2023-03-09 21:33:52 -08:00
Chen Wang
7db339dba2 This commit contains the following:
1. Scheduler bug-fix + scheduler-focussed E2E tests
2. Add cgroup v2 support for in-place pod resize
3. Enable full E2E pod resize test for containerd>=1.6.9 and EventedPLEG related changes.

Co-Authored-By: Vinay Kulkarni <vskibum@gmail.com>
2023-02-24 18:21:21 +00:00
Vinay Kulkarni
f2bd94a0de In-place Pod Vertical Scaling - core implementation
1. Core Kubelet changes to implement In-place Pod Vertical Scaling.
2. E2E tests for In-place Pod Vertical Scaling.
3. Refactor kubelet code and add missing tests (Derek's kubelet review)
4. Add a new hash over container fields without Resources field to allow feature gate toggling without restarting containers not using the feature.
5. Fix corner-case where resize A->B->A gets ignored
6. Add cgroup v2 support to pod resize E2E test.
KEP: /enhancements/keps/sig-node/1287-in-place-update-pod-resources

Co-authored-by: Chen Wang <Chen.Wang1@ibm.com>
2023-02-24 18:21:21 +00:00
runzhliu
b3aefb7ba5
Update kuberuntime_manager_test.go
Typo fix.
2022-12-15 08:43:01 +08:00
David Ashpole
64af1adace
Second attempt: Plumb context to Kubelet CRI calls (#113591)
* plumb context from CRI calls through kubelet

* clean up extra timeouts

* try fixing incorrectly cancelled context
2022-11-05 06:02:13 -07:00
Antonio Ojea
9c2b333925 Revert "plumb context from CRI calls through kubelet"
This reverts commit f43b4f1b95.
2022-11-02 13:37:23 +00:00
David Ashpole
f43b4f1b95
plumb context from CRI calls through kubelet 2022-10-28 02:55:28 +00:00
Sascha Grunert
b296f82c69
Sort kubelet pods by their creation time
There is a corner case when blocking Pod termination via a lifecycle
preStop hook, for example by using this StateFulSet:

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: ubi
  serviceName: "ubi"
  replicas: 1
  template:
    metadata:
      labels:
        app: ubi
    spec:
      terminationGracePeriodSeconds: 1000
      containers:
      - name: ubi
        image: ubuntu:22.04
        command: ['sh', '-c', 'echo The app is running! && sleep 360000']
        ports:
        - containerPort: 80
          name: web
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - 'echo aaa; trap : TERM INT; sleep infinity & wait'
```

After creation, downscaling, forced deletion and upscaling of the
replica like this:

```
> kubectl apply -f sts.yml
> kubectl scale sts web --replicas=0
> kubectl delete pod web-0 --grace-period=0 --force
> kubectl scale sts web --replicas=1
```

We will end up having two pods running by the container runtime, while
the API only reports one:

```
> kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
web-0   1/1     Running   0          92s
```

```
> sudo crictl pods
POD ID              CREATED              STATE     NAME     NAMESPACE     ATTEMPT     RUNTIME
e05bb7dbb7e44       12 minutes ago       Ready     web-0    default       0           (default)
d90088614c73b       12 minutes ago       Ready     web-0    default       0           (default)
```

When now running `kubectl exec -it web-0 -- ps -ef`, there is a random chance that we hit the wrong
container reporting the lifecycle command `/bin/sh -c echo aaa; trap : TERM INT; sleep infinity & wait`.

This is caused by the container lookup via its name (and no podUID) at:
02109414e8/pkg/kubelet/kubelet_pods.go (L1905-L1914)

And more specifiy by the conversion of the pod result map to a slice in `GetPods`:
02109414e8/pkg/kubelet/kuberuntime/kuberuntime_manager.go (L407-L411)

We now solve that unexpected behavior by tracking the creation time of
the pod and sorting the result based on that. This will cause to always
match the most recently created pod.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-10-13 16:32:44 +02:00
Lee Verberne
d238e67ba6 Remove EphemeralContainers feature-gate checks 2022-07-26 02:55:30 +02:00
KeZhang
3946d99904 Ignore container notfound error while getPodstatuses 2022-02-16 08:55:19 +08:00
Sascha Grunert
de37b9d293
Make CRI v1 the default and allow a fallback to v1alpha2
This patch makes the CRI `v1` API the new project-wide default version.
To allow backwards compatibility, a fallback to `v1alpha2` has been added
as well. This fallback can either used by automatically determined by
the kubelet.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2021-11-17 11:05:05 -08:00
Mengjiao Liu
275d832ce2 Upgrade preparation to verify sysctl values containing forward slashes by regex 2021-11-04 11:49:56 +08:00
Kubernetes Prow Robot
dab6f6a43d
Merge pull request #102344 from smarterclayton/keep_pod_worker
Prevent Kubelet from incorrectly interpreting "not yet started" pods as "ready to terminate pods" by unifying responsibility for pod lifecycle into pod worker
2021-07-08 16:48:53 -07:00
Li Bo
c3d9b10ca8 feature: support Memory QoS for cgroups v2 2021-07-08 09:26:46 +08:00
Clayton Coleman
3eadd1a9ea
Keep pod worker running until pod is truly complete
A number of race conditions exist when pods are terminated early in
their lifecycle because components in the kubelet need to know "no
running containers" or "containers can't be started from now on" but
were relying on outdated state.

Only the pod worker knows whether containers are being started for
a given pod, which is required to know when a pod is "terminated"
(no running containers, none coming). Move that responsibility and
podKiller function into the pod workers, and have everything that
was killing the pod go into the UpdatePod loop. Split syncPod into
three phases - setup, terminate containers, and cleanup pod - and
have transitions between those methods be visible to other
components. After this change, to kill a pod you tell the pod worker
to UpdatePod({UpdateType: SyncPodKill, Pod: pod}).

Several places in the kubelet were incorrect about whether they
were handling terminating (should stop running, might have
containers) or terminated (no running containers) pods. The pod worker
exposes methods that allow other loops to know when to set up or tear
down resources based on the state of the pod - these methods remove
the possibility of race conditions by ensuring a single component is
responsible for knowing each pod's allowed state and other components
simply delegate to checking whether they are in the window by UID.

Removing containers now no longer blocks final pod deletion in the
API server and are handled as background cleanup. Node shutdown
no longer marks pods as failed as they can be restarted in the
next step.

See https://docs.google.com/document/d/1Pic5TPntdJnYfIpBeZndDelM-AbS4FN9H2GTLFhoJ04/edit# for details
2021-07-06 15:55:22 -04:00
Elana Hashman
9fb6e712ff
Override terminationLivenessGracePeriod for probes 2021-03-11 14:38:03 -08:00
Ryan Phillips
f989adaa18 kubelet: fix create create sandbox delete pod race 2021-02-18 11:22:12 -06:00
Sergey Kanzhelev
4c9e96c238 Revert "Merge pull request #92817 from kmala/kubelet"
This reverts commit 88512be213, reversing
changes made to c3b888f647.
2021-01-12 22:27:22 +00:00
Kubernetes Prow Robot
88512be213
Merge pull request #92817 from kmala/kubelet
Check for sandboxes before deleting the pod from apiserver
2020-09-10 07:27:45 -07:00
Keerthan Reddy,Mala
872859b422 correct the sandboxId attribute in unit tests 2020-07-22 11:54:58 -07:00
Keerthan Reddy,Mala
90cc954eed add sandbox deletor to delete sandboxes on pod delete event 2020-07-22 11:54:58 -07:00
Quan Tian
b2b082f54f Don't create a new sandbox for pod with RestartPolicyOnFailure if all containers succeeded
The kubelet would attempt to create a new sandbox for a pod whose
RestartPolicy is OnFailure even after all container succeeded. It caused
unnecessary CRI and CNI calls, confusing logs and conflicts between the
routine that creates the new sandbox and the routine that kills the Pod.

This patch checks the containers to start and stops creating sandbox if
no container is supposed to start.
2020-07-07 22:49:48 +08:00
Sergey Kanzhelev
ee53488f19 fix golint issues in pkg/kubelet/container 2020-06-19 15:48:08 +00:00
Shihang Zhang
b56da85a77 sync api/v1/pod/util with api/pod/util and remove DefaultContainers 2020-03-24 16:42:32 -07:00
Lee Verberne
9a6d50cb2a Add namespace targeting to the kubelet 2020-01-30 15:31:43 +01:00
Kubernetes Prow Robot
4e45328e65
Merge pull request #83123 from aramase/dualstack-downward-api
Dualstack downward api
2019-11-14 22:13:42 -08:00
Kubernetes Prow Robot
a08b09d52f
Merge pull request #84279 from matthyx/kuberuntime-startupprobe
Add startupProbe result handling to kuberuntime
2019-11-13 13:01:53 -08:00
Matthias Bertschy
66595d54a0 Add startupProbe result handling to kuberuntime 2019-11-13 08:12:54 +01:00
yuxiaobo
81e9f21f83 Correct spelling mistakes
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-11-06 20:25:19 +08:00
Anish Ramasekar
af4d18ccf9
add status.podIPs in downward api
add host file write for podIPs

update tests

remove import alias

update type check

update type check

remove import alias

update open api spec

add tests

update test

add tests

address review comments

update imports

remove todo and import alias
2019-10-25 09:18:49 -07:00
Lee Verberne
ea212d5d49 Add support for ephemeral containers to the kubelet 2019-07-24 16:24:26 +00:00
Khaled Henidak(Kal)
dba434c4ba kubenet for ipv6 dualstack 2019-07-02 22:26:25 +00:00
Yu-Ju Hong
3fac48f86a kubelet: retry pod sandbox creation when containers were never created
If kubelet never gets past sandbox creation (i.e., never attempted to
create containers for a pod), it should retry the sandbox creation on
failure, regardless of the restart policy of the pod.
2019-06-26 18:19:27 -07:00
Davanum Srinivas
33081c1f07
New staging repository for cri-api
Change-Id: I2160b0b0ec4b9870a2d4452b428e395bbe12afbb
2019-03-26 18:21:04 -04:00
Lantao Liu
f14c6c95d6 New pod log directory /var/log/pods/NAMESPACE_NAME_UID.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-03-08 16:42:14 -08:00
Lubomir I. Ivanov
e29c6e1b38 go-1.12: fix 'go vet' failures 2019-03-01 18:48:17 +02:00
Kubernetes Prow Robot
6a9902deee
Merge pull request #73802 from Random-Liu/handle-unknown-state
Stop container in unknown state before recreate or remove.
2019-02-14 15:50:12 -08:00
Lantao Liu
de8ee94d14 Stop container in unknown state before recreate or remove. 2019-02-14 02:31:17 -08:00
Lantao Liu
1a92e218e0 Remove unused function from the legacy runtime interface.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-02-07 16:57:19 -08:00
Kubernetes Prow Robot
53a7601e6a
Merge pull request #64648 from dcbw/remove-unused-param
kubelet: remove unused parameter from runtime's SyncPod()
2019-02-01 09:03:45 -08:00
Lee Verberne
f6084f7eab Remove container type from kubelet runtime labels
We've changed the Ephemeral Containers API, and container type will no
longer be required. Since this is the only feature using it, remove it.

This reverts commit ba6f31a6c6.
2018-12-21 15:47:47 +01:00
k8s-ci-robot
6c1688712d
Merge pull request #68181 from Pingan2017/golint
fix golint failures - some packages under /pkg/kubelet
2018-09-28 01:56:26 -07:00
Derek Carr
5f473bc8e1 Kubelet should not create a new pod sandbox if all containers are done 2018-09-27 14:21:50 -04:00
Pingan2017
158552ff35 fix golint failures - /pkg/kubelet/images 2018-09-17 10:52:25 +08:00
Dan Williams
931f6718b0 kubelet: remove unused parameter from runtime's SyncPod() 2018-06-01 21:55:40 -05:00
Jan Safranek
5110db5087 Lock subPath volumes
Users must not be allowed to step outside the volume with subPath.
Therefore the final subPath directory must be "locked" somehow
and checked if it's inside volume.

On Windows, we lock the directories. On Linux, we bind-mount the final
subPath into /var/lib/kubelet/pods/<uid>/volume-subpaths/<container name>/<subPathName>,
it can't be changed to symlink user once it's bind-mounted.
2018-03-05 09:14:44 +01:00