Table of Contents
Table of Contents
Further Reading
How Kubernetes Secrets work
Secrets keep credentials out of container images and source code. Pods receive them at runtime.
- Create a Secret from literal values, files, or a manifest.
- Reference the Secret in a pod or Job spec.
- Kubernetes exposes it as environment variables or mounted files.
- The application or test reads the values at runtime.
- Rotate the Secret, and new pods pick up the new values.
Secrets vs. ConfigMaps
Both inject configuration into pods. Only Secrets are meant for sensitive data.
Why Secrets matter in Kubernetes
Secrets are central to Kubernetes security and configuration. Without them, clusters risk credential leaks and compliance problems.
- Protection: credentials stay out of version control
- Environment flexibility: different credentials for test, staging, and production
- Central management: one place for credentials across workloads
- Secure automation: CI/CD tools and cloud services get credentials safely
- Compliance: supports data protection requirements
Consider a SaaS team that found an API key committed in a test file. Moving it into a Secret and rotating it closed the gap without changing the test logic.
Common challenges with Secrets
- Weak storage: Secrets left unencrypted at rest or in plain files
- Broad access: too many users or service accounts can read them
- Versioning: changes to sensitive config are hard to track
- Rotation: expired or stale Secrets cause failures and risk
- Namespace leaks: Secrets shared across environments by mistake
- Integration: aligning Secrets across Kubernetes, CI/CD, and test tools
Best practices
- Encrypt at rest: enable encryption for Secrets in etcd
- Least privilege: restrict who and what can read each Secret
- External managers: use Vault or a cloud secrets manager for rotation
- Rotate regularly: replace credentials on a schedule
- Scope by namespace: keep Secrets inside the environment that needs them
How Secrets relate to Testkube
Testkube uses Kubernetes Secrets to handle sensitive data during test execution. Credentials reach tests safely without living in test code.
- Native Secrets: credentials and tokens stored as Kubernetes Secrets
- Pod injection: values exposed as environment variables or mounted files
- Less exposure: sensitive values kept out of test code, logs, and reports
- External stores: works with HashiCorp Vault or AWS Secrets Manager
- Parameterized tests: Secret-backed inputs for dynamic workflows
- CI/CD: pipelines pass credentials securely to tests
Real-world examples
- Authenticated APIs: a QA engineer stores API keys as Secrets for endpoint tests
- Database access: a DevOps team connects Testkube tests to internal databases with Secrets
- Rotation: a platform engineer automates Secret rotation across namespaces
- Integration tests: a developer mounts Secrets into Testkube pods for third-party APIs
- Audits: a security team reviews how tests use Secrets



