diff --git a/templates/client-daemonset.yaml b/templates/client-daemonset.yaml index 4035a0181f11..55bc053aaed7 100644 --- a/templates/client-daemonset.yaml +++ b/templates/client-daemonset.yaml @@ -191,7 +191,7 @@ spec: -node-meta=pod-name:${HOSTNAME} \ -node-meta=host-ip:${HOST_IP} \ -hcl='leave_on_terminate = true' \ - -disable-host-node-id=false \ + -disable-host-node-id={{ .Values.client.disableHostNodeID }} \ {{- if .Values.global.tls.enabled }} -hcl='ca_file = "/consul/tls/ca/tls.crt"' \ {{- if .Values.global.tls.enableAutoEncrypt }} diff --git a/test/unit/client-daemonset.bats b/test/unit/client-daemonset.bats index 24b60c6068bd..3e21192d735a 100755 --- a/test/unit/client-daemonset.bats +++ b/test/unit/client-daemonset.bats @@ -1206,3 +1206,27 @@ rollingUpdate: local actual=$(echo $security_context | jq -r .privileged) [ "${actual}" = "true" ] } + +#-------------------------------------------------------------------- +# client.disableHostNodeID + +@test "client/DaemonSet: disableHostNodeID defaults to false" { + cd `chart_dir` + local actual=$(helm template \ + -s templates/client-daemonset.yaml \ + . | tee /dev/stderr | \ + yq '.spec.template.spec.containers[0].command | any(contains("disable-host-node-id=false"))' \ + | tee /dev/stderr) + [ "${actual}" = "true" ] +} + +@test "client/DaemonSet: disableHostNodeID can be set to true" { + cd `chart_dir` + local actual=$(helm template \ + -s templates/client-daemonset.yaml \ + --set 'client.disableHostNodeID=true' \ + . | tee /dev/stderr | \ + yq '.spec.template.spec.containers[0].command | any(contains("disable-host-node-id=true"))' \ + | tee /dev/stderr) + [ "${actual}" = "true" ] +} diff --git a/values.yaml b/values.yaml index f49737f2b7e0..2111771087fd 100644 --- a/values.yaml +++ b/values.yaml @@ -699,6 +699,13 @@ client: # This also changes the clients' advertised IP to the `hostIP` rather than `podIP`. exposeGossipPorts: false + # Disable host node ID + # If true, consul clients will not use information from the host to generate a deterministic node ID + # and will instead generate a random node ID which will be persisted in the data directory. + # When two VMs are on the same underlying hardware, they can have node IDs that collide. Setting `disableHostNodeID` to true can work around the collision. + # Refer to https://www.consul.io/docs/agent/options#_disable_host_node_id for more info. + disableHostNodeID: false + # Resource settings for Client agents. # NOTE: The use of a YAML string is deprecated. Instead, set directly as a # YAML map.