React js with kubernetes deployment

4/5/2019

mine is a react app (not build from creat react app) we use env file for different environments variables(use Dotenv web pack ) from npm . We are deploying this app to docker container in kubernetes. Looking for a way that env vars can be managed from kubernetes side than from .env file . While running In localhost (not in docker ) it should work also when deploying should take from kubernetes.any suggestion

-- CoolOS
docker
kubernetes
node.js
react-redux
reactjs

1 Answer

4/5/2019

You can use configmap and secrets in kubernetes to manage the environment variables. while both are default in kubernetes so no need of extra installation.

there are many other option you can also use the hashicorp vault for more secure varible store.

  1. If environment variables will used inside kubernetes you can use configmap & secrets
  2. If you want to transfer variable outside kubernetes better setup vault for more security purpose.

if you want to set the environment variables in docker file include you can do it like

...
RUN npm run build
ENV File_location=/app/.env
ENV DB_PORT=9090
WORKDIR /
RUN npm install express
...

This environment variable you can use and import to code.

-- Harsh Manvar
Source: StackOverflow