简体   繁体   中英

Kubernetes + Azure + Environment Variables

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM