Kubernetes secrets types define how sensitive data is classified, stored, and accessed inside a cluster. Understanding the specific semantics of each type helps platform teams balance security, compliance, and operational simplicity. Without a clear mapping between secret types and workload requirements, teams risk misconfigurations that expose credentials or violate data isolation policies.
Built-in secrets and their behavior
Kubernetes provides a built-in secret type represented by the kubernetes.io/opaque string. This generic type allows any unstructured key-value data to be stored as base64-encoded strings. While flexible, opaque secrets do not enforce data structure or validation, placing the burden of correctness on the creator and consumer. The API server stores the payload in etcd, and the kubelet writes the content to disk on nodes, making encryption at rest a critical control for opaque secrets.
Service account tokens
Service account tokens are a distinct built-in secret type automatically mounted into pods with associated service accounts. These secrets include a JSON Web Token signed by the API server, enabling authentication to the API. Unlike opaque secrets, token secrets carry an expiration and are bound to the service account lifecycle. Rotating tokens and tightening admission policies can reduce the blast radius of compromised pods.
Custom secrets using the Kubernetes API
Operators and controllers can define additional Kubernetes secrets types by registering custom resources or using the standard API with well-known keys. For example, kubernetes.io/tls carries a TLS certificate and key, while cloud providers may document their own key prefixes and formats. Custom types are not enforced by the control plane beyond standard RBAC and schema validation, so tooling and documentation are essential for consistent usage across teams.
Structured data and versioning considerations
Treating opaque secrets as opaque blobs makes structured updates and version tracking difficult. Teams often encode configuration formats such as JSON or YAML into key-value pairs, which obscurs diffing and merging in source control. Using dedicated secret managers and controllers that reconcile structured data with Kubernetes secrets helps maintain readability, auditability, and safer rollouts across environments.
External secrets and synchronization patterns
Many organizations store credentials in external vaults such as HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault. External secrets operators synchronize these entries into Kubernetes secrets, optionally mapping cloud provider types to kubernetes.io/opaque or domain-specific annotations. This pattern centralizes lifecycle management and access policies while still allowing pods to consume standard Kubernetes secrets.
Rotation, reconciliation, and security posture
Automated rotation of database passwords and API keys requires tight coupling between the vault backend and Kubernetes secrets. Operators must handle reconciliation loops, ensuring that updated values are propagated without disrupting running workloads. Monitoring and alerting on secret changes, combined with short TTLs where possible, significantly improve the security posture around Kubernetes secrets types.