use server environment variable on image use server environment variable on image kubernetes kubernetes

use server environment variable on image


alternativly you can read from local config json , and then use volumes, having seperate config map for each of you environments see

under src/assets/config put the config json,

in your code read the url from the config file:

private getConfigJSONFile() {     return this.http.get("/assets/config/env-vars.json").map((res:any) => res.json())   }

now create the config on kubernetes:

here is the config file:

configs/env-variables.json

{  "api_server_url": "https://api.example.com"}

create the config

kubectl create configmap angular-env-vars --from-file=env-vars.json=configs/env-variables.json

use volumes in your deployment:

apiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: angular-web-appspec:  replicas: 1  revisionHistoryLimit: 1  strategy:      type: RollingUpdate  template:    metadata:      labels:        app: angular-web-app    spec:      containers:      - name: angular-web-app        image: us.gcr.io/my-com/angular-web-app:06.01.2018        volumeMounts:        - name: env-vars          mountPath: /usr/share/nginx/html/assets/config        ports:        - containerPort: 80      volumes:      - name: env-vars        configMap:          name: angular-env-vars