Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth/kubernetes: support for dynamically reloading short-lived tokens #13595

Merged
merged 4 commits into from Jan 15, 2022

Conversation

tsaarni
Copy link
Contributor

@tsaarni tsaarni commented Jan 7, 2022

This change is continuation to hashicorp/vault-plugin-auth-kubernetes#122 where support was added for dynamically reloading Kubernetes short-lived tokens for better Kubernetes 1.21+ compatibility. This change takes the feature into use in Vault.

  • Uplift new version of Kubernetes auth plugin that does not store the service account token persistently to Vault storage.
  • Update the documentation to recommend local token again when running Vault inside cluster.

Fixes #12855

Signed-off-by: Tero Saarni tero.saarni@est.tech

* Uplift new version of Kubernetes auth plugin that does not store the
  service account token persistently to Vault storage.

* Update the documentation to recommend local token again when running
  Vault inside cluster.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@vercel vercel bot temporarily deployed to Preview – vault-storybook January 7, 2022 17:00 Inactive
@@ -96,7 +96,7 @@ require (
github.com/hashicorp/vault-plugin-auth-gcp v0.11.3
github.com/hashicorp/vault-plugin-auth-jwt v0.11.4
github.com/hashicorp/vault-plugin-auth-kerberos v0.5.0
github.com/hashicorp/vault-plugin-auth-kubernetes v0.11.3
github.com/hashicorp/vault-plugin-auth-kubernetes v0.7.1-0.20220107030939-d289258274b7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tvoran Would it be possible to tag a new release of vault-plugin-auth-kubernetes so that we can rever to proper version number?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be tagging a new release of vault-plugin-auth-kubernetes later in Vault's release cycle, so this pseudo version is good for now.

@tsaarni
Copy link
Contributor Author

tsaarni commented Jan 7, 2022

@tomhjp, @tvoran I've sent this PR to uplift hashicorp/vault-plugin-auth-kubernetes#122 into Vault.

I added proposal for documentation changes, though I feel they are maybe bit unnecessarily complicated for in-cluster deployment. User should not need to be aware about short-lived tokens anymore as reloading is transparent - though I guess the information is necessary since user can be running older version of Vault.

(for running Vault outside-cluster, I'm not sure if copying service account tokens from cluster has ever been that good idea - I think client cert support might have been better)

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@@ -96,7 +96,7 @@ require (
github.com/hashicorp/vault-plugin-auth-gcp v0.11.3
github.com/hashicorp/vault-plugin-auth-jwt v0.11.4
github.com/hashicorp/vault-plugin-auth-kerberos v0.5.0
github.com/hashicorp/vault-plugin-auth-kubernetes v0.11.3
github.com/hashicorp/vault-plugin-auth-kubernetes v0.7.1-0.20220107030939-d289258274b7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be tagging a new release of vault-plugin-auth-kubernetes later in Vault's release cycle, so this pseudo version is good for now.

@@ -0,0 +1,2 @@
```release-note:improvement
auth/kubernetes: Added support for short-lived tokens for Kubernetes 1.21+ compatibility
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding "dynamically reloading" somewhere in here? Previously, short-lived tokens worked, just not well :)

Suggested change
auth/kubernetes: Added support for short-lived tokens for Kubernetes 1.21+ compatibility
auth/kubernetes: Added support for dynamically reloading short-lived tokens for better Kubernetes 1.21+ compatibility
```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

go.sum Outdated Show resolved Hide resolved
@tvoran tvoran requested a review from tomhjp January 7, 2022 20:56
@vercel vercel bot temporarily deployed to Preview – vault-storybook January 8, 2022 08:32 Inactive
@tsaarni tsaarni changed the title auth/kubernetes: support for short-lived tokens auth/kubernetes: support for dynamically reloading short-lived tokens Jan 8, 2022
Copy link
Contributor

@tomhjp tomhjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this! A few small suggestions. This should definitely make it into 1.10. For now we should probably just get this merged into main, and then it will automatically go live on the website when 1.10 gets released but not before.

@@ -155,6 +154,7 @@ table summarizes the options, each of which is explained in more detail below.

| Option | All tokens are short-lived | Can revoke tokens early | Other considerations |
| ------------------------------------ | -------------------------- | ----------------------- | -------------------- |
| Use local token as reviewer JWT | Yes | Yes | Requires Vault VERSION_TODO |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Use local token as reviewer JWT | Yes | Yes | Requires Vault VERSION_TODO |
| Use local token as reviewer JWT | Yes | Yes | Requires Vault (1.10+) to be deployed on the Kubernetes cluster |

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

kubernetes_host=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT
```

!> **Note:** Requires Vault VERSION_TODO. In earlier versions the service account
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!> **Note:** Requires Vault VERSION_TODO. In earlier versions the service account
!> **Note:** Requires Vault 1.10+. In earlier versions the service account

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@@ -168,6 +168,23 @@ short-lived tokens. If you would like to disable this, set

[k8s-extended-tokens]: https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/#options

#### Use local service account token as the reviewer JWT

When running Vault in a Kubernetes pod the recommended option is to use local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When running Vault in a Kubernetes pod the recommended option is to use local
When running Vault in a Kubernetes pod the recommended option is to use the pod's local

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Comment on lines 175 to 176
short-lived tokens. Local token and CA certificate are used by configuring the
auth method without setting `token_reviewer_jwt` and `kubernetes_ca_cert`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
short-lived tokens. Local token and CA certificate are used by configuring the
auth method without setting `token_reviewer_jwt` and `kubernetes_ca_cert`.
short-lived tokens. To use the local token and CA certificate, omit
`token_reviewer_jwt` and `kubernetes_ca_cert` when configuring the auth method.
Vault will attempt to load them from `token` and `ca.crt` respectively inside
the default mount folder `/var/run/secrets/kubernetes.io/serviceaccount/`.

The first half of the suggestion is just re-wording. With the second half, I was trying to demystify how it works, but perhaps it's too detailed. Take or leave the suggestions as you like :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good clarification, thanks! Taken it as such :)

@vercel vercel bot temporarily deployed to Preview – vault-storybook January 12, 2022 07:23 Inactive
@tvoran tvoran merged commit 3f7dd79 into hashicorp:main Jan 15, 2022
tvoran pushed a commit that referenced this pull request Jan 19, 2022
…#13595)

* auth/kubernetes: support for short-lived tokens

* Uplift new version of Kubernetes auth plugin that does not store the
  service account token persistently to Vault storage.

* Update the documentation to recommend local token again when running
  Vault inside cluster.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* Added changelog entry

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* clarification to changelog entry, executed go mod tidy

* clarifications and added targeted release version
tvoran pushed a commit that referenced this pull request Jan 19, 2022
…#13595)

* auth/kubernetes: support for short-lived tokens

* Uplift new version of Kubernetes auth plugin that does not store the
  service account token persistently to Vault storage.

* Update the documentation to recommend local token again when running
  Vault inside cluster.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* Added changelog entry

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* clarification to changelog entry, executed go mod tidy

* clarifications and added targeted release version
tvoran added a commit that referenced this pull request Jan 22, 2022
…lived tokens into release/1.9.x (#13698)

* auth/kubernetes: support for dynamically reloading short-lived tokens (#13595)

* auth/kubernetes: support for short-lived tokens

* Uplift new version of Kubernetes auth plugin that does not store the
  service account token persistently to Vault storage.

* Update the documentation to recommend local token again when running
  Vault inside cluster.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* Added changelog entry

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* clarification to changelog entry, executed go mod tidy

* clarifications and added targeted release version

* update available version to 1.9.3+ and changelog

renamed changelog file to the backport pr number.

* update go.mod to k8s-auth@v0.11.4

Co-authored-by: Tero Saarni <tero.saarni@est.tech>
Co-authored-by: Theron Voran <tvoran@users.noreply.github.com>
joatmon08 pushed a commit that referenced this pull request Jan 25, 2022
…#13595)

* auth/kubernetes: support for short-lived tokens

* Uplift new version of Kubernetes auth plugin that does not store the
  service account token persistently to Vault storage.

* Update the documentation to recommend local token again when running
  Vault inside cluster.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* Added changelog entry

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* clarification to changelog entry, executed go mod tidy

* clarifications and added targeted release version
qk4l pushed a commit to qk4l/vault that referenced this pull request Feb 4, 2022
…hashicorp#13595)

* auth/kubernetes: support for short-lived tokens

* Uplift new version of Kubernetes auth plugin that does not store the
  service account token persistently to Vault storage.

* Update the documentation to recommend local token again when running
  Vault inside cluster.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* Added changelog entry

Signed-off-by: Tero Saarni <tero.saarni@est.tech>

* clarification to changelog entry, executed go mod tidy

* clarifications and added targeted release version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubernetes Auth Method documentation not compatible with Kubernetes v1.21+
4 participants