Configmaps - Angular

3/9/2019

So i have a configmap config.json

{
"apiUrl": "http://application.cloudapp.net/",
"test": "1232"
}

called 'continuousdeployment'

The pod yaml

    apiVersion: v1
kind: Pod
metadata:
  name: continuousdeployment-ui
spec:
  containers:
  - name: continuousdeployment-ui
    image: release.azurecr.io/release.ccf.ui:2758
    volumeMounts:
    - name: config-volume
      mountPath: app/wwwroot/assets/config
  volumes:
  - name: config-volume
    configMap:
      name: continuousdeployment

Without the config map set i can see the config file when going to the IP address ./assets/config/config.json and i can view it all fine. when i apply the config map the only part of the json i can then see is:

    {
"apiUrl": 

So any ideas?

Update - Just amended the config.json to the following

{ 
"test":"1232", 
"apiUrl":"http://applictaion.cloudapp.net/"
}

and in the browser i can see

{ 
    "test":"1232",

configmap

    {
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {
    "name": "continuousdeployment-ccf-ui-config",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/configmaps/continuousdeployment-ccf-ui-config",
    "uid": "94ee863c-42b3-11e9-8872-36a65af8d9e4",
    "resourceVersion": "235988",
    "creationTimestamp": "2019-03-09T21:37:47Z"
  },
  "data": {
    "config.json": "{\n    \"apiUrl\": \"http://application.cloudapp.net/\"\n}"
  }
}

even tried this

{
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {
    "name": "continuousdeployment-ccf-ui-config1",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/configmaps/continuousdeployment-ccf-ui-config1",
    "uid": "ee50ad25-42c0-11e9-8872-36a65af8d9e4",
    "resourceVersion": "243585",
    "creationTimestamp": "2019-03-09T23:13:21Z"
  },
  "data": {
    "config.json": "{\r\n    \"apiUrl\": \"http://application.cloudapp.net/\"\r\n}"
  }
}

So if i remove all odd characters and just do the alphabet, when i view the config.json it gets to 'q'

{
  "kind": "ConfigMap",
  "apiVersion": "v1",
  "metadata": {
    "name": "continuousdeployment-ccf-ui-config1",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/configmaps/continuousdeployment-ccf-ui-config1",
    "uid": "ee50ad25-42c0-11e9-8872-36a65af8d9e4",
    "resourceVersion": "244644",
    "creationTimestamp": "2019-03-09T23:13:21Z"
  },
  "data": {
    "config.json": "{abcdefghijklmnopqrstuvwxyz}"
  }
}
-- Dan Lewis
kubernetes

1 Answer

3/10/2019

Sorted it!

volumeMounts:
- mountPath: /app/wwwroot/assets/config/config.json
  name: config-volume
  subPath: config.json

Had to put the following in the pod and now the json is visable and works

-- Dan Lewis
Source: StackOverflow