Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable dynamic allocation of heapster/eventer cpu request/limit #27185

Merged
merged 1 commit into from
Jun 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awk is a heavy-weight tool. Can we use the same way as the above line to calculate the variable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a float. We could redefine it here to metrics_millicpu_per_node and keep it in integer space, though?

Copy link
Contributor Author

@gmarek gmarek Jun 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that I want it to be 0.5. I can implement it as an ordinary fraction, but that seems even worse than awk. I can switch to bc if that's better for some reason.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not notice it is a float, so please ignore my previous comment about awk

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zmerlynn - it's already 0.5 millicpu (0.0005 cpu). So if we want to keep it integer, we should probably move to micro-cpus...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math is hard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, not to complain about bash not having floats, but are we OK with awk, should we move to bc, use micro-cpus, or something else?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with awk.

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