Skip to content

Commit

Permalink
acl-token file readable by lifecycle sidecar
Browse files Browse the repository at this point in the history
Fix bug where the lifecycle sidecar (which runs as user consul-k8s)
could not read the acl-token because it was owned by root
  • Loading branch information
lkysow committed Dec 17, 2019
1 parent 629782b commit 02de5b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions connect-inject/container_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ EOF
-bearer-token-file="/var/run/secrets/kubernetes.io/serviceaccount/token" \
-token-sink-file="/consul/connect-inject/acl-token" \
-meta="pod=${POD_NAMESPACE}/${POD_NAME}"
{{- /* The acl token file needs to be read by the lifecycle-sidecar which runs
as non-root user consul-k8s. */}}
chmod 444 /consul/connect-inject/acl-token
{{- end }}
{{- if .WriteServiceDefaults }}
{{- /* We use -cas and -modify-index 0 so that if a service-defaults config
Expand Down
2 changes: 2 additions & 0 deletions connect-inject/container_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ func TestHandlerContainerInit_authMethod(t *testing.T) {
-bearer-token-file="/var/run/secrets/kubernetes.io/serviceaccount/token" \
-token-sink-file="/consul/connect-inject/acl-token" \
-meta="pod=${POD_NAMESPACE}/${POD_NAME}"
chmod 444 /consul/connect-inject/acl-token
/bin/consul services register \
-token-file="/consul/connect-inject/acl-token" \
Expand Down Expand Up @@ -678,6 +679,7 @@ EOF
-bearer-token-file="/var/run/secrets/kubernetes.io/serviceaccount/token" \
-token-sink-file="/consul/connect-inject/acl-token" \
-meta="pod=${POD_NAMESPACE}/${POD_NAME}"
chmod 444 /consul/connect-inject/acl-token
/bin/consul config write -cas -modify-index 0 \
-token-file="/consul/connect-inject/acl-token" \
/consul/connect-inject/service-defaults.hcl || true
Expand Down

0 comments on commit 02de5b6

Please sign in to comment.