Using Kubernetes ConfigMaps and Docker Env Variables in FE projects

Ahmad Mhaish
The Startup
6 min readDec 20, 2019

--

After moving to Microservices architect, and by using a framework like Kubernetes, the need to store all configuration and variables in an easy to access place appears. And that is the main benefit of Kubernetes ConfigMaps and Secrets.

These two objects let you store and manage in order your configurations and sensitive data. Like integration endpoints, hidden/shown features, passwords, tokens, ssh keys, …etc.

The real magic comes when you can use these values in your Kubernetes service deployment file where you are defining the Docker instance and environment parameters, which means that these parameters can be passed as environment parameters to any service in the mesh.

One of the challenges is to find a way to pass these parameters to a front-end project either if it's a pure JS project or written in one of the famous platforms now (React, Angular and Vue). We will talk next about configuring Kubernetes ConfigMaps, using them in services, and the trick to using these variables in FE project.

Defining ConfigMap/Secret in K8

K8s secrets are all about that Base64 encoding. Kubernetes does this to avoid accidentally exposing secrets.

--

--

Ahmad Mhaish
The Startup

I am a Software and AI engineer that have a great passion for integrating technology with businesses and human life.