earthmant | 5e1853a | 2017-08-04 09:02:48 +0300 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | from fabric.api import run |
| 4 | |
| 5 | |
| 6 | def label_node(labels, hostname): |
| 7 | if labels: |
| 8 | label_list = [] |
| 9 | for key, value in labels.items(): |
| 10 | label_pair_string = '%s=%s' % (key, value) |
| 11 | label_list.append(label_pair_string) |
| 12 | label_string = ' '.join(label_list) |
| 13 | command = 'kubectl label nodes %s %s' % (hostname, label_string) |
| 14 | run(command) |
| 15 | |
| 16 | |
| 17 | def stop_node(hostname): |
| 18 | command = 'kubectl drain %s' % (hostname) |
| 19 | run(command) |
| 20 | |
| 21 | |
| 22 | def delete_node(hostname): |
| 23 | command = 'kubectl delete no %s' % (hostname) |
| 24 | run(command) |