Skip to content

Commit 4e11394

Browse files
committed
fix: bind loadbalancer healthcheck endpoint to localhost by default (#12809)
1 parent 0bffcac commit 4e11394

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

roles/kubernetes/node/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ kubelet_healthz_port: 10248
143143
# Bind address for healthz for Kubelet
144144
kubelet_healthz_bind_address: 127.0.0.1
145145

146+
# Bind addresses for healthz for the internal load balancer (nginx/haproxy)
147+
# Defaults to localhost for security. Set to 0.0.0.0 if external health checks are needed.
148+
loadbalancer_apiserver_healthcheck_bind_address: 127.0.0.1
149+
# Defaults to IPv6 localhost. Set to :: if external health checks are needed.
150+
loadbalancer_apiserver_healthcheck_bind_address_ipv6: ::1
151+
146152
# sysctl_file_path to add sysctl conf to
147153
sysctl_file_path: "/etc/sysctl.d/99-sysctl.conf"
148154

roles/kubernetes/node/templates/loadbalancer/haproxy.cfg.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ defaults
2121

2222
{% if loadbalancer_apiserver_healthcheck_port is defined -%}
2323
frontend healthz
24-
bind 0.0.0.0:{{ loadbalancer_apiserver_healthcheck_port }}
24+
bind {{ loadbalancer_apiserver_healthcheck_bind_address }}:{{ loadbalancer_apiserver_healthcheck_port }}
2525
{% if ipv6_stack -%}
26-
bind :::{{ loadbalancer_apiserver_healthcheck_port }}
26+
bind [{{ loadbalancer_apiserver_healthcheck_bind_address_ipv6 }}]:{{ loadbalancer_apiserver_healthcheck_port }}
2727
{% endif -%}
2828
mode http
2929
monitor-uri /healthz

roles/kubernetes/node/templates/loadbalancer/nginx.conf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ http {
4343

4444
{% if loadbalancer_apiserver_healthcheck_port is defined -%}
4545
server {
46-
listen {{ loadbalancer_apiserver_healthcheck_port }};
46+
listen {{ loadbalancer_apiserver_healthcheck_bind_address }}:{{ loadbalancer_apiserver_healthcheck_port }};
4747
{% if ipv6_stack -%}
48-
listen [::]:{{ loadbalancer_apiserver_healthcheck_port }};
48+
listen [{{ loadbalancer_apiserver_healthcheck_bind_address_ipv6 }}]:{{ loadbalancer_apiserver_healthcheck_port }};
4949
{% endif -%}
5050
location /healthz {
5151
access_log off;

0 commit comments

Comments
 (0)