Commit Graph

40 Commits

Author SHA1 Message Date
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
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
1c95d63df0
Migrate kuberuntime_gc.go to structured logs 2021-03-15 12:39:35 -07:00
Elana Hashman
9fb6e712ff
Override terminationLivenessGracePeriod for probes 2021-03-11 14:38:03 -08: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
Keerthan Reddy,Mala
90cc954eed add sandbox deletor to delete sandboxes on pod delete event 2020-07-22 11:54:58 -07:00
Sergey Kanzhelev
ee53488f19 fix golint issues in pkg/kubelet/container 2020-06-19 15:48:08 +00:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
Kubernetes Prow Robot
96e13de777
Merge pull request #88980 from tedyu/evict-delay-sorting
Delay sorting of evictUnits slice in kuberuntime_gc
2020-05-14 21:24:58 -07:00
Ted Yu
18e9f33fc6 Remove unhealthy symlink only for dead containers
Signed-off-by: Ted Yu <yuzhihong@gmail.com>
2020-04-21 12:30:51 -07:00
zyu
78e2668539 Delay sorting of evictUnits slice in kuberuntime_gc
Signed-off-by: zyu <yuzhihong@gmail.com>
2020-03-09 12:24:42 -07:00
Ted Yu
58dfe186d8 Call getKubeletSandboxes first in containerGC#evictSandboxes 2019-05-26 14:40:11 -07:00
Kubernetes Prow Robot
dc1ff116dc
Merge pull request #74220 from tedyu/master
Aggregate errors for kube runtime GC
2019-04-04 17:47:19 -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
Ted Yu
dae6950f04 Aggregate errors for kube runtime GC
Signed-off-by: Ted Yu <yute@vmware.com>
2019-02-18 13:29:22 -08:00
Lantao Liu
de8ee94d14 Stop container in unknown state before recreate or remove. 2019-02-14 02:31:17 -08:00
Davanum Srinivas
954996e231
Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135
2018-11-10 07:50:31 -05:00
Pingan2017
158552ff35 fix golint failures - /pkg/kubelet/images 2018-09-17 10:52:25 +08:00
Lee Verberne
e10042d22f Increment CRI version from v1alpha1 to v1alpha2
This also incorporates the version string into the package name so
that incompatibile versions will fail to connect.

Arbitrary choices:
- The proto3 package name is runtime.v1alpha2. The proto compiler
  normally translates this to a go package of "runtime_v1alpha2", but
  I renamed it to "v1alpha2" for consistency with existing packages.
- kubelet/apis/cri is used as "internalapi". I left it alone and put the
  public "runtimeapi" in kubelet/apis/cri/runtime.
2018-02-07 09:06:26 +01:00
David Ashpole
4300c75d48 fix #52462. Do not GC exited containers in running pods 2017-09-28 09:37:21 -07:00
FengyunPan
bfc171ccaa Improve codes which checks whether sandbox contains containers
Currently when evictSandboxes() checks whether sandbox contains
containers, it traverses all the containers for every sandbox,
but when cluster has many containres, it wastes a lot of time.
It is better to use sets in this case.
2017-09-18 14:34:34 +08:00
David Ashpole
9ac30e2c28 wait for container cleanup before deletion 2017-09-04 17:38:09 -07:00
Pengfei Ni
22e99504d7 Update CRI references 2017-06-09 10:16:40 +08:00
David Ashpole
889afa5e2d trigger aggressive container garbage collection when under disk pressure 2017-06-03 07:52:36 -07:00
Michael Taufen
cbad320205 Reorganize kubelet tree so apis can be independently versioned 2017-05-12 10:02:33 -07:00
Pengfei Ni
691f0482fb Fix sandbox garbage collection.
Sandboxes are garbage collected only when they are containing no containers at
all and not the latest sandbox if it is belonging to an existing pod.
2017-05-03 14:29:16 +08:00
Yu-Ju Hong
1095652cb8 Add more logs to help debugging 2017-03-08 12:27:49 -08:00
Pengfei Ni
53c20e3630 kubelet/kuberuntime: update cri to protobuf v3 2017-01-20 09:55:56 +08:00
deads2k
6a4d5cd7cc start the apimachinery repo 2017-01-11 09:09:48 -05:00
Pengfei Ni
f584ed4398 Fix package aliases to follow golang convention 2016-11-30 15:40:50 +08:00
Yu-Ju Hong
faae51a14a CRI: stop sandbox before removing it
Stopping a sandbox includes reclaiming the network resources.  By always
stopping the sandbox before removing it, we reduce the possibility of leaking
resources in some corner cases.
2016-11-03 14:11:19 -07:00
Yu-Ju Hong
8a6285d844 CRI: Rename container/sandbox states
The enum constants are not namespaced. The shorter, unspecifc names are likely
to cause naming conflicts in the future.

Also replace "SandBox" with "Sandbox" in the API.
2016-11-01 13:18:21 -07:00
Random-Liu
0655ae56bb Add pod log garbage collection unit test. 2016-10-24 00:03:34 -07:00
Random Liu
e87fa5e0ff * Refactor kuberuntime unit test
* Add gc unit test
* Fix init container unit test
2016-10-24 00:03:34 -07:00
Random Liu
fad4672e72 Add legacy container log location support. 2016-10-23 19:08:47 -07:00
Random-Liu
121a91eb12 Symlink docker logs to CRI defined log path. 2016-10-23 19:08:47 -07:00
Random-Liu
08aedca12e Add MinAge for sandbox GC. 2016-10-07 14:10:19 -07:00
Random-Liu
76056a47f9 Change the timestamp unit to nanosecond. 2016-10-07 14:10:19 -07:00
Pengfei Ni
f774a68d52 Kubelet: add garbage collection for new runtime API 2016-09-14 09:09:45 +08:00