Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kube_hostname_override inconsistencies #4185

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ kube_proxy_nodeport_addresses: >-
[]
{%- endif -%}

# If non-empty, will use this string as identification instead of the actual hostname
#kube_override_hostname: >-
# {%- if cloud_provider is defined and cloud_provider in [ 'aws' ] -%}
# {%- else -%}
# {{ inventory_hostname }}
# {%- endif -%}

## Encrypting Secret Data at Rest (experimental)
kube_encrypt_secret_data: false

Expand Down
7 changes: 7 additions & 0 deletions roles/kubernetes/kubeadm/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
---
# discovery_timeout modifies the discovery timeout
discovery_timeout: 5m0s

# If non-empty, will use this string as identification instead of the actual hostname
kube_override_hostname: >-
{%- if cloud_provider is defined and cloud_provider in [ 'aws' ] -%}
{%- else -%}
{{ inventory_hostname }}
{%- endif -%}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ discoveryTokenAPIServers:
{% endif %}
discoveryTokenUnsafeSkipCAVerification: true
nodeRegistration:
name: {{ inventory_hostname }}
name: {{ kube_override_hostname }}
{% if container_manager == 'crio' %}
criSocket: /var/run/crio/crio.sock
{% elif container_manager == 'rkt' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ discoveryTokenAPIServers:
{% endif %}
discoveryTokenUnsafeSkipCAVerification: true
nodeRegistration:
name: {{ inventory_hostname }}
name: {{ kube_override_hostname }}
{% if container_manager == 'crio' %}
criSocket: /var/run/crio/crio.sock
{% elif container_manager == 'rkt' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ discovery:
tlsBootstrapToken: {{ kubeadm_token }}
caCertPath: {{ kube_cert_dir }}/ca.crt
nodeRegistration:
name: {{ inventory_hostname }}
name: {{ kube_override_hostname }}
{% if container_manager == 'crio' %}
criSocket: /var/run/crio/crio.sock
{% elif container_manager == 'rkt' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ conntrack:
tcpEstablishedTimeout: {{ kube_proxy_conntrack_tcp_established_timeout }}
enableProfiling: {{ kube_proxy_enable_profiling }}
healthzBindAddress: {{ kube_proxy_healthz_bind_address }}
hostnameOverride: {{ kube_override_hostname }}
iptables:
masqueradeAll: {{ kube_proxy_masquerade_all }}
masqueradeBit: {{ kube_proxy_masquerade_bit }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ conntrack:
tcpEstablishedTimeout: {{ kube_proxy_conntrack_tcp_established_timeout }}
enableProfiling: {{ kube_proxy_enable_profiling }}
healthzBindAddress: {{ kube_proxy_healthz_bind_address }}
hostnameOverride: {{ kube_override_hostname }}
iptables:
masqueradeAll: {{ kube_proxy_masquerade_all }}
masqueradeBit: {{ kube_proxy_masquerade_bit }}
Expand Down
7 changes: 7 additions & 0 deletions roles/kubespray-defaults/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ kube_apiserver_port: 6443
kube_apiserver_insecure_bind_address: 127.0.0.1
kube_apiserver_insecure_port: 0

# If non-empty, will use this string as identification instead of the actual hostname
kube_override_hostname: >-
{%- if cloud_provider is defined and cloud_provider in [ 'aws' ] -%}
{%- else -%}
{{ inventory_hostname }}
{%- endif -%}

# dynamic kubelet configuration
dynamic_kubelet_configuration: false

Expand Down
22 changes: 0 additions & 22 deletions roles/win_nodes/kubernetes_patch/files/hostnameOverride-patch.json

This file was deleted.

27 changes: 0 additions & 27 deletions roles/win_nodes/kubernetes_patch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,6 @@
recurse: yes
tags: [init, cni]

- name: Apply kube-proxy hostnameOverride
block:
- name: Copy kube-proxy daemonset hostnameOverride patch
copy:
src: hostnameOverride-patch.json
dest: "{{ kubernetes_user_manifests_path }}/hostnameOverride-patch.json"

- name: Check current command for kube-proxy daemonset
shell: "{{bin_dir}}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf get ds kube-proxy --namespace=kube-system -o jsonpath='{.spec.template.spec.containers[0].command}'"
register: current_kube_proxy_command

- name: Apply hostnameOverride patch for kube-proxy daemonset
shell: "{{bin_dir}}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf patch ds kube-proxy --namespace=kube-system --type=json -p \"$(cat hostnameOverride-patch.json)\""
args:
chdir: "{{ kubernetes_user_manifests_path }}"
register: patch_kube_proxy_command
when: not current_kube_proxy_command.stdout is search("--hostname-override=${NODE_NAME}")

- debug: msg={{ patch_kube_proxy_command.stdout_lines }}
when: patch_kube_proxy_command is not skipped

- debug: msg={{ patch_kube_proxy_command.stderr_lines }}
when: patch_kube_proxy_command is not skipped
tags: init
when:
- not kube_proxy_remove

- name: Apply kube-proxy nodeselector
block:
- name: Copy kube-proxy daemonset nodeselector patch
Expand Down