Skip to content

Commit 616fce7

Browse files
authored
Merge pull request kubernetes#85797 from oxddr/taint-heapster
Add an option to specify kubelet flags for heapster node.
2 parents 3994f52 + 39cb822 commit 616fce7

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
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: 16 additions & 11 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,7 +618,7 @@ 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=""
621623
if [[ "${KUBE_PROXY_DAEMONSET:-}" == "true" && "${master}" != "true" ]]; then
622624
# Add kube-proxy daemonset label to node to avoid situation during cluster
@@ -626,10 +628,10 @@ function build-linux-node-labels {
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
@@ -1481,7 +1486,7 @@ EOF
14811486
# TODO(kubernetes/autoscaler#718): AUTOSCALER_ENV_VARS is a hotfix for cluster autoscaler,
14821487
# which reads the kube-env to determine the shape of a node and was broken by #60020.
14831488
# This should be removed as soon as a more reliable source of information is available!
1484-
local node_labels="$(build-linux-node-labels false)"
1489+
local node_labels="$(build-linux-node-labels node)"
14851490
local node_taints="${NODE_TAINTS:-}"
14861491
local autoscaler_env_vars="node_labels=${node_labels};node_taints=${node_taints}"
14871492
cat >>$file <<EOF
@@ -3256,7 +3261,7 @@ function create-heapster-node() {
32563261
--tags "${NODE_TAG}" \
32573262
${network} \
32583263
$(get-scope-flags) \
3259-
--metadata-from-file "$(get-node-instance-metadata-from-file)"
3264+
--metadata-from-file "$(get-node-instance-metadata-from-file "heapster-kube-env")"
32603265
}
32613266

32623267
# Assumes:

0 commit comments

Comments
 (0)