OpsCanary
Back to daily brief
securitysecretsPractitioner

Kubernetes Auth Method: Mastering Secrets with Service Account Tokens

5 min read HashiCorp DocsApr 27, 2026
Share
PractitionerHands-on experience recommended

Kubernetes authentication is essential for managing secrets securely within your applications. By using service account tokens, you can easily integrate Vault into your Kubernetes Pods, allowing for seamless authentication and access to sensitive data. This method not only simplifies token management but also enhances security by leveraging Kubernetes' built-in capabilities.

The Kubernetes auth method operates by authenticating with Vault using a Kubernetes Service Account Token. The default endpoint for this authentication is auth/kubernetes/login, where you can submit your JWT. Key parameters include kubernetes_host, which specifies the address of your Kubernetes host, and kubernetes_ca_cert, which is necessary for secure communication. Starting with Kubernetes v1.21, the BoundServiceAccountTokenVolume feature is enabled by default, further streamlining the process of managing service account tokens. Be sure to set disable_iss_validation to true when upgrading to Kubernetes v1.21+ to avoid issues with token validation.

In production, be mindful of the potential pitfalls. For instance, sharing JWT tokens between applications can lead to unintended access, so ensure that your applications are isolated. Additionally, Vault versions prior to 1.9.3 have limitations regarding token management, as they only read the service account token once. Always verify that your setup adheres to the latest version requirements to avoid authentication failures.

Key takeaways

  • Use Kubernetes Service Account Tokens to authenticate with Vault seamlessly.
  • Set `disable_iss_validation` to true when upgrading to Kubernetes v1.21+.
  • Ensure your `kubernetes_host` and `kubernetes_ca_cert` are correctly configured for secure communication.
  • Avoid sharing JWT tokens between applications to prevent unauthorized access.
  • Upgrade to Vault 1.9.3+ to leverage improved token management capabilities.

Why it matters

In production, managing secrets securely is non-negotiable. Using Kubernetes service account tokens allows for streamlined access to sensitive data while minimizing the risk of exposure.

Code examples

Bash
$vault write auth/kubernetes/login role=demo jwt=...
Bash
$vault write auth/kubernetes/config \token_reviewer_jwt="<your reviewer service account JWT>" \kubernetes_host=https://192.168.99.100:<your TCP port or blank for 443> \kubernetes_ca_cert=@ca.crt
Bash
$vault write auth/kubernetes/role/demo \bound_service_account_names=myapp \bound_service_account_namespaces=default \policies=default \audience=myapp \ttl=1h

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.