Skip to content

Commit

Permalink
Hostname alias fixes
Browse files Browse the repository at this point in the history
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 kubernetes/kubernetes#22770

Signed-off-by: Chad Swenson <chadswen@gmail.com>
  • Loading branch information
chadswen committed Oct 18, 2016
1 parent 1de1274 commit a5137af
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion roles/kubernetes/node/templates/kubelet.j2
Expand Up @@ -14,7 +14,7 @@ KUBELET_ADDRESS="--address={{ ip | default("0.0.0.0") }}"
# The port for the info server to serve on
# KUBELET_PORT="--port=10250"
# 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'] %}
KUBELET_REGISTER_NODE="--register-node=false"
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion roles/kubernetes/preinstall/tasks/etchosts.yml
Expand Up @@ -4,7 +4,7 @@
dest: /etc/hosts
block: |-
{% 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 %}
state: present
create: yes
Expand Down

0 comments on commit a5137af

Please sign in to comment.