Skip to content

Commit

Permalink
Merge pull request hashicorp#278 from hashicorp/auth-method
Browse files Browse the repository at this point in the history
Allow setting the -acl-auth-method flag
  • Loading branch information
lkysow authored Nov 5, 2019
2 parents 341f785 + 56be9a6 commit bb4bfa3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion templates/connect-inject-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ spec:
-envoy-image="{{ .Values.connectInject.imageEnvoy }}" \
{{ end -}}
-listen=:8080 \
{{- if .Values.global.bootstrapACLs }}
{{- if .Values.connectInject.overrideAuthMethodName }}
-acl-auth-method="{{ .Values.connectInject.overrideAuthMethodName }}" \
{{ else if .Values.global.bootstrapACLs }}
-acl-auth-method="{{ .Release.Name }}-consul-k8s-auth-method" \
{{- end }}
{{- if .Values.connectInject.centralConfig.enabled }}
Expand Down
47 changes: 47 additions & 0 deletions test/unit/connect-inject-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,50 @@ load _helpers
yq '.spec.template.spec.containers[0].command | any(contains("-default-protocol=\"grpc\""))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# authMethod

@test "connectInject/Deployment: -acl-auth-method is not set by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-acl-auth-method="))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "connectInject/Deployment: -acl-auth-method is set when global.bootstrapACLs is true" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'global.bootstrapACLs=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-acl-auth-method=\"release-name-consul-k8s-auth-method\""))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "connectInject/Deployment: -acl-auth-method is set to connectInject.overrideAuthMethodName" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'connectInject.overrideAuthMethodName=override' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-acl-auth-method=\"override\""))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "connectInject/Deployment: -acl-auth-method is overridden by connectInject.overrideAuthMethodName if global.bootstrapACLs is true" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'global.bootstrapACLs=true' \
--set 'connectInject.overrideAuthMethodName=override' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-acl-auth-method=\"override\""))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
4 changes: 4 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ connectInject:
# Requires Consul >= v1.5 and consul-k8s >= v0.8.0.
aclBindingRuleSelector: "serviceaccount.name!=default"

# If not using global.bootstrapACLs and instead manually setting up an auth
# method for Connect inject, set this to the name of your auth method.
overrideAuthMethodName: ""

# Requires Consul >= v1.5 and consul-k8s >= v0.8.1.
centralConfig:
enabled: false
Expand Down

0 comments on commit bb4bfa3

Please sign in to comment.