Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
Not able to access Gitlab env variables either in node.js or react

I have two different projects checked in Gitlab, frontend and backend. For both the projects i have a Dockerfile each. I have set the env variables in gitlab ci/cd . I am running docker container in kubernetes, but i am not able to access the gitlab env variables either in my react or node.js (express) application.

I was thinking that those env variable would be available to me when i do process.env.variable_name, but i am not able to access them.

What’s the best way to access Gitlab env variables in kubernetes (deployment.yaml) env variables ?

UPDATE

I have found that we can specify env variables in kubernetes, deployment.yaml file (under env section). How can i pass gitlab env variables to deployment.yaml?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Docker containers require that you set environment variables when you run them:

https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file

--env , -e      Set environment variables
over 4 years ago · Santiago Trujillo Report

0

I was able to access environment variable in Node js application using Gitlab K8S_SECRET_ variable naming convention. For example define a variable like K8S_SECRET_MY_TEST_API in gitlab. In Node js, you can access this variable using process.env.MY_TEST_API.

Only issue I am facing is that those variables are not available in React app. Still trying to figure that out. I will update here once I resolve that issue.

over 4 years ago · Santiago Trujillo Report

0

To inject environment variables to a react app created with create-react-app you should add the prefix REACT_APP_ to every env var.

During the build, webpack will pick all the environment variables with that prefix and will add them to environment.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!