Overview
Sealed Secrets provides a secure way to store Kubernetes secrets in Git repositories. It encrypts secrets using asymmetric cryptography, allowing you to commit encrypted secrets to version control while maintaining security.Why Sealed Secrets?
Standard Kubernetes Secrets are base64-encoded, not encrypted. This makes them unsafe to commit to Git. Sealed Secrets solves this by:- Encrypting secrets with a public key
- Storing encrypted secrets safely in Git
- Automatically decrypting secrets in the cluster using a private key
- Preventing secret exposure in version control
Security Model
Encryption Process
- Public key encryption: Secrets are encrypted using a public certificate
- Safe storage: Encrypted SealedSecret resources can be committed to Git
- Cluster decryption: The controller decrypts secrets using a private key stored only in the cluster
- Automatic creation: Kubernetes Secret is automatically created from the SealedSecret
Key Management
- Private key: Stored securely in the
kube-systemnamespace, never leaves the cluster - Public certificate: Can be safely distributed for encryption
- Key rotation: Supports automatic key rotation for enhanced security
Installation
Install Sealed Secrets Controller
Deploy the controller using Helm:Install kubeseal CLI
Install thekubeseal client tool for encrypting secrets:
Verify Installation
Fetch the public certificate to verify the controller is running:Creating Sealed Secrets
Method 1: From Literal Values
Create a sealed secret directly from literal values:Method 2: From Existing Secret File
If you have an existing secret YAML file:Method 3: Offline Encryption
For CI/CD pipelines without cluster access, fetch the certificate once:Sealed Secret Structure
Example SealedSecret Resource
encryptedData: Each secret key is encrypted separatelytemplate.metadata: Metadata for the generated Kubernetes Secretnamespace: SealedSecret and Secret must be in the same namespace
Deploying Sealed Secrets
Apply to Cluster
- Detects the SealedSecret resource
- Decrypts the data using the private key
- Creates a standard Kubernetes Secret
Verify Deployment
Check that the Secret was created:Using Secrets in Deployments
Reference the decrypted secret in your deployments:Scope and Permissions
Sealed Secrets support three encryption scopes:1. Strict (default)
Secret is sealed to a specific namespace and name:2. Namespace-wide
Secret can be decrypted in any Secret with any name in the same namespace:3. Cluster-wide
Secret can be decrypted in any namespace:Key Rotation and Renewal
Automatic Key Renewal
The controller automatically generates new keys every 30 days but keeps old keys to decrypt existing secrets.Manual Key Rotation
Force key rotation:Re-encrypting After Rotation
After key rotation, re-encrypt secrets with the new key:Backup and Disaster Recovery
Backup Private Keys
Backup the private key for disaster recovery:Restore Private Keys
Restore keys in a new cluster:Troubleshooting
Secret Not Decrypting
-
Check controller logs:
-
Verify SealedSecret exists:
-
Check for decryption errors:
Wrong Namespace or Name
If usingstrict scope, ensure the SealedSecret name and namespace match:
Certificate Fetch Fails
Ifkubeseal --fetch-cert fails:
-
Verify controller is running:
-
Check service exists:
Production Best Practices
1. Version Control Strategy
- Commit SealedSecret YAML files to Git
- Never commit plain Secret files
- Use separate sealed secrets for different environments
2. Secret Rotation
- Rotate secrets regularly (e.g., every 90 days)
- Re-encrypt with new certificates after key rotation
- Update applications to use new secrets
3. Access Control
- Restrict access to the sealed-secrets-controller namespace
- Use RBAC to limit who can view Secrets
- Audit secret access using admission controllers
4. Monitoring
- Monitor controller logs for decryption failures
- Alert on SealedSecret resources that fail to create Secrets
- Track certificate expiration
5. Multi-Cluster Strategy
- Use separate keys per cluster
- Avoid sharing private keys between environments
- Use offline encryption in CI/CD pipelines
Resources
Next Steps
TLS Certificates
Automated certificate management
Best Practices
Security hardening guidelines

