title: How to pass environment variables in angular application with docker
body: <p>I m running my Angular 6 application as a Kubernetes pod/container. In this Angular app, I try to access a JSON config-object, to load my environment variables.</p>
  
  <p>I have used volume to read the config map and volume mount to create a config json file.</p>
  
  <p>My service is throwing a <code>503</code> error IF I include the volume creation code in my yaml file.</p>
  
  <p>The pods are in running mode when seen in logs.</p>
  
  <p>Code snippet of my deployment yaml file:</p>
  
  <pre><code>  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: {{ include "client-onboard.fullname" . }}
    labels:
      app.kubernetes.io/name: {{ include "client-onboard.name" . }}
      helm.sh/chart: {{ include "client-onboard.chart" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
      app.kubernetes.io/managed-by: {{ .Release.Service }}
  spec:
    replicas: {{ .Values.replicaCount }}
    selector:
      matchLabels:
        app.kubernetes.io/name: {{ include "client-onboard.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    template:
      metadata:
        labels:
          app.kubernetes.io/name: {{ include "client-onboard.name" . }}
          app.kubernetes.io/instance: {{ .Release.Name }}
      spec:
        containers:
          - name: {{ .Chart.Name }}
            image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
            imagePullPolicy: {{ .Values.image.pullPolicy }}
            volumeMounts:
            - name: env-vars
              mountPath: usr/share/nginx/html/config/env-vars.json
        volumes:
          - name: env-vars
            configMap:
              name: {{ .Chart.Name }}-configmap
            ports:
              - name: http
                containerPort: 80
                protocol: TCP
            livenessProbe:
              httpGet:
                path: /
                port: http
            readinessProbe:
              httpGet:
                path: /
                port: http
            resources:
              {{- toYaml .Values.resources | nindent 12 }}
        {{- with .Values.nodeSelector }}
        nodeSelector:
          {{- toYaml . | nindent 8 }}
        {{- end }}
      {{- with .Values.affinity }}
        affinity:
          {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
        tolerations:
          {{- toYaml . | nindent 8 }}
      {{- end }}
  </code></pre>
  
  <p>I am using nginx server for this.</p>