Skip to content
Merged
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
13 changes: 13 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ function getSubnets() {
fi
}

function getNodesByLabel () {
printf "finding nodes matching %s...\n" "$1"
nodeStr=$("$K8S_CLI_BIN" get nodes -l "$1" -o name | tr '\n' ' ')
IFS=' ' read -ra nodeArray <<<"$nodeStr"
if [ "${#nodeArray[@]}" -gt 0 ]; then
printf "%d matching nodes found: %s\n" ${#nodeArray[@]} "$nodeStr" >&2
else
printf "%s doesn't match any node label. Please check your --node-selector parameter\n" "$1" >&2
exit 1
fi
}

function setup {
echo "Setting up... "

Expand Down Expand Up @@ -490,6 +502,7 @@ function edit_manifest() {
"node_selector")
key=${2%:*}
val=${2#*:}
getNodesByLabel "$key=$val"
"$YQ_BIN" e --inplace ".spec.template.spec.nodeSelector.\"$key\" |= \"$val\"" "$3"
;;
esac
Expand Down
Loading