Skip to content

Commit 2342d0c

Browse files
authored
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.
1 parent e6a5266 commit 2342d0c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

roles/kubespray_defaults/defaults/main/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ apiserver_loadbalancer_domain_name: "lb-apiserver.kubernetes.local"
646646
kube_apiserver_global_endpoint: |-
647647
{% if loadbalancer_apiserver is defined -%}
648648
https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port | default(kube_apiserver_port) }}
649-
{%- elif loadbalancer_apiserver_localhost and (loadbalancer_apiserver_port is not defined or loadbalancer_apiserver_port == kube_apiserver_port) -%}
650-
https://localhost:{{ kube_apiserver_port }}
649+
{%- elif loadbalancer_apiserver_localhost -%}
650+
https://localhost:{{ loadbalancer_apiserver_port | default(kube_apiserver_port) }}
651651
{%- else -%}
652652
https://{{ first_kube_control_plane_address | ansible.utils.ipwrap }}:{{ kube_apiserver_port }}
653653
{%- endif %}

roles/network_plugin/calico/templates/kubernetes-services-endpoint.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: kube-system
66
name: kubernetes-services-endpoint
77
data:
8-
{% if calico_bpf_enabled %}
8+
{% if calico_bpf_enabled or loadbalancer_apiserver_localhost %}
99
KUBERNETES_SERVICE_HOST: "{{ kube_apiserver_global_endpoint | urlsplit('hostname') }}"
1010
KUBERNETES_SERVICE_PORT: "{{ kube_apiserver_global_endpoint | urlsplit('port') }}"
1111
{% endif %}

0 commit comments

Comments
 (0)