Skip to content
This repository has been archived by the owner on Dec 5, 2017. It is now read-only.

restrict pods to the resource constraints declared in their manifest #68

Closed
jdef opened this issue Nov 9, 2014 · 8 comments
Closed

Comments

@jdef
Copy link

jdef commented Nov 9, 2014

Currently pods can declare cpu and memory constraints but we don't honor them. We should.

The current design maps a single mesos task to a k8s pod, which in reality represents multiple containers. One approach would be to place all pods managed by an executor into its container, growing and shrinking the resource constraints of the executor container on the fly to accommodate the pods that it's in charge of managing. That implies that we can actually control placement of the docker containers (well, their cgroup placement). Currently this is only possible by manually moving the processes from their default docker-determined cgroup to that of the executor.

There is a docker proposal on the table to allow for customizable cgroup placement: moby/moby#8551 (related prototype tooling here: https://github.com/ibuildthecloud/systemd-docker).

Assuming that we could convince docker to honor custom cgroup placement (at container launch time), then we'd also need to convince/hack the kubelet to apply custom placement rules.

@jdef
Copy link
Author

jdef commented Dec 2, 2014

@jdef
Copy link
Author

jdef commented Dec 2, 2014

kubelet doesn't currently offer any public API hooks for interacting with newly launched containers:
https://github.com/GoogleCloudPlatform/kubernetes/blob/b61168835d1ef25d87d75f013b0d1045890c2234/pkg/kubelet/kubelet.go#L442

... although the kubelet does publish events about them, referencing such CT's by handles generated in kubelet.containerRef() (though ref's seem to be evolving). we also need to wait for #88 to get support for these events. it's probably reasonable to assume that we could set up a listener for new-container events and then react by shuffling cgroups around (ala the aforementioned systemd hack).

@jdef
Copy link
Author

jdef commented Dec 19, 2014

xref moby/moby#6791

@jdef
Copy link
Author

jdef commented Mar 19, 2015

custom cgroup parents have landed in docker:

@sushantk
Copy link

sushantk commented Jul 2, 2015

@jdef k8s now supports setting the parent cgroup for the kublet. Does this open the door to apply resource constraints?

@jdef
Copy link
Author

jdef commented Jul 2, 2015

Sure does. It's on our todo list.

On Thu, Jul 2, 2015 at 1:43 PM, sushantk notifications@github.com wrote:

@jdef https://github.com/jdef k8s now supports setting the parent
cgroup for the kublet. Does this open the door to apply resource
constraints?


Reply to this email directly or view it on GitHub
#68 (comment)
.

@sttts
Copy link

sttts commented Jul 14, 2015

There are no pod resource constraints right now in k8s, only by container. Hence, we can – maybe as a first step – easily sum up the values and put the sum into the TaskInfo. The launched docker containers have the container-wise limits applied by the kubelet.

@sttts sttts self-assigned this Jul 16, 2015
@sttts sttts added PTAL and removed WIP labels Jul 16, 2015
sttts added a commit to mesosphere-backup/kubernetes that referenced this issue Jul 30, 2015
This patch

- set limits (0.25 cpu, 64 MB) on containers which are not limited in pod spec
  (these are also passed to the kubelet such that it uses them for the docker
  run limits)
- sums up the container resource limits for cpu and memory inside a pod,
- compares the sums to the offered resources
- puts the sums into the Mesos TaskInfo such that Mesos does the accounting
  for the pod.
- parses the static pod spec and adds up the resources
- sets the executor resources to 0.25 cpu, 64 MB plus the static pod resources
- sets the cgroups in the kubelet for system containers, resource containers
  and docker to the one of the executor that Mesos assigned
- adds scheduler parameters --default-container-cpu-limit and
  --default-container-mem-limit.

The containers themselves are resource limited the Docker resource limit which
the kubelet applies when launching them.

Fixes mesosphere/kubernetes-mesos#68 and mesosphere/kubernetes-mesos#304
@jdef
Copy link
Author

jdef commented Jul 31, 2015

resolved by kubernetes/kubernetes#11230

@jdef jdef closed this as completed Jul 31, 2015
@jdef jdef removed the PTAL label Jul 31, 2015
sttts added a commit to mesosphere-backup/kubernetes that referenced this issue Jul 31, 2015
This patch

- set limits (0.25 cpu, 64 MB) on containers which are not limited in pod spec
  (these are also passed to the kubelet such that it uses them for the docker
  run limits)
- sums up the container resource limits for cpu and memory inside a pod,
- compares the sums to the offered resources
- puts the sums into the Mesos TaskInfo such that Mesos does the accounting
  for the pod.
- parses the static pod spec and adds up the resources
- sets the executor resources to 0.25 cpu, 64 MB plus the static pod resources
- sets the cgroups in the kubelet for system containers, resource containers
  and docker to the one of the executor that Mesos assigned
- adds scheduler parameters --default-container-cpu-limit and
  --default-container-mem-limit.

The containers themselves are resource limited the Docker resource limit which
the kubelet applies when launching them.

