From c27cc33bd70efb0685cbb049d6704210ecf6a620 Mon Sep 17 00:00:00 2001 From: ChengHao Yang <17496418+tico88612@users.noreply.github.com> Date: Mon, 4 Nov 2024 23:40:01 +0800 Subject: [PATCH] Refactor: var kube_override_hostname only reserve in kubespray-defaults Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com> --- inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml | 6 +----- roles/kubernetes/control-plane/defaults/main/main.yml | 7 ------- roles/kubernetes/kubeadm/defaults/main.yml | 7 ------- roles/kubernetes/node/defaults/main.yml | 7 ------- roles/kubespray-defaults/defaults/main/main.yml | 6 +----- 5 files changed, 2 insertions(+), 31 deletions(-) diff --git a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml index d24a1eb0b..9639879db 100644 --- a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml +++ b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml @@ -140,11 +140,7 @@ 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 -%} -# {%- else -%} -# {{ inventory_hostname }} -# {%- endif -%} +# kube_override_hostname: {{ inventory_hostname }} ## Encrypting Secret Data at Rest kube_encrypt_secret_data: false diff --git a/roles/kubernetes/control-plane/defaults/main/main.yml b/roles/kubernetes/control-plane/defaults/main/main.yml index 3b1834d55..d3a28bc21 100644 --- a/roles/kubernetes/control-plane/defaults/main/main.yml +++ b/roles/kubernetes/control-plane/defaults/main/main.yml @@ -184,13 +184,6 @@ kube_encryption_algorithm: "secretbox" # Which kubernetes resources to encrypt kube_encryption_resources: [secrets] -# If non-empty, will use this string as identification instead of the actual hostname -kube_override_hostname: >- - {%- if cloud_provider is defined -%} - {%- else -%} - {{ inventory_hostname }} - {%- endif -%} - secrets_encryption_query: "resources[*].providers[0].{{ kube_encryption_algorithm }}.keys[0].secret" ## Support tls min version, Possible values: VersionTLS10, VersionTLS11, VersionTLS12, VersionTLS13. diff --git a/roles/kubernetes/kubeadm/defaults/main.yml b/roles/kubernetes/kubeadm/defaults/main.yml index 789b87624..8f5111937 100644 --- a/roles/kubernetes/kubeadm/defaults/main.yml +++ b/roles/kubernetes/kubeadm/defaults/main.yml @@ -6,10 +6,3 @@ kubeadm_join_timeout: 120s # Enable kubeadm file discovery if anonymous access has been removed kubeadm_use_file_discovery: "{{ remove_anonymous_access }}" - -# If non-empty, will use this string as identification instead of the actual hostname -kube_override_hostname: >- - {%- if cloud_provider is defined -%} - {%- else -%} - {{ inventory_hostname }} - {%- endif -%} diff --git a/roles/kubernetes/node/defaults/main.yml b/roles/kubernetes/node/defaults/main.yml index a18444354..c51e00f0e 100644 --- a/roles/kubernetes/node/defaults/main.yml +++ b/roles/kubernetes/node/defaults/main.yml @@ -134,13 +134,6 @@ kubelet_logfiles_max_size: 10Mi ## Support custom flags to be passed to kubelet kubelet_custom_flags: [] -# If non-empty, will use this string as identification instead of the actual hostname -kube_override_hostname: >- - {%- if cloud_provider is defined -%} - {%- else -%} - {{ inventory_hostname }} - {%- endif -%} - # The read-only port for the Kubelet to serve on with no authentication/authorization. kube_read_only_port: 0 diff --git a/roles/kubespray-defaults/defaults/main/main.yml b/roles/kubespray-defaults/defaults/main/main.yml index 40551738e..3cd59d29b 100644 --- a/roles/kubespray-defaults/defaults/main/main.yml +++ b/roles/kubespray-defaults/defaults/main/main.yml @@ -253,11 +253,7 @@ kube_apiserver_bind_address: 0.0.0.0 kube_apiserver_port: 6443 # If non-empty, will use this string as identification instead of the actual hostname -kube_override_hostname: >- - {%- if cloud_provider is defined -%} - {%- else -%} - {{ inventory_hostname }} - {%- endif -%} +kube_override_hostname: "{{ inventory_hostname }}" # define kubelet config dir for dynamic kubelet # kubelet_config_dir: