Skip to content

Commit

Permalink
Use disableHostNodeID param in values.yaml to configure Consul client (
Browse files Browse the repository at this point in the history
…hashicorp#901)

* Use disableHostNodeID param in values.yaml to configure Consul client
* Remove comment about multi-agent testing since this will be a DaemonSet
* Add bats tests for disableHostNodeID
  • Loading branch information
ilhaan authored Apr 20, 2021
1 parent 44600e1 commit 67285d6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion templates/client-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
24 changes: 24 additions & 0 deletions test/unit/client-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
7 changes: 7 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 67285d6

Please sign in to comment.