Skip to content
Snippets Groups Projects
Commit a5137aff authored by Chad Swenson's avatar Chad Swenson
Browse files

Hostname alias fixes

Change the kubelet --hostname-override flag to use the ansible_hostname variable which should be more consistent with the value required by cloud providers

Add ansible_hostname alias to /etc/hosts when it is different from inventory_hostname to overcome node name limitations see https://github.com/kubernetes/kubernetes/issues/22770



Signed-off-by: default avatarChad Swenson <chadswen@gmail.com>
parent 1de12747
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ KUBELET_ADDRESS="--address={{ ip | default("0.0.0.0") }}" ...@@ -14,7 +14,7 @@ KUBELET_ADDRESS="--address={{ ip | default("0.0.0.0") }}"
# The port for the info server to serve on # The port for the info server to serve on
# KUBELET_PORT="--port=10250" # KUBELET_PORT="--port=10250"
# You may leave this blank to use the actual hostname # You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override={{ inventory_hostname }}" KUBELET_HOSTNAME="--hostname-override={{ ansible_hostname }}"
{% if inventory_hostname in groups['kube-master'] and inventory_hostname not in groups['kube-node'] %} {% if inventory_hostname in groups['kube-master'] and inventory_hostname not in groups['kube-node'] %}
KUBELET_REGISTER_NODE="--register-node=false" KUBELET_REGISTER_NODE="--register-node=false"
{% endif %} {% endif %}
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
dest: /etc/hosts dest: /etc/hosts
block: |- block: |-
{% for item in groups['all'] -%} {% for item in groups['all'] -%}
{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address)) }} {{ item }} {{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address)) }}{% if (item != hostvars[item]['ansible_hostname']) %} {{ hostvars[item]['ansible_hostname'] }}{% endif %} {{ item }}
{% endfor %} {% endfor %}
state: present state: present
create: yes create: yes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment