DevOps / Scripts
bash
Advanced
Kubernetes Secret from .env
Parse a .env file and create a Kubernetes Secret without storing values in shell history.
bash
#!/bin/bash
ENV_FILE=${1:-.env}
NAME=${2:-app-secrets}
kubectl create secret generic $NAME \
$(grep -v "^#" $ENV_FILE | grep -v "^$" | xargs -I{} echo "--from-literal={}") \
--dry-run=client -o yaml | kubectl apply -f -
Prerequisites
- kubectl
- .env file
Pro Tips
- → Use --dry-run=client to preview before applying.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- bash
- Level
- Advanced
- Read time
- 3 min
- Published
- Jun 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
Postgres S3 Backup
Dump a Postgres database, gzip it, push to S3 with AES256 encryption.
bash
·
Intermediate
Disk Usage Alert
Send an alert when any mounted filesystem exceeds a usage threshold.
bash
·
Beginner
Docker Image Cleanup Script
Remove dangling images, stopped containers and unused volumes in one pass.
bash
·
Intermediate