Skip to content

Commit

Permalink
Adjust heapster cpu request/limit
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarek committed Jun 15, 2016
1 parent 3d09b99 commit 8617f70
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{% set base_metrics_memory = "140Mi" -%}
{% set metrics_memory = base_metrics_memory -%}
{% set base_metrics_cpu = "80m" -%}
{% set metrics_cpu = base_metrics_cpu -%}
{% set base_eventer_memory = "190Mi" -%}
{% set eventer_memory = base_eventer_memory -%}
{% set metrics_memory_per_node = 4 -%}
{% set metrics_cpu_per_node = 0.5 -%}
{% set eventer_memory_per_node = 500 -%}
{% set num_nodes = pillar.get('num_nodes', -1) -%}
{% set nanny_memory = "90Mi" -%}
{% set nanny_memory_per_node = 200 -%}
{% if num_nodes >= 0 -%}
{% set metrics_memory = (200 + num_nodes * metrics_memory_per_node)|string + "Mi" -%}
{% set metrics_cpu = (80 + num_nodes * metrics_cpu_per_node)|string + "m" -%}
{% set eventer_memory = (200 * 1024 + num_nodes * eventer_memory_per_node)|string + "Ki" -%}
{% set nanny_memory = (90 * 1024 + num_nodes * nanny_memory_per_node)|string + "Ki" -%}
{% endif -%}
Expand Down Expand Up @@ -40,10 +44,10 @@ spec:
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
requests:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
command:
- /heapster
Expand Down Expand Up @@ -91,8 +95,8 @@ spec:
fieldPath: metadata.namespace
command:
- /pod_nanny
- --cpu=80m
- --extra-cpu=0.5m
- --cpu={{ base_metrics_cpu }}
- --extra-cpu={{ metrics_cpu_per_node }}m
- --memory={{ base_metrics_memory }}
- --extra-memory={{metrics_memory_per_node}}Mi
- --threshold=5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{% set base_metrics_memory = "140Mi" -%}
{% set metrics_memory = base_metrics_memory -%}
{% set base_metrics_cpu = "80m" -%}
{% set metrics_cpu = base_metrics_cpu -%}
{% set base_eventer_memory = "190Mi" -%}
{% set eventer_memory = base_eventer_memory -%}
{% set metrics_memory_per_node = 4 -%}
{% set metrics_cpu_per_node = 0.5 -%}
{% set eventer_memory_per_node = 500 -%}
{% set num_nodes = pillar.get('num_nodes', -1) -%}
{% set nanny_memory = "90Mi" -%}
{% set nanny_memory_per_node = 200 -%}
{% if num_nodes >= 0 -%}
{% set metrics_memory = (200 + num_nodes * metrics_memory_per_node)|string + "Mi" -%}
{% set metrics_cpu = (80 + num_nodes * metrics_cpu_per_node)|string + "m" -%}
{% set eventer_memory = (200 * 1024 + num_nodes * eventer_memory_per_node)|string + "Ki" -%}
{% set nanny_memory = (90 * 1024 + num_nodes * nanny_memory_per_node)|string + "Ki" -%}
{% endif -%}
Expand Down Expand Up @@ -40,10 +44,10 @@ spec:
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
requests:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
command:
- /heapster
Expand Down Expand Up @@ -92,8 +96,8 @@ spec:
fieldPath: metadata.namespace
command:
- /pod_nanny
- --cpu=80m
- --extra-cpu=0.5m
- --cpu={{ base_metrics_cpu }}
- --extra-cpu={{ metrics_cpu_per_node }}m
- --memory={{ base_metrics_memory }}
- --extra-memory={{ metrics_memory_per_node }}Mi
- --threshold=5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{% set base_metrics_memory = "140Mi" -%}
{% set metrics_memory = base_metrics_memory -%}
{% set base_metrics_cpu = "80m" -%}
{% set metrics_cpu = base_metrics_cpu -%}
{% set base_eventer_memory = "190Mi" -%}
{% set eventer_memory = base_eventer_memory -%}
{% set metrics_memory_per_node = 4 -%}
{% set metrics_cpu_per_node = 0.5|float -%}
{% set eventer_memory_per_node = 500 -%}
{% set num_nodes = pillar.get('num_nodes', -1) -%}
{% set nanny_memory = "90Mi" -%}
{% set nanny_memory_per_node = 200 -%}
{% if num_nodes >= 0 -%}
{% set metrics_memory = (200 + num_nodes * metrics_memory_per_node)|string + "Mi" -%}
{% set metrics_cpu = (80 + num_nodes * metrics_cpu_per_node)|string + "m" -%}
{% set eventer_memory = (200 * 1024 + num_nodes * eventer_memory_per_node)|string + "Ki" -%}
{% set nanny_memory = (90 * 1024 + num_nodes * nanny_memory_per_node)|string + "Ki" -%}
{% endif -%}
Expand Down Expand Up @@ -40,10 +44,10 @@ spec:
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
requests:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
command:
- /heapster
Expand Down Expand Up @@ -83,8 +87,8 @@ spec:
fieldPath: metadata.namespace
command:
- /pod_nanny
- --cpu=80m
- --extra-cpu=0.5m
- --cpu={{ base_metrics_cpu }}
- --extra-cpu={{ metrics_cpu_per_node }}m
- --memory={{ base_metrics_memory }}
- --extra-memory={{ metrics_memory_per_node }}Mi
- --threshold=5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{% set base_metrics_memory = "140Mi" -%}
{% set metrics_memory = base_metrics_memory -%}
{% set metrics_memory_per_node = 4 -%}
{% set base_metrics_cpu = "80m" -%}
{% set metrics_cpu = base_metrics_cpu -%}
{% set metrics_cpu_per_node = 0.5 -%}
{% set num_nodes = pillar.get('num_nodes', -1) -%}
{% set nanny_memory = "90Mi" -%}
{% set nanny_memory_per_node = 200 -%}
{% if num_nodes >= 0 -%}
{% set metrics_memory = (200 + num_nodes * metrics_memory_per_node)|string + "Mi" -%}
{% set nanny_memory = (90 * 1024 + num_nodes * nanny_memory_per_node)|string + "Ki" -%}
{% set metrics_cpu = (80 + num_nodes * metrics_cpu_per_node)|string + "m" -%}
{% endif -%}

