Calico: populate kubernetes-services-endpoint for localhost LB (#12598)

When loadbalancer_apiserver_localhost is enabled, Calico falls back to the
Kubernetes service IP because the kubernetes-services-endpoint ConfigMap is
empty. CNI then fails to reach the API server even though an nginx proxy is
listening on localhost.

Update kube_apiserver_global_endpoint to always reference the localhost load
balancer (respecting the configured port) and populate the ConfigMap for both
eBPF and localhost LB modes.
This commit is contained in:
Chris Ricker
2025-12-03 10:22:19 -05:00
committed by GitHub
parent e6a5266bad
commit 2342d0cd57
2 changed files with 3 additions and 3 deletions

View File

@@ -646,8 +646,8 @@ apiserver_loadbalancer_domain_name: "lb-apiserver.kubernetes.local"
kube_apiserver_global_endpoint: |- kube_apiserver_global_endpoint: |-
{% if loadbalancer_apiserver is defined -%} {% if loadbalancer_apiserver is defined -%}
https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port | default(kube_apiserver_port) }} https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port | default(kube_apiserver_port) }}
{%- elif loadbalancer_apiserver_localhost and (loadbalancer_apiserver_port is not defined or loadbalancer_apiserver_port == kube_apiserver_port) -%} {%- elif loadbalancer_apiserver_localhost -%}
https://localhost:{{ kube_apiserver_port }} https://localhost:{{ loadbalancer_apiserver_port | default(kube_apiserver_port) }}
{%- else -%} {%- else -%}
https://{{ first_kube_control_plane_address | ansible.utils.ipwrap }}:{{ kube_apiserver_port }} https://{{ first_kube_control_plane_address | ansible.utils.ipwrap }}:{{ kube_apiserver_port }}
{%- endif %} {%- endif %}

View File

@@ -5,7 +5,7 @@ metadata:
namespace: kube-system namespace: kube-system
name: kubernetes-services-endpoint name: kubernetes-services-endpoint
data: data:
{% if calico_bpf_enabled %} {% if calico_bpf_enabled or loadbalancer_apiserver_localhost %}
KUBERNETES_SERVICE_HOST: "{{ kube_apiserver_global_endpoint | urlsplit('hostname') }}" KUBERNETES_SERVICE_HOST: "{{ kube_apiserver_global_endpoint | urlsplit('hostname') }}"
KUBERNETES_SERVICE_PORT: "{{ kube_apiserver_global_endpoint | urlsplit('port') }}" KUBERNETES_SERVICE_PORT: "{{ kube_apiserver_global_endpoint | urlsplit('port') }}"
{% endif %} {% endif %}