Skip to content

Commit

Permalink
impersonation: Clear config.BearerTokenFile when setting BearerToken.
Browse files Browse the repository at this point in the history
When running in a cluster, the BearerTokenFile is set to point to
`/var/run/secrets/kubernetes.io/serviceaccount/token` where the service
account's token is auto-mounted. If this value is not cleared, the
setting of the BearerToken field will have no effect. Relevant
documentation:
https://pkg.go.dev/k8s.io/client-go@v0.20.2/rest#Config.BearerTokenFile
  • Loading branch information
nairb774 committed Jan 25, 2021
1 parent 2d38de8 commit 6b215a1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions controllers/kustomization_impersonation.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (ki *KustomizeImpersonation) clientForServiceAccount(ctx context.Context) (
return nil, nil, err
}
restConfig.BearerToken = token
restConfig.BearerTokenFile = "" // Clear, as it overrides BearerToken

restMapper, err := apiutil.NewDynamicRESTMapper(restConfig)
if err != nil {
Expand Down

0 comments on commit 6b215a1

Please sign in to comment.