Skip to content

Instantly share code, notes, and snippets.

@egernst
Last active August 6, 2019 16:55
Show Gist options
  • Save egernst/737a9027db6ca2f5008372252634339c to your computer and use it in GitHub Desktop.
Save egernst/737a9027db6ca2f5008372252634339c to your computer and use it in GitHub Desktop.
kubernetes eviction study

Eviction handling

Kubelet manages eviction, which is carried out at pod-granularity on a node. The kubelet ranks Pods for eviction first by whether or not their usage of the starved resource exceeds requests, then by Priority, and then by the consumption of the starved compute resource relative to the Pods’ scheduling requests.

Of note for Pod Overhead is the comparision of requested resources versus utilization of particular resource. The sum of requests is compared against the sum of container utilization, for each pod.

Eviction is handled by an Evicition Manager.

NewManager is passed a summaryProvider, which is a part of the StatsProvider created for Kubelet. In our case, it should be a New CRI Stats Provider (see ~/go/src/k8s.io/kubernetes/pkg/kubelet/server/stats/summary.go for analyzer?)

Stats gathering:

A stats_provider is ultimately used to grab stats:

 func (p *criStatsProvider) ListPodCPUAndMemoryStats() ([]statsapi.PodStats, error) {

Or, see the code

Problem with current eviction handling: no concept of pod overhead

As is, we are only working at the container level to gather details about the pod behavior. This doesn't take into account any potential resource utilization by the sandbox, the pod, itself. This is non-negligible, especially for sandboxed runtimes, like Kata Containers.

Solution

For eviction purposes, utilization statistics should be measured at the pod cgroup, not as a sum of container statistics.

Questions

  • Currently pretty tied into existing stats provider
  • ok to modify container level stats?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment