Lowercase hostnames when used as node names in k8s

This commit is contained in:
Konstantinos Tsakalozos 2017-11-22 09:45:23 +02:00
parent afb26b9323
commit 99a25fed19

View File

@ -157,7 +157,7 @@ def shutdown():
'''
try:
if os.path.isfile(kubeconfig_path):
kubectl('delete', 'node', gethostname())
kubectl('delete', 'node', gethostname().lower())
except CalledProcessError:
hookenv.log('Failed to unregister node.')
service_stop('snap.kubelet.daemon')
@ -906,7 +906,8 @@ class ApplyNodeLabelFailed(Exception):
def _apply_node_label(label, delete=False, overwrite=False):
''' Invoke kubectl to apply node label changes '''
hostname = gethostname()
# k8s lowercases hostnames and uses them as node names
hostname = gethostname().lower()
# TODO: Make this part of the kubectl calls instead of a special string
cmd_base = 'kubectl --kubeconfig={0} label node {1} {2}'