Key Concepts
Secret
A Kubernetes resource that stores sensitive data as base64-encoded key-value pairs.
Type
Secret type indicates the intended use (Opaque, TLS, Docker, etc.) and may enforce required keys.
Data
Base64-encoded key-value pairs containing the actual secret values.
stringData
Plain text values that are automatically base64-encoded when the Secret is created.
Required Permissions
| Action | Permission |
|---|---|
| View secrets | iam:project:infrastructure:kubernetes:read |
| Create secret | iam:project:infrastructure:kubernetes:write |
| Edit secret | iam:project:infrastructure:kubernetes:write |
| Delete secret | iam:project:infrastructure:kubernetes:delete |
Secret data is masked in the list view for security. Click on a Secret to view the actual (base64-encoded) values in the detail view.
Secret Types
| Type | Label | Description |
|---|---|---|
| Opaque | Opaque | Generic secret for arbitrary data (default) |
| kubernetes.io/tls | TLS | TLS certificate and private key |
| kubernetes.io/dockerconfigjson | Docker | Docker registry credentials |
| kubernetes.io/dockercfg | Docker | Legacy Docker registry credentials |
| kubernetes.io/service-account-token | SA Token | ServiceAccount token (auto-generated) |
| kubernetes.io/basic-auth | Basic Auth | Username and password |
| kubernetes.io/ssh-auth | SSH | SSH private key |
| bootstrap.kubernetes.io/token | Bootstrap | Bootstrap token for node joining |
| helm.sh/release.v1 | Helm | Helm release metadata |
How to View Secrets
How to View Secret Details
How to Create a Secret
Write YAML
Enter the Secret manifest in YAML format. Key fields:
type- Secret type (defaults to Opaque)data- Base64-encoded key-value pairsstringData- Plain text values (auto-encoded)
How to Edit a Secret
Modify Data
Edit the Secret content. You can:
- Update existing values
- Add new keys
- Change the type (with caution)
How to Delete a Secret
Using Secrets in Pods
As Environment Variables
As Volume Mounts
For Image Pull
Creating Common Secret Types
TLS Secret
Docker Registry Secret
Basic Auth Secret
Troubleshooting
Pod fails to start with Secret error
Pod fails to start with Secret error
- Verify the Secret exists in the same namespace as the pod
- Check Secret name spelling in pod spec
- Ensure referenced keys exist in the Secret
- Use
optional: trueif Secret might not exist
Image pull fails with authentication error
Image pull fails with authentication error
- Verify imagePullSecrets is configured on the pod or ServiceAccount
- Check the Docker Secret contains valid credentials
- Ensure the Secret type is
kubernetes.io/dockerconfigjson - Verify the registry URL in the Secret matches the image registry
TLS Secret not working
TLS Secret not working
- Ensure type is
kubernetes.io/tls - Verify keys are exactly
tls.crtandtls.key - Check certificate and key are valid and match
- Ensure values are base64-encoded
Secret data appears corrupted
Secret data appears corrupted
- Values must be base64-encoded in
datafield - Use
stringDatafor plain text (auto-encoded) - Don’t double-encode values
- Verify encoding with
echo "<value>" | base64 -d
Secret changes not reflected in pod
Secret changes not reflected in pod
- Pods don’t automatically reload Secrets
- Restart the deployment/pod to pick up changes
- Volume-mounted Secrets eventually update (kubelet sync)
- Environment variables from Secrets never auto-update
Cannot see Secret data
Cannot see Secret data
- List view masks data for security (shows ***)
- Click the Secret name to view actual values in detail view
- YAML view shows base64-encoded data
FAQ
Are Secrets actually secure?
Are Secrets actually secure?
By default, Secrets are only base64-encoded, not encrypted. For true security, enable encryption at rest in your cluster and use RBAC to restrict access. Consider external secret managers (Vault, AWS Secrets Manager) for highly sensitive data.
What's the difference between data and stringData?
What's the difference between data and stringData?
data expects base64-encoded values. stringData accepts plain text and automatically encodes it. Use
stringData when creating Secrets manually for convenience.Can I use Secrets across namespaces?
Can I use Secrets across namespaces?
No. Secrets are namespace-scoped. A pod can only reference Secrets in its own namespace. For shared secrets, create copies in each namespace or use external secret management.
Why is my Secret type important?
Why is my Secret type important?
Secret types help Kubernetes validate required keys and enable specific functionality. For example,
kubernetes.io/tls requires tls.crt and tls.key, and kubernetes.io/dockerconfigjson is recognized by kubelet for image pulls.How do I rotate Secrets?
How do I rotate Secrets?
Update the Secret with new values, then restart pods that use it. For zero-downtime rotation, consider using external secret managers with automatic rotation support.
What's the size limit for Secrets?
What's the size limit for Secrets?
Secrets are limited to 1 MiB, same as ConfigMaps. For larger data, consider external storage or splitting into multiple Secrets.
Should I commit Secrets to version control?
Should I commit Secrets to version control?
Never commit plain Secrets to version control. Use sealed-secrets, SOPS, or external secret managers to safely store encrypted secret references in Git.
How do ServiceAccount tokens work?
How do ServiceAccount tokens work?
Kubernetes automatically creates
kubernetes.io/service-account-token Secrets for ServiceAccounts. These contain tokens for authenticating to the API server.