From 8cf3dc103ef3689f76c22a8076b79512d6be7cff Mon Sep 17 00:00:00 2001 From: Michael Taufen Date: Tue, 13 Mar 2018 10:16:52 -0700 Subject: [PATCH] Add AUTOSCALER_ENV_VARS to kube-env to hotfix cluster autoscaler This provides a temporary way for the cluster autoscaler to get at values that were removed from kube-env in #60020. Ideally this information will eventually be available via e.g. the Cluster API, because kube-env is an internal interface that carries no stability guarantees. --- cluster/gce/util.sh | 47 ++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 5838ec052a5..eef97ef5fe7 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -514,6 +514,23 @@ function write-node-env { build-kube-env false "${KUBE_TEMP}/node-kube-env.yaml" } +function build-node-labels { + local master=$1 + local node_labels="" + if [[ "${KUBE_PROXY_DAEMONSET:-}" == "true" && "${master}" != "true" ]]; then + # Add kube-proxy daemonset label to node to avoid situation during cluster + # upgrade/downgrade when there are two instances of kube-proxy running on a node. + node_labels="beta.kubernetes.io/kube-proxy-ds-ready=true" + fi + if [[ -n "${NODE_LABELS:-}" ]]; then + node_labels="${node_labels:+${node_labels},}${NODE_LABELS}" + fi + if [[ -n "${NON_MASTER_NODE_LABELS:-}" && "${master}" != "true" ]]; then + node_labels="${node_labels:+${node_labels},}${NON_MASTER_NODE_LABELS}" + fi + echo $node_labels +} + # $1: if 'true', we're rendering flags for a master, else a node function construct-kubelet-flags { local master=$1 @@ -585,18 +602,7 @@ function construct-kubelet-flags { if [[ -n "${ENABLE_CUSTOM_METRICS:-}" ]]; then flags+=" --enable-custom-metrics=${ENABLE_CUSTOM_METRICS}" fi - local node_labels="" - if [[ "${KUBE_PROXY_DAEMONSET:-}" == "true" && "${master}" != "true" ]]; then - # Add kube-proxy daemonset label to node to avoid situation during cluster - # upgrade/downgrade when there are two instances of kube-proxy running on a node. - node_labels="beta.kubernetes.io/kube-proxy-ds-ready=true" - fi - if [[ -n "${NODE_LABELS:-}" ]]; then - node_labels="${node_labels:+${node_labels},}${NODE_LABELS}" - fi - if [[ -n "${NON_MASTER_NODE_LABELS:-}" && "${master}" != "true" ]]; then - node_labels="${node_labels:+${node_labels},}${NON_MASTER_NODE_LABELS}" - fi + local node_labels=$(build-node-labels ${master}) if [[ -n "${node_labels:-}" ]]; then flags+=" --node-labels=${node_labels}" fi @@ -972,6 +978,17 @@ ENABLE_CLUSTER_AUTOSCALER: $(yaml-quote ${ENABLE_CLUSTER_AUTOSCALER}) AUTOSCALER_MIG_CONFIG: $(yaml-quote ${AUTOSCALER_MIG_CONFIG}) AUTOSCALER_EXPANDER_CONFIG: $(yaml-quote ${AUTOSCALER_EXPANDER_CONFIG}) EOF + if [[ "${master}" == "false" ]]; then + # TODO(kubernetes/autoscaler#718): AUTOSCALER_ENV_VARS is a hotfix for cluster autoscaler, + # which reads the kube-env to determine the shape of a node and was broken by #60020. + # This should be removed as soon as a more reliable source of information is available! + local node_labels=$(build-node-labels false) + local node_taints="${NODE_TAINTS:-}" + local autoscaler_env_vars="node_labels=${node_labels};node_taints=${node_taints}" + cat >>$file <>$file <