Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodelocaldns: allow binding metrics address to host IP #7748

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ dns_mode: coredns
enable_nodelocaldns: true
nodelocaldns_ip: 169.254.25.10
nodelocaldns_health_port: 9254
nodelocaldns_bind_metrics_host_ip: false
# nodelocaldns_external_zones:
# - zones:
# - example.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data:
loop
bind {{ nodelocaldns_ip }}
forward . {{ block['nameservers'] | join(' ') }}
prometheus :9253
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:9253
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a question about the syntax {$FOO}, but that seems fine from https://coredns.io/manual/configuration/#environment-variables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the way Caddyfiles (the configuration file format used by CoreDNS) do interpolation.

log
{% if dns_etchosts | default(None) %}
hosts /etc/coredns/hosts {
Expand All @@ -39,7 +39,7 @@ data:
forward . {{ forwardTarget }} {
force_tcp
}
prometheus :9253
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:9253
health {{ nodelocaldns_ip }}:{{ nodelocaldns_health_port }}
{% if dns_etchosts | default(None) %}
hosts /etc/coredns/hosts {
Expand All @@ -56,7 +56,7 @@ data:
forward . {{ forwardTarget }} {
force_tcp
}
prometheus :9253
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:9253
}
ip6.arpa:53 {
errors
Expand All @@ -67,7 +67,7 @@ data:
forward . {{ forwardTarget }} {
force_tcp
}
prometheus :9253
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:9253
}
.:53 {
errors
Expand All @@ -76,7 +76,7 @@ data:
loop
bind {{ nodelocaldns_ip }}
forward . {{ upstreamForwardTarget }}
prometheus :9253
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:9253
{% if dns_etchosts | default(None) %}
hosts /etc/coredns/hosts {
fallthrough
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ spec:
args: [ "-localip", "{{ nodelocaldns_ip }}", "-conf", "/etc/coredns/Corefile", "-upstreamsvc", "coredns" ]
securityContext:
privileged: true
{% if nodelocaldns_bind_metrics_host_ip %}
env:
- name: MY_HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
{% endif %}
ports:
- containerPort: 53
name: dns
Expand Down
1 change: 1 addition & 0 deletions roles/kubespray-defaults/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ dns_mode: coredns
enable_nodelocaldns: true
nodelocaldns_ip: 169.254.25.10
nodelocaldns_health_port: 9254
nodelocaldns_bind_metrics_host_ip: false

# Should be set to a cluster IP if using a custom cluster DNS
manual_dns_server: ""
Expand Down