diff --git a/docs/etcd.md b/docs/etcd.md index 574cc31d2..2efc85ce8 100644 --- a/docs/etcd.md +++ b/docs/etcd.md @@ -44,3 +44,9 @@ kubeEtcd: service: enabled: false ``` + +To fully override metrics exposition urls, define it in the inventory with: + +```yaml +etcd_listen_metrics_urls: "http://0.0.0.0:2381" +``` diff --git a/roles/etcd/templates/etcd.env.j2 b/roles/etcd/templates/etcd.env.j2 index c3013f679..2abd9cc80 100644 --- a/roles/etcd/templates/etcd.env.j2 +++ b/roles/etcd/templates/etcd.env.j2 @@ -5,7 +5,9 @@ ETCD_INITIAL_ADVERTISE_PEER_URLS={{ etcd_peer_url }} ETCD_INITIAL_CLUSTER_STATE={% if etcd_cluster_is_healthy.rc == 0 | bool %}existing{% else %}new{% endif %} ETCD_METRICS={{ etcd_metrics }} -{% if etcd_metrics_port is defined %} +{% if etcd_listen_metrics_urls is defined %} +ETCD_LISTEN_METRICS_URLS={{ etcd_listen_metrics_urls }} +{% elif etcd_metrics_port is defined %} ETCD_LISTEN_METRICS_URLS=http://{{ etcd_address }}:{{ etcd_metrics_port }},http://127.0.0.1:{{ etcd_metrics_port }} {% endif %} ETCD_LISTEN_CLIENT_URLS=https://{{ etcd_address }}:2379,https://127.0.0.1:2379 diff --git a/roles/kubernetes/control-plane/templates/kubeadm-config.v1beta3.yaml.j2 b/roles/kubernetes/control-plane/templates/kubeadm-config.v1beta3.yaml.j2 index d284c7543..64105719b 100644 --- a/roles/kubernetes/control-plane/templates/kubeadm-config.v1beta3.yaml.j2 +++ b/roles/kubernetes/control-plane/templates/kubeadm-config.v1beta3.yaml.j2 @@ -58,6 +58,9 @@ etcd: election-timeout: "{{ etcd_election_timeout }}" heartbeat-interval: "{{ etcd_heartbeat_interval }}" auto-compaction-retention: "{{ etcd_compaction_retention }}" +{% if etcd_listen_metrics_urls is defined %} + listen-metrics-urls: "{{ etcd_listen_metrics_urls }}" +{% endif %} {% if etcd_snapshot_count is defined %} snapshot-count: "{{ etcd_snapshot_count }}" {% endif %}