Kubernetes + Azure + Environment Variables

8/24/2019

I have a NodeJS app that renders server-side ReactJS components.

When I populate the environment variables via the deployment file. It seems as my NodeJS server or ReactJS app does not see my environment variables.

How does envs work here?

When I build the image. I can set the envs there.

But that is being set via the Kubernetes Deployment file.

We are using webpack to build the server.

I tried building the image with the envs inside it. I tried building the image without the envs inside it.

When I do a console.log(process.env), I don't see the envs populated in the deployment file for Kubernetes.

-- Mark Richardson
azure
kubernetes
node.js
reactjs

1 Answer

8/24/2019

you cant get environment variables from the reactjs app, since it happens in the client browser. you can set them at build time or do some sort of parsing before the application starts to preprocess js files with a script\init container

https://medium.com/@trekinbami/using-environment-variables-in-react-6b0a99d83cf5

-- 4c74356b41
Source: StackOverflow