Skip to content

Commit

Permalink
check node selector (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau authored Jan 22, 2025
1 parent 7d83259 commit 52d1805
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,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 @@ -549,6 +561,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

0 comments on commit 52d1805

Please sign in to comment.