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 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.