Add labeling nodes

This commit is contained in:
Aleksandr Didenko 2016-07-08 15:04:31 +02:00
parent 99db440287
commit e89f4ac7ee
2 changed files with 33 additions and 0 deletions

28
ccp/label-nodes.sh Executable file
View file

@ -0,0 +1,28 @@
#!/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

View file

@ -8,6 +8,11 @@
dest: /root/ccp/ dest: /root/ccp/
tasks: tasks:
- name: Label nodes
shell: ./label-nodes.sh
args:
chdir: /root/ccp
run_once: true
- name: Get namespaces - name: Get namespaces
shell: kubectl get namespace shell: kubectl get namespace