Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
dotenv-from-k8s
Advanced tools
A commandline cli tool to fetch, merge and convert secrets and config maps in k8s to dot env property file.
Readme
A commandline cli tool to fetch, merge and convert secrets and config maps in k8s to dot env property file.
In most frontend projects environment variables are built as part of docker build. This tool allows you to create a .env file from k8s secrets and config maps before doing a docker build. This way you can store your secrets in k8s secrets just like you would for a nodejs service.
This tool uses kubernetes apis via the official kubernetes client for javascript and will use your currently configured kubectl to perform necessary api calls. So make sure you have configured your kubectl correctly before running this.
npm install -g dotenv-from-k8s
dotenv-from-k8s 1.4.0 - A commandline cli tool to fetch, merge and convert secrets and config maps in k8s to dot env property file.
USAGE
dotenv-from-k8s
OPTIONS
-i, --input Input configuration file optional default: false
-o, --out Output env file name, defaults to stdout optional default: false
-s, --secret <secret_name> K8s <secret_name> from which you want to generate env file optional
-c, --configmap <config_map> K8s <config_map> from which you want to generate env file optional
-n, --namespace <name_space> K8s <name_space> from which you want to access the secrets and/or config maps optional
-x, --context <context_name> K8s context <context_name> from which you want to access the secrets and/or config maps optional
MORE INFO
Basic example:
---------------
dotenv-from-k8s -c api-config -o .env
or
dotenv-from-k8s -c api-config > .env
Advanced example:
----------------
dotenv-from-k8s -s api-secrets -s api-secrets2 -c api-config -c api-config2 -n default > .env
Config file example:
--------------------
cat > env-from.yaml <<EOL
namespace: default
envFrom:
- secretRef:
name: app-secrets
- configMapRef:
name: app-config
EOL
dotenv-from-k8s -i env-from.yaml -o .env
Config file example with overrides:
-----------------------------------
cat > env-from.yaml <<EOL
namespace: default
envFrom:
- secretRef:
name: app-secrets
- configMapRef:
name: app-config
overrides:
HELLO: WORLD
ANOTHER_KEY: ANOTHER_VALUE
EOL
dotenv-from-k8s -i env-from.yaml -o .env
GLOBAL OPTIONS
-h, --help Display help
-V, --version Display version
--no-color Disable colors
--quiet Quiet mode - only displays warn and error messages
-v, --verbose Verbose mode - will also output debug messages
dotenv-from-k8s -c api-config -o .env
or
dotenv-from-k8s -c api-config > .env
dotenv-from-k8s -s api-secrets -s api-secrets2 -c api-config -c api-config2 -n default > .env
env-from.yaml
namespace: default
envFrom:
- secretRef:
name: app-secrets
- configMapRef:
name: app-config
overrides:
Hello: World
dotenv-from-k8s -i env-from.yaml -o .env
If you do not want to use this tool for some reason you can try
PS: You will need jq
version 1.6+ installed on your system.
kubectl get secrets/api-secrets -o json | \
jq -r '.data | map_values(@base64d) | to_entries[] | "\(.key)=\(.value)"' > .env
kubectl get configmaps/api-config -o json | \
jq -r '.data | to_entries[] | "\(.key)=\(.value)"' >> .env
FAQs
A commandline cli tool to fetch, merge and convert secrets and config maps in k8s to dot env property file.
The npm package dotenv-from-k8s receives a total of 27 weekly downloads. As such, dotenv-from-k8s popularity was classified as not popular.
We found that dotenv-from-k8s demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.