2

I have this ConfigMap where I am constructing a app-config.json file that I pass into Angular. This file is how I get environment variables into Angular as they must be served.

Below is how I thought passing variables into the JSON would work in ConfiMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: frontend-settings
data:
  app-config.json: |-
    {
        "keycloakUrl": "http://${minikube ip}:${keycloak_port}/auth",
        "realm": "eshc",
        "clientId": "eshc-frontend",
        "backendApi": "http://localhost:${backend_port}"
    }

The problem is that these are not evaluated. I want to pass Kube service aliases, and the minikube ip command as in the example above. Could someone point me in the right direction as to how I might do this?

Thanks in advance!

1 Answers1

2

Kubernetes doesn't provide this facility in the API.

You can do this at deploy time with helm or kubectl's kustomization features.

Depending on your use case, this can also be done at runtime in a container entry point before the app starts up or in a Kubernetes specific init container. Avoid the init container unless you are working with shared file systems, or with the Kubernetes API to apply these changes.

From your example it looks like everything should be available at deploy time, maybe not the minikube IP. For that you should be able to use the magic DNS name host.minikube.internal

Matt
  • 68,711
  • 7
  • 155
  • 158