c12s-kubespray/ccp/label-nodes.sh

29 lines
650 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=( \
["node2"]="openstack-controller=true"
["node3"]="openstack-controller=true"
["node4"]="openstack-controller=true"
["node5"]="openstack-compute=true"
["node6"]="openstack-compute=true"
["node7"]="openstack-compute=true"
)
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