Skip to content

Commit

Permalink
Allow for the creation of the client ACL token when the clients are d…
Browse files Browse the repository at this point in the history
…isabled
  • Loading branch information
rmakram-ims committed Feb 25, 2020
1 parent cb8dc5e commit 8729d12
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ spec:
{{- if .Values.client.snapshotAgent.enabled }}
-create-snapshot-agent-token=true \
{{- end }}
{{- if not (or (and (ne (.Values.client.enabled | toString) "-") .Values.client.enabled) (and (eq (.Values.client.enabled | toString) "-") .Values.global.enabled)) }}
{{- if not (or (.Values.client.createACLToken) (or (and (ne (.Values.client.enabled | toString) "-") .Values.client.enabled) (and (eq (.Values.client.enabled | toString) "-") .Values.global.enabled))) }}
-create-client-token=false \
{{- end }}
{{- if .Values.global.enableConsulNamespaces }}
Expand Down
48 changes: 48 additions & 0 deletions test/unit/server-acl-init-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,54 @@ load _helpers
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# client.createACLToken

@test "serverACLInit/Job: client acl option disabled in the absence of clients" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-acl-init-job.yaml \
--set 'global.bootstrapACLs=true' \
--set 'client.enabled=false' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-create-client-token"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "serverACLInit/Job: client acl option enabled by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-acl-init-job.yaml \
--set 'global.bootstrapACLs=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-create-client-token"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "serverACLInit/Job: client acl option enabled with even if not creating clients" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-acl-init-job.yaml \
--set 'global.bootstrapACLs=true' \
--set 'client.enabled=false' \
--set 'client.createACLToken=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-create-client-token"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "serverACLInit/Job: client acl option enabled when creating clients" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-acl-init-job.yaml \
--set 'global.bootstrapACLs=true' \
--set 'client.enabled=true' \
--set 'client.createACLToken=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-create-client-token"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

#--------------------------------------------------------------------
# global.tls.enabled

Expand Down
5 changes: 5 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ client:
image: null
join: null

# createACLToken is a way to force the creation of the client ACL token
# in the case where the client is an external deployment, such as Vault
# Only being considered when `global.bootstrapACLs` is set to `true`.
createACLToken: false

# dataDirectoryHostPath is an absolute path to a directory on the host machine
# to use as the Consul client data directory.
# If set to the empty string or null, the Consul agent will store its data
Expand Down

0 comments on commit 8729d12

Please sign in to comment.