Skip to content

Commit fc92222

Browse files
authored
Merge pull request kubernetes#87013 from oxddr/taint-heapster
Revert "Revert "Add an option to specify kubelet flags for heapster node
2 parents b95d571 + a9e5fd6 commit fc92222

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

cluster/gce/gci/node-helper.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
# A library of helper functions and constant for GCI distro
1818
source "${KUBE_ROOT}/cluster/gce/gci/helper.sh"
1919

20+
# shellcheck disable=SC2120
2021
function get-node-instance-metadata-from-file {
22+
local kube_env=${1:-node-kube-env} # optional
2123
local metadata=""
22-
metadata+="kube-env=${KUBE_TEMP}/node-kube-env.yaml,"
24+
metadata+="kube-env=${KUBE_TEMP}/${kube_env}.yaml,"
2325
metadata+="kubelet-config=${KUBE_TEMP}/node-kubelet-config.yaml,"
2426
metadata+="user-data=${KUBE_ROOT}/cluster/gce/gci/node.yaml,"
2527
metadata+="configure-sh=${KUBE_ROOT}/cluster/gce/gci/configure.sh,"

cluster/gce/util.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ function write-master-env {
592592
KUBERNETES_MASTER_NAME="${MASTER_NAME}"
593593
fi
594594

595-
construct-linux-kubelet-flags true
595+
construct-linux-kubelet-flags "master"
596596
build-linux-kube-env true "${KUBE_TEMP}/master-kube-env.yaml"
597597
build-kubelet-config true "linux" "${KUBE_TEMP}/master-kubelet-config.yaml"
598598
build-kube-master-certs "${KUBE_TEMP}/kube-master-certs.yaml"
@@ -603,7 +603,9 @@ function write-linux-node-env {
603603
KUBERNETES_MASTER_NAME="${MASTER_NAME}"
604604
fi
605605

606-
construct-linux-kubelet-flags false
606+
construct-linux-kubelet-flags "heapster"
607+
build-linux-kube-env false "${KUBE_TEMP}/heapster-kube-env.yaml"
608+
construct-linux-kubelet-flags "node"
607609
build-linux-kube-env false "${KUBE_TEMP}/node-kube-env.yaml"
608610
build-kubelet-config false "linux" "${KUBE_TEMP}/node-kubelet-config.yaml"
609611
}
@@ -616,20 +618,20 @@ function write-windows-node-env {
616618
}
617619

618620
function build-linux-node-labels {
619-
local master=$1
621+
local node_type=$1
620622
local node_labels=""
621-
if [[ "${KUBE_PROXY_DAEMONSET:-}" == "true" && "${master}" != "true" ]]; then
623+
if [[ "${KUBE_PROXY_DAEMONSET:-}" == "true" && "${node_type}" != "master" ]]; then
622624
# Add kube-proxy daemonset label to node to avoid situation during cluster
623625
# upgrade/downgrade when there are two instances of kube-proxy running on a node.
624626
node_labels="node.kubernetes.io/kube-proxy-ds-ready=true"
625627
fi
626628
if [[ -n "${NODE_LABELS:-}" ]]; then
627629
node_labels="${node_labels:+${node_labels},}${NODE_LABELS}"
628630
fi
629-
if [[ -n "${NON_MASTER_NODE_LABELS:-}" && "${master}" != "true" ]]; then
631+
if [[ -n "${NON_MASTER_NODE_LABELS:-}" && "${node_type}" != "master" ]]; then
630632
node_labels="${node_labels:+${node_labels},}${NON_MASTER_NODE_LABELS}"
631633
fi
632-
if [[ -n "${MASTER_NODE_LABELS:-}" && "${master}" == "true" ]]; then
634+
if [[ -n "${MASTER_NODE_LABELS:-}" && "${node_type}" == "master" ]]; then
633635
node_labels="${node_labels:+${node_labels},}${MASTER_NODE_LABELS}"
634636
fi
635637
echo $node_labels
@@ -740,7 +742,7 @@ function construct-common-kubelet-flags {
740742
# Sets KUBELET_ARGS with the kubelet flags for Linux nodes.
741743
# $1: if 'true', we're rendering flags for a master, else a node
742744
function construct-linux-kubelet-flags {
743-
local master="$1"
745+
local node_type="$1"
744746
local flags="$(construct-common-kubelet-flags)"
745747
# Keep in sync with CONTAINERIZED_MOUNTER_HOME in configure-helper.sh
746748
flags+=" --experimental-mounter-path=/home/kubernetes/containerized_mounter/mounter"
@@ -751,7 +753,7 @@ function construct-linux-kubelet-flags {
751753
flags+=" --dynamic-config-dir=/var/lib/kubelet/dynamic-config"
752754

753755

754-
if [[ "${master}" == "true" ]]; then
756+
if [[ "${node_type}" == "master" ]]; then
755757
flags+=" ${MASTER_KUBELET_TEST_ARGS:-}"
756758
if [[ "${REGISTER_MASTER_KUBELET:-false}" == "true" ]]; then
757759
#TODO(mikedanese): allow static pods to start before creating a client
@@ -765,14 +767,17 @@ function construct-linux-kubelet-flags {
765767
flags+=" ${NODE_KUBELET_TEST_ARGS:-}"
766768
flags+=" --bootstrap-kubeconfig=/var/lib/kubelet/bootstrap-kubeconfig"
767769
flags+=" --kubeconfig=/var/lib/kubelet/kubeconfig"
770+
if [[ "${node_type}" == "heapster" ]]; then
771+
flags+=" ${HEAPSTER_KUBELET_TEST_ARGS:-}"
772+
fi
768773
fi
769774
# Network plugin
770775
if [[ -n "${NETWORK_PROVIDER:-}" || -n "${NETWORK_POLICY_PROVIDER:-}" ]]; then
771776
flags+=" --cni-bin-dir=/home/kubernetes/bin"
772777
if [[ "${NETWORK_POLICY_PROVIDER:-}" == "calico" || "${ENABLE_NETD:-}" == "true" ]]; then
773778
# Calico uses CNI always.
774779
# Note that network policy won't work for master node.
775-
if [[ "${master}" == "true" ]]; then
780+
if [[ "${node_type}" == "master" ]]; then
776781
flags+=" --network-plugin=${NETWORK_PROVIDER}"
777782
else
778783
flags+=" --network-plugin=cni"
@@ -787,7 +792,7 @@ function construct-linux-kubelet-flags {
787792
flags+=" --non-masquerade-cidr=${NON_MASQUERADE_CIDR}"
788793
fi
789794
flags+=" --volume-plugin-dir=${VOLUME_PLUGIN_DIR}"
790-
local node_labels="$(build-linux-node-labels ${master})"
795+
local node_labels="$(build-linux-node-labels ${node_type})"
791796
if [[ -n "${node_labels:-}" ]]; then
792797
flags+=" --node-labels=${node_labels}"
793798
fi
@@ -1480,7 +1485,7 @@ EOF
14801485
# TODO(kubernetes/autoscaler#718): AUTOSCALER_ENV_VARS is a hotfix for cluster autoscaler,
14811486
# which reads the kube-env to determine the shape of a node and was broken by #60020.
14821487
# This should be removed as soon as a more reliable source of information is available!
1483-
local node_labels="$(build-linux-node-labels false)"
1488+
local node_labels="$(build-linux-node-labels node)"
14841489
local node_taints="${NODE_TAINTS:-}"
14851490
local autoscaler_env_vars="node_labels=${node_labels};node_taints=${node_taints}"
14861491
cat >>$file <<EOF
@@ -3255,7 +3260,7 @@ function create-heapster-node() {
32553260
--tags "${NODE_TAG}" \
32563261
${network} \
32573262
$(get-scope-flags) \
3258-
--metadata-from-file "$(get-node-instance-metadata-from-file)"
3263+
--metadata-from-file "$(get-node-instance-metadata-from-file "heapster-kube-env")"
32593264
}
32603265

32613266
# Assumes:

0 commit comments

Comments
 (0)