All MongoDB credentials have been moved from configuration files to Kubernetes Secrets for enhanced security.
- Passwords removed from
helm/mongodb/values.yaml - Passwords removed from
helm/mongodb/values-dev.yaml - Passwords removed from
helm/mongodb/values-test.yaml - Passwords removed from
helm/mongodb/values-prod.yaml
helm/mongodb/values.yaml- Removed password fields, kept username and databasehelm/mongodb/values-dev.yaml- Removed password fieldshelm/mongodb/values-test.yaml- Removed password fieldshelm/mongodb/values-prod.yaml- Removed password fieldshelm/mongodb/templates/secret.yaml- Updated to handle external secretshelm/mongodb/README.md- Added secrets management section.github/workflows/deploy-mongodb.yml- Added "Create MongoDB Secret" step
helm/mongodb/SECRETS.md- Complete secrets management guide (best practices, vault integration)helm/mongodb/setup-secrets.sh- Helper script to create secretsdocs/MONGODB_MIGRATION.md- Updated with secret creation steps
Option A: Using the helper script
chmod +x ./helm/mongodb/setup-secrets.sh
./helm/mongodb/setup-secrets.sh \
-n 86cabb-dev \
-p "YourSecurePassword123!" \
-a "YourAdminPassword456!"Option B: Using kubectl directly
kubectl create secret generic mongodb-secret \
-n 86cabb-dev \
--from-literal=mongodb-password='YourSecurePassword123!' \
--from-literal=mongodb-admin-password='YourAdminPassword456!'helm install mongodb ./helm/mongodb \
-n 86cabb-dev \
-f ./helm/mongodb/values-dev.yamlkubectl get secret mongodb-secret -n 86cabb-dev
kubectl get statefulset mongodb -n 86cabb-dev
kubectl logs mongodb-0 -n 86cabb-devAdd these secrets to your GitHub repository:
Settings → Secrets and variables → Actions → New repository secret
Create for each environment:
| Environment | Secret Name | Example Value |
|---|---|---|
| Development | MONGODB_PASSWORD |
DevPassword123! |
| Development | MONGODB_ADMIN_PASSWORD |
DevAdminPassword456! |
| Test | MONGODB_PASSWORD |
TestPassword789! |
| Test | MONGODB_ADMIN_PASSWORD |
TestAdminPassword000! |
| Production | MONGODB_PASSWORD |
ProdPassword111! |
| Production | MONGODB_ADMIN_PASSWORD |
ProdAdminPassword222! |
The workflow will use these to create the Secret:
- name: Create MongoDB Secret
run: |
kubectl create secret generic mongodb-secret \
-n ${{ env.NAMESPACE }} \
--from-literal=mongodb-password='${{ secrets.MONGODB_PASSWORD }}' \
--from-literal=mongodb-admin-password='${{ secrets.MONGODB_ADMIN_PASSWORD }}' \
--dry-run=client -o yaml | kubectl apply -f -✅ No credentials in Git - Passwords never committed to source control ✅ Environment isolation - Different passwords per environment (dev ≠ test ≠ prod) ✅ Audit trail - Kubernetes Secret changes are auditable ✅ Easy rotation - Update password without redeploying application ✅ Vault integration - Can integrate with Azure Key Vault, HashiCorp Vault, etc.
These files are now safe to commit to Git (no credentials):
- ✅
helm/mongodb/values.yaml - ✅
helm/mongodb/values-dev.yaml - ✅
helm/mongodb/values-test.yaml - ✅
helm/mongodb/values-prod.yaml - ✅
.github/workflows/deploy-mongodb.yml
-
helm/mongodb/SECRETS.md - Complete credentials management guide
- How to create/update secrets
- Vault integration
- Password rotation procedures
- Troubleshooting
-
helm/mongodb/README.md - Helm chart documentation (updated)
- Installation with secrets
- Migration steps
- Configuration
-
docs/MONGODB_MIGRATION.md - Migration guide (updated)
- Includes secret creation as prerequisite step
If you previously deployed with passwords in values files:
- Extract current passwords from old
values-*.yamlfiles - Create Kubernetes Secrets with extracted passwords
- Verify Secrets exist in each namespace
- Delete old value files with passwords (git rm)
- Update Helm chart deployment
- Test MongoDB connectivity
- Commit cleaned-up files (without passwords)
# Check if Secret exists
kubectl get secret mongodb-secret -n <namespace>
# Create it if missing
kubectl create secret generic mongodb-secret \
-n <namespace> \
--from-literal=mongodb-password='<password>' \
--from-literal=mongodb-admin-password='<admin-password>'# Check Secret keys
kubectl get secret mongodb-secret -n <namespace> -o yaml
# Verify both keys exist:
# - mongodb-password
# - mongodb-admin-password
# If missing, recreate with both keys# Update Secret
kubectl patch secret mongodb-secret -n <namespace> \
-p '{"data":{"mongodb-password":"'$(echo -n 'new-password' | base64)'"}}'
# Force pod restart to pick up new Secret value
kubectl delete pod mongodb-0 -n <namespace>- ✅ Understand the changes - Review this document
- ⏭️ Read SECRETS.md - Comprehensive credential management guide
- ⏭️ Create Secrets - For each environment (dev, test, prod)
- ⏭️ Deploy Helm Chart - With Secrets in place
- ⏭️ Test Connectivity - Verify MongoDB works
- ⏭️ Automate with GitHub Actions - Use the provided workflow
See helm/mongodb/SECRETS.md for comprehensive information on:
- Azure Key Vault integration
- External Secrets Operator setup
- Password rotation procedures
- Vault/HashiCorp integration
- Security best practices
Summary: Passwords are now managed securely via Kubernetes Secrets. Never commit credentials to Git. Use the helper script or kubectl to create secrets before deploying.