c12s-kubespray/ccp/label-nodes.sh

26 lines
539 B
Bash
Raw Normal View History

2016-07-08 13:04:31 +00:00
#!/bin/bash
set -e
# FIXME: hardcoded roles
declare -A nodes
nodes=( \
2016-07-11 12:16:02 +00:00
["node1"]="openstack-controller=true"
["node2"]="openstack-compute=true"
["node3"]="openstack-compute=true"
2016-07-08 13:04:31 +00:00
)
label_nodes() {
all_label='openstack-compute-controller=true'
for i in "${!nodes[@]}"
do
node=$i
label=${nodes[$i]}
kubectl get nodes $node --show-labels | grep -q "$label" || kubectl label nodes $node $label
kubectl get nodes $node --show-labels | grep -q "$all_label" || kubectl label nodes $node $all_label
done
}
label_nodes