refactor: unify inconsistent variables in apiserver endpoint (#13392)

This commit is contained in:
Dasmat Hansda
2026-10-12 06:25:22 +00:00
committed by GitHub
parent 7c57bc015d
commit 38f82cdce9
30 changed files with 170 additions and 192 deletions
@@ -81,3 +81,40 @@ ssl_ca_dirs_per_os_family:
RedHat:
- /etc/pki/tls
- /etc/pki/ca-trust
# Internal API server endpoints (cannot be overridden by inventory).
#
# _kube_apiserver_endpoint:
# External API server endpoint used for external access from outside the cluster
# (e.g., in admin kubeconfig written for localhost).
# Resolves to kube_apiserver_endpoint if defined; otherwise defaults to
# https://<first_control_plane_address>:<kube_apiserver_port>.
#
# _kube_apiserver_cluster_internal_endpoint:
# Internal endpoint used for in-cluster communication to the API server by
# cluster components, nodes (kubelet, kube-proxy), and pods (CNI plugins).
# If loadbalancer_apiserver_localhost is enabled, it points to the local load balancer
# proxy (https://127.0.0.1:<loadbalancer_apiserver_port>), otherwise falls back
# to _kube_apiserver_endpoint.
#
# _kube_apiserver_local_endpoint:
# Direct local endpoint to the kube-apiserver process running on the control plane node itself,
# bypassing any load balancer or proxy.
# Used on control plane nodes for local readiness checks, health checks (/healthz),
# and restart handlers.
#
# _kube_apiserver_endpoint_netloc:
# The <host>:<port> representation of _kube_apiserver_endpoint without the scheme.
# Used where kubeadm requires a host:port string (e.g. controlPlaneEndpoint, apiServerEndpoint).
_kube_apiserver_endpoint: >-
{{ kube_apiserver_endpoint if kube_apiserver_endpoint is defined
else 'https://' ~ (first_kube_control_plane_address | ansible.utils.ipwrap) ~ ':' ~ kube_apiserver_port }}
_kube_apiserver_cluster_internal_endpoint: >-
{{ kube_apiserver_cluster_internal_endpoint if kube_apiserver_cluster_internal_endpoint is defined
else (('https://127.0.0.1:' ~ loadbalancer_apiserver_port)
if loadbalancer_apiserver_localhost else _kube_apiserver_endpoint) }}
_kube_apiserver_local_endpoint: "https://{{ kube_apiserver_bind_address | regex_replace('^0\\.0\\.0\\.0$', '127.0.0.1') | regex_replace('^::$', '127.0.0.1') | ansible.utils.ipwrap }}:{{ kube_apiserver_port }}"
_kube_apiserver_endpoint_netloc: "{{ _kube_apiserver_endpoint | urlsplit('netloc') }}"