Skip to content

Commit 38c2817

Browse files
committed
Propagate cluster size through salt
1 parent 8a8cd06 commit 38c2817

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

cluster/gce/gci/configure-helper.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,12 @@ function start-kube-apiserver {
635635
if [[ -n "${ENABLE_GARBAGE_COLLECTOR:-}" ]]; then
636636
params+=" --enable-garbage-collector=${ENABLE_GARBAGE_COLLECTOR}"
637637
fi
638+
if [[ -n "${NUM_NODES:-}" ]]; then
639+
# Set amount of memory available for apiserver based on number of nodes.
640+
# TODO: Once we start setting proper requests and limits for apiserver
641+
# we should reuse the same logic here instead of current heuristic.
642+
params+=" --target-ram-mb=$((${NUM_NODES} * 60))"
643+
fi
638644
if [[ -n "${SERVICE_CLUSTER_IP_RANGE:-}" ]]; then
639645
params+=" --service-cluster-ip-range=${SERVICE_CLUSTER_IP_RANGE}"
640646
fi

cluster/gce/trusty/configure-helper.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ start_kube_apiserver() {
519519
params="${params} --authorization-policy-file=/etc/srv/kubernetes/abac-authz-policy.jsonl"
520520
params="${params} --etcd-servers-overrides=/events#http://127.0.0.1:4002"
521521

522+
if [ -n "${NUM_NODES:-}" ]; then
523+
# Set amount of memory available for apiserver based on number of nodes.
524+
# TODO: Once we start setting proper requests and limits for apiserver
525+
# we should reuse the same logic here instead of current heuristic.
526+
params="${params} --target-ram-mb=$((${NUM_NODES} * 60))"
527+
fi
522528
if [ -n "${SERVICE_CLUSTER_IP_RANGE:-}" ]; then
523529
params="${params} --service-cluster-ip-range=${SERVICE_CLUSTER_IP_RANGE}"
524530
fi

cluster/saltbase/salt/kube-apiserver/kube-apiserver.manifest

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@
5757
{% set etcd_servers = "--etcd-servers=http://127.0.0.1:4001" -%}
5858
{% set etcd_servers_overrides = "--etcd-servers-overrides=/events#http://127.0.0.1:4002" -%}
5959

60+
{% set target_ram_mb = "" -%}
61+
{% if pillar['num_nodes'] is defined -%}
62+
# Set amount of memory available for apiserver based on number of nodes.
63+
# TODO: Once we start setting proper requests and limits for apiserver
64+
# we should reuse the same logic here instead of current heuristic.
65+
{% set tmp_ram_mb = pillar['num_nodes']|int * 60 %}
66+
{% set target_ram_mb = "--target-ram-mb=" + tmp_ram_mb|string -%}
67+
{% endif -%}
68+
6069
{% set service_cluster_ip_range = "" -%}
6170
{% if pillar['service_cluster_ip_range'] is defined -%}
6271
{% set service_cluster_ip_range = "--service-cluster-ip-range=" + pillar['service_cluster_ip_range'] -%}
@@ -124,15 +133,15 @@
124133

125134
{% set enable_garbage_collector = "" -%}
126135
{% if pillar['enable_garbage_collector'] is defined -%}
127-
{% set enable_garbage_collector = "--enable-garbage-collector=" + pillar['enable_garbage_collector'] -%}
136+
{% set enable_garbage_collector = "--enable-garbage-collector=" + pillar['enable_garbage_collector'] -%}
128137
{% endif -%}
129138

130-
{% set params = address + " " + etcd_servers + " " + etcd_servers_overrides + " " + cloud_provider + " " + cloud_config + " " + runtime_config + " " + admission_control + " " + service_cluster_ip_range + " " + client_ca_file + basic_auth_file + " " + min_request_timeout + " " + enable_garbage_collector -%}
139+
{% set params = address + " " + etcd_servers + " " + etcd_servers_overrides + " " + cloud_provider + " " + cloud_config + " " + runtime_config + " " + admission_control + " " + target_ram_mb + " " + service_cluster_ip_range + " " + client_ca_file + basic_auth_file + " " + min_request_timeout + " " + enable_garbage_collector -%}
131140
{% set params = params + " " + cert_file + " " + key_file + " --secure-port=" + secure_port + token_auth_file + " " + bind_address + " " + log_level + " " + advertise_address + " " + proxy_ssh_options + authz_mode + abac_policy_file + webhook_authentication_config + webhook_authorization_config -%}
132141

133142
# test_args has to be kept at the end, so they'll overwrite any prior configuration
134143
{% if pillar['apiserver_test_args'] is defined -%}
135-
{% set params = params + " " + pillar['apiserver_test_args'] -%}
144+
{% set params = params + " " + pillar['apiserver_test_args'] -%}
136145
{% endif -%}
137146

138147
{

0 commit comments

Comments
 (0)