Angular access K8S Environment variables in code

8/9/2021

Working on an Angular application. Using angular version 6.

This application runs in Docker container and using Kubernetes as container-orchestration.

There are some dynamic Environment variables set by k8s from build pipe line. I want to use those in code and display them in one of my angular component ui.

I have no idea how to do this. Could someone please help me with this.

If this topic is already discussed here please point me the post. I will gladly delete my post.

Here is my config-map.yaml file:

apiVersion: v1
kind: ConfigMap
metadata:
  name: __AppName__-v__ReleaseVersion__
  labels:
    app: __AppName__
    version: v__ReleaseVersion__
data:
  LOGGING_LEVEL_ROOT: __LOGGING_LEVEL_ROOT__
  EXECUTION_ENVIRONMENT_IDENTIFIER: __EXECUTION_ENVIRONMENT_IDENTIFIER__

here is my-app.yaml file

...
        - name: EXECUTION_ENVIRONMENT_IDENTIFIER
          valueFrom:
            configMapKeyRef:
              name: __AppName__-v__ReleaseVersion__
              key: EXECUTION_ENVIRONMENT_IDENTIFIER
...
-- Kishor Prakash
angular
kubernetes

0 Answers