apiVersion: extensions/v1beta1
Expand Down Expand Up @@ -36,10 +40,10 @@ spec:
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
requests:
cpu: 100m
cpu: {{ metrics_cpu }}
memory: {{ metrics_memory }}
command:
- /heapster
Expand All @@ -64,8 +68,8 @@ spec:
fieldPath: metadata.namespace
command:
- /pod_nanny
- --cpu=80m
- --extra-cpu=0.5m
- --cpu={{ base_metrics_cpu }}
- --extra-cpu={{ metrics_cpu_per_node }}m
- --memory={{ base_metrics_memory }}
- --extra-memory={{ metrics_memory_per_node }}Mi
- --threshold=5
Expand Down
7 changes: 7 additions & 0 deletions cluster/gce/gci/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -725,16 +725,20 @@ function start-kube-addons {
base_metrics_memory="140Mi"
metrics_memory="${base_metrics_memory}"
base_eventer_memory="190Mi"
base_metrics_cpu="80m"
metrics_cpu="${base_metrics_cpu}"
eventer_memory="${base_eventer_memory}"
nanny_memory="90Mi"
local -r metrics_memory_per_node="4"
local -r metrics_cpu_per_node="0.5"
local -r eventer_memory_per_node="500"
local -r nanny_memory_per_node="200"
if [[ -n "${NUM_NODES:-}" && "${NUM_NODES}" -ge 1 ]]; then
num_kube_nodes="$((${NUM_NODES}+1))"
metrics_memory="$((${num_kube_nodes} * ${metrics_memory_per_node} + 200))Mi"
eventer_memory="$((${num_kube_nodes} * ${eventer_memory_per_node} + 200 * 1024))Ki"
nanny_memory="$((${num_kube_nodes} * ${nanny_memory_per_node} + 90 * 1024))Ki"
metrics_cpu=$(echo - | awk "{print ${num_kube_nodes} * ${metrics_cpu_per_node} + 80}")m
fi
controller_yaml="${dst_dir}/${file_dir}"
if [[ "${ENABLE_CLUSTER_MONITORING:-}" == "googleinfluxdb" ]]; then
Expand All @@ -745,11 +749,14 @@ function start-kube-addons {
remove-salt-config-comments "${controller_yaml}"
sed -i -e "s@{{ *base_metrics_memory *}}@${base_metrics_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_memory *}}@${metrics_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *base_metrics_cpu *}}@${base_metrics_cpu}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_cpu *}}@${metrics_cpu}@g" "${controller_yaml}"
sed -i -e "s@{{ *base_eventer_memory *}}@${base_eventer_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *eventer_memory *}}@${eventer_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_memory_per_node *}}@${metrics_memory_per_node}@g" "${controller_yaml}"
sed -i -e "s@{{ *eventer_memory_per_node *}}@${eventer_memory_per_node}@g" "${controller_yaml}"
sed -i -e "s@{{ *nanny_memory *}}@${nanny_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_cpu_per_node *}}@${metrics_cpu_per_node}@g" "${controller_yaml}"
fi
if [[ "${ENABLE_CLUSTER_DNS:-}" == "true" ]]; then
setup-addon-manifests "addons" "dns"
Expand Down
7 changes: 7 additions & 0 deletions cluster/gce/trusty/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -717,16 +717,20 @@ start_kube_addons() {
base_metrics_memory="140Mi"
metrics_memory="${base_metrics_memory}"
base_eventer_memory="190Mi"
base_metrics_cpu="80m"
metrics_cpu="${base_metrics_cpu}"
eventer_memory="${base_eventer_memory}"
nanny_memory="90Mi"
readonly metrics_memory_per_node="4"
readonly metrics_cpu_per_node="0.5"
readonly eventer_memory_per_node="500"
readonly nanny_memory_per_node="200"
if [ -n "${NUM_NODES:-}" ] && [ "${NUM_NODES}" -ge 1 ]; then
num_kube_nodes="$((${NUM_NODES}+1))"
metrics_memory="$((${num_kube_nodes} * ${metrics_memory_per_node} + 200))Mi"
eventer_memory="$((${num_kube_nodes} * ${eventer_memory_per_node} + 200 * 1024))Ki"
nanny_memory="$((${num_kube_nodes} * ${nanny_memory_per_node} + 90 * 1024))Ki"
metrics_cpu=$(echo - | awk "{print ${num_kube_nodes} * ${metrics_cpu_per_node} + 80}")m
fi
controller_yaml="${addon_dst_dir}/${file_dir}"
if [ "${ENABLE_CLUSTER_MONITORING:-}" = "googleinfluxdb" ]; then
Expand All @@ -737,11 +741,14 @@ start_kube_addons() {
remove_salt_config_comments "${controller_yaml}"
sed -i -e "s@{{ *base_metrics_memory *}}@${base_metrics_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_memory *}}@${metrics_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *base_metrics_cpu *}}@${base_metrics_cpu}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_cpu *}}@${metrics_cpu}@g" "${controller_yaml}"
sed -i -e "s@{{ *base_eventer_memory *}}@${base_eventer_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *eventer_memory *}}@${eventer_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_memory_per_node *}}@${metrics_memory_per_node}@g" "${controller_yaml}"
sed -i -e "s@{{ *eventer_memory_per_node *}}@${eventer_memory_per_node}@g" "${controller_yaml}"
sed -i -e "s@{{ *nanny_memory *}}@${nanny_memory}@g" "${controller_yaml}"
sed -i -e "s@{{ *metrics_cpu_per_node *}}@${metrics_cpu_per_node}@g" "${controller_yaml}"
fi
if [ "${ENABLE_L7_LOADBALANCING:-}" = "glbc" ]; then
setup_addon_manifests "addons" "cluster-loadbalancing/glbc"
Expand Down

0 comments on commit 8617f70

Please sign in to comment.