Fixes mesosphere/kubernetes-mesos#68 and mesosphere/kubernetes-mesos#304
sttts added a commit to mesosphere-backup/kubernetes that referenced this issue Aug 1, 2015
This patch

- set limits (0.25 cpu, 64 MB) on containers which are not limited in pod spec
  (these are also passed to the kubelet such that it uses them for the docker
  run limits)
- sums up the container resource limits for cpu and memory inside a pod,
- compares the sums to the offered resources
- puts the sums into the Mesos TaskInfo such that Mesos does the accounting
  for the pod.
- parses the static pod spec and adds up the resources
- sets the executor resources to 0.25 cpu, 64 MB plus the static pod resources
- sets the cgroups in the kubelet for system containers, resource containers
  and docker to the one of the executor that Mesos assigned
- adds scheduler parameters --default-container-cpu-limit and
  --default-container-mem-limit.

The containers themselves are resource limited the Docker resource limit which
the kubelet applies when launching them.

Fixes mesosphere/kubernetes-mesos#68 and mesosphere/kubernetes-mesos#304
sttts added a commit to mesosphere-backup/kubernetes that referenced this issue Aug 13, 2015
This patch

- set limits (0.25 cpu, 64 MB) on containers which are not limited in pod spec
  (these are also passed to the kubelet such that it uses them for the docker
  run limits)
- sums up the container resource limits for cpu and memory inside a pod,
- compares the sums to the offered resources
- puts the sums into the Mesos TaskInfo such that Mesos does the accounting
  for the pod.
- parses the static pod spec and adds up the resources
- sets the executor resources to 0.25 cpu, 64 MB plus the static pod resources
- sets the cgroups in the kubelet for system containers, resource containers
  and docker to the one of the executor that Mesos assigned
- adds scheduler parameters --default-container-cpu-limit and
  --default-container-mem-limit.

The containers themselves are resource limited the Docker resource limit which
the kubelet applies when launching them.

Fixes mesosphere/kubernetes-mesos#68 and mesosphere/kubernetes-mesos#304
sttts added a commit to mesosphere-backup/kubernetes that referenced this issue Sep 4, 2015
This patch

- set limits (0.25 cpu, 64 MB) on containers which are not limited in pod spec
  (these are also passed to the kubelet such that it uses them for the docker
  run limits)
- sums up the container resource limits for cpu and memory inside a pod,
- compares the sums to the offered resources
- puts the sums into the Mesos TaskInfo such that Mesos does the accounting
  for the pod.
- parses the static pod spec and adds up the resources
- sets the executor resources to 0.25 cpu, 64 MB plus the static pod resources
- sets the cgroups in the kubelet for system containers, resource containers
  and docker to the one of the executor that Mesos assigned
- adds scheduler parameters --default-container-cpu-limit and
  --default-container-mem-limit.

The containers themselves are resource limited the Docker resource limit which
the kubelet applies when launching them.

Fixes mesosphere/kubernetes-mesos#68 and mesosphere/kubernetes-mesos#304
sttts added a commit to mesosphere-backup/kubernetes that referenced this issue Oct 8, 2015
This patch

- set limits (0.25 cpu, 64 MB) on containers which are not limited in pod spec
  (these are also passed to the kubelet such that it uses them for the docker
  run limits)
- sums up the container resource limits for cpu and memory inside a pod,
- compares the sums to the offered resources
- puts the sums into the Mesos TaskInfo such that Mesos does the accounting
  for the pod.
- parses the static pod spec and adds up the resources
- sets the executor resources to 0.25 cpu, 64 MB plus the static pod resources
- sets the cgroups in the kubelet for system containers, resource containers
  and docker to the one of the executor that Mesos assigned
- adds scheduler parameters --default-container-cpu-limit and
  --default-container-mem-limit.

The containers themselves are resource limited the Docker resource limit which
the kubelet applies when launching them.

Fixes mesosphere/kubernetes-mesos#68 and mesosphere/kubernetes-mesos#304
deads2k pushed a commit to kubernetes-retired/kube-mesos-framework that referenced this issue Sep 29, 2016
This patch

- set limits (0.25 cpu, 64 MB) on containers which are not limited in pod spec
  (these are also passed to the kubelet such that it uses them for the docker
  run limits)
- sums up the container resource limits for cpu and memory inside a pod,
- compares the sums to the offered resources
- puts the sums into the Mesos TaskInfo such that Mesos does the accounting
  for the pod.
- parses the static pod spec and adds up the resources
- sets the executor resources to 0.25 cpu, 64 MB plus the static pod resources
- sets the cgroups in the kubelet for system containers, resource containers
  and docker to the one of the executor that Mesos assigned
- adds scheduler parameters --default-container-cpu-limit and
  --default-container-mem-limit.

The containers themselves are resource limited the Docker resource limit which
the kubelet applies when launching them.

Fixes mesosphere/kubernetes-mesos#68 and mesosphere/kubernetes-mesos#304
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants