Merge pull request #10655 from dchen1107/cadvisor

Set minimal shares for containers with no cpu specified
pull/6/head
Yu-Ju Hong 2015-07-06 11:38:54 -07:00
commit b58e7c8c2d
6 changed files with 29 additions and 2 deletions

View File

@ -8,6 +8,11 @@
{
"name": "etcd-container",
"image": "gcr.io/google_containers/etcd:2.0.12",
"resources": {
"limits": {
"cpu": "200m"
}
},
"command": [
"/bin/sh",
"-c",

View File

@ -98,6 +98,11 @@
{
"name": "kube-apiserver",
"image": "gcr.io/google_containers/kube-apiserver:{{pillar['kube-apiserver_docker_tag']}}",
"resources": {
"limits": {
"cpu": "200m"
}
},
"command": [
"/bin/sh",
"-c",

View File

@ -46,6 +46,11 @@
{
"name": "kube-controller-manager",
"image": "gcr.io/google_containers/kube-controller-manager:{{pillar['kube-controller-manager_docker_tag']}}",
"resources": {
"limits": {
"cpu": "200m"
}
},
"command": [
"/bin/sh",
"-c",

View File

@ -8,6 +8,11 @@
{
"name": "kube-scheduler",
"image": "gcr.io/google_containers/kube-scheduler:{{pillar['kube-scheduler_docker_tag']}}",
"resources": {
"limits": {
"cpu": "200m"
}
},
"command": [
"/bin/sh",
"-c",

View File

@ -8,6 +8,11 @@
{
"name": "nginx",
"image": "gcr.io/google-containers/nginx:v1",
"resources": {
"limits": {
"cpu": "200m"
}
},
"command": [
"nginx",
"-g",

View File

@ -306,8 +306,10 @@ func ConnectToDockerOrDie(dockerEndpoint string) DockerInterface {
func milliCPUToShares(milliCPU int64) int64 {
if milliCPU == 0 {
// zero milliCPU means unset. Use kernel default.
return 0
// Docker converts zero milliCPU to unset, which maps to kernel default
// for unset: 1024. Return 2 here to really match kernel default for
// zero milliCPU.
return minShares
}
// Conceptually (milliCPU / milliCPUToCPU) * sharesPerCPU, but factored to improve rounding.
shares := (milliCPU * sharesPerCPU) / milliCPUToCPU