Configmap-角度

时间:2019-03-09 19:07:58

标签: kubernetes

所以我有一个configmap config.json

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

称为“连续部署”

豆荚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

没有配置映射集,我可以在转到IP地址./assets/config/config.json时看到配置文件,并且可以很好地查看它。当我应用配置映射时,然后可以看到的json的唯一部分是:

    {
"apiUrl": 

有什么想法吗?

更新-只需将config.json修改为以下内容

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

在浏览器中我可以看到

{ 
    "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}"
  }
}

甚至尝试过

{
  "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}"
  }
}

因此,如果我删除所有奇数字符并只使用字母,那么当我查看config.json时,它会变成'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}"
  }
}

1 个答案:

答案 0 :(得分:0)

排序!

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

必须将以下内容放入广告连播中,现在json可见并且可以使用