Skip to content

Commit

Permalink
Give better error when using default service acct (#842)
Browse files Browse the repository at this point in the history
* Give better error when using default service acct

If consul login fails when the service account name is `default` then
give an explicit warning that the reason it failed is because in
default installations that is not a support service account name.

We can't fail during injection because we support modifying the binding
rule such that `default` _is_ a valid svc account name.
  • Loading branch information
lkysow authored Nov 10, 2021
1 parent 0ad49a9 commit 8a63540
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BREAKING CHANGES:
IMPROVEMENTS:
* Control Plane
* TLS: Support PKCS1 and PKCS8 private keys for Consul certificate authority. [[GH-843](https://github.com/hashicorp/consul-k8s/pull/843)]
* Connect: Log a warning when ACLs are enabled and the default service account is used. [[GH-842](https://github.com/hashicorp/consul-k8s/pull/842)]
* CLI
* Delete jobs, cluster roles, and cluster role bindings on `uninstall`. [[GH-820](https://github.com/hashicorp/consul-k8s/pull/820)]
* Helm Chart
Expand Down
6 changes: 6 additions & 0 deletions control-plane/subcommand/connect-init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ func (c *Command) Run(args []string) int {
return err
}, backoff.WithMaxRetries(backoff.NewConstantBackOff(1*time.Second), numLoginRetries))
if err != nil {
if c.flagServiceAccountName == "default" {
c.logger.Warn("The service account name for this Pod is \"default\"." +
" In default installations this is not a supported service account name." +
" The service account name must match the name of the Kubernetes Service" +
" or the consul.hashicorp.com/connect-service annotation.")
}
c.logger.Error("Hit maximum retries for consul login", "error", err)
return 1
}
Expand Down

0 comments on commit 8a63540

Please sign in to comment.