Kubernetes容器环境

时间:2018-12-11 16:17:28

标签: kubernetes kubernetes-helm

我在k8s中编写了deployment.yml文件:-

spec:
  containers:
  - name: consul
    image: xyz
    ports:
      - name: http
        containerPort: 8500
      - name: http1
        containerPort: 53
    env:
    - name: SERVICE_8500_IGNORE
      value: "true"
    - name: CONSUL_LOCAL_CONFIG
      value: "{"node_name": "docker","acl_datacenter": "dc1", "acl_default_policy": "deny", "acl_down_policy": "deny", "acl_master_token": "fleeture", "acl_agent_token":"xyz", "enable_script_checks": true}"

运行后出现错误

  

错误:“ node_name”附近的意外字符:“ docker”,“ acl_datacenter”:“ dc1”,“ acl_default_policy”:“ deny”,“ acl_down_policy”:“ deny”,“ acl_master_token”:“ xyz”,“ acl_agent_token” “:” xyz“,” enable_script_checks“:true}”“。   行:14值:“ {” node_name“:” docker“,” acl_datacenter“:” dc1“,” acl_default_policy“:” deny“,” acl_down_policy“:” deny“,” acl_master_token“:” fleeture“,” acl_agent_token“ :“ xyz”,“ enable_script_checks”:true}“

有想法如何为第14行编写ENV吗?

2 个答案:

答案 0 :(得分:5)

您需要使用\来对CONSUL_LOCAL_CONFIG的值中的双引号进行转义,以便条目变为:

- name: CONSUL_LOCAL_CONFIG
  value: "{\"node_name\": \"docker\",\"acl_datacenter\": \"dc1\", \"acl_default_policy\": \"deny\", \"acl_down_policy\": \"deny\", \"acl_master_token\": \"fleeture\", \"acl_agent_token\":\"xyz\", \"enable_script_checks\": true}"

答案 1 :(得分:2)

@ ryan-dawson的答案是正确的答案。

此外,您可以简单地将第一个双引号()替换为单引号('),

{% raw %}

<table class="table table-striped table-bordered row" id="compare-table" style = "table-layout: fixed; margin-right: auto; margin-left: auto">
    <thead>
        <th class = "col-md-3 tableHeading">Configuration name</th>
        <th class = "col-md-3 tableHeading">Property Name</th>
        <th class = "col-md-3 tableHeading">Value 1</th>
        <th class = "col-md-3 tableHeading">Value 2 </th>
    </thead>
    <tbody>
    {{#each tableRows }}
        {{#each values}}
            <tr>
                {{#if @first}}
                <th  class="breakWord inlineHeading" rowspan={{../length}}>{{ ../pid }}</th>
                {{/if}}

                <td class="breakWord">{{ propName }}</td>
                <td class="breakWord">{{ propValueA }}</td>
                <td class="breakWord">{{ propValueB }}</td>
            </tr>
        {{/each}}
    {{/each}}
    </tbody>
</table>
{% endraw %}