hazelcast头盔模板,如何传递hazelcast.xml?

时间:2019-07-04 15:29:37

标签: kubernetes hazelcast kubernetes-helm

格林豪森。我必须使用chart将特定的hazelcast.xml“注入”到configMap中。我应该--set hazelcast.configurationFiles

我尝试了几种方法:

  1. helm install stable/hazelcast --set cluster.memberCount=3 --set hazelcast.configurationFiles[0].val="$(cat k8s/hazelcast.xml)"
    
  2. helm install --name=ciao stable/hazelcast --set cluster.memberCount=3 --set hazelcast.configurationFiles[0]="\{ key: hazelcast.xml, val:$(cat k8s/hazelcast.xml)  \}"
    
  3. helm install --name=ciao stable/hazelcast --set cluster.memberCount=3   --set hazelcast.configurationFiles[0]="$(cat k8s/hazelcast.xml)"
    

它们都不起作用,我找不到或不知道如何正确地做到这一点。

我希望我正确配置configMap,就像这样:

apiVersion: v1
kind: ConfigMap
metadata:
  name: hazelcast-configuration
data:
  hazelcast.xml: |-
    <?xml version="1.0" encoding="UTF-8"?>........

代替此操作(尝试nr 3获得最接近的结果):

 data:
 "0": |-
       <?xml version="1.0" encoding="UTF-8"?>

1 个答案:

答案 0 :(得分:1)

遵循README示例

您需要取消对configurationFiles值的注释,并粘贴您自己的xml文件内容:

configurationFiles:
hazelcast.xml: |-
  <?xml version="1.0" encoding="UTF-8"?>
  <hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.10.xsd"
                 xmlns="http://www.hazelcast.com/schema/config"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <properties>
      <property name="hazelcast.discovery.enabled">true</property>
    </properties>
    <network>
      <join>
        <multicast enabled="false"/>
        <tcp-ip enabled="false" />
        <discovery-strategies>
          <discovery-strategy enabled="true" class="com.hazelcast.kubernetes.HazelcastKubernetesDiscoveryStrategy">
          </discovery-strategy>
        </discovery-strategies>
      </join>
    </network>

    <management-center enabled="${hazelcast.mancenter.enabled}">${hazelcast.mancenter.url}</management-center>

    <!-- Custom Configuration Placeholder -->
  </hazelcast>

,但是如果您不想粘贴values.yaml中的内容,则可以使用。文件以在同一路径中获取文件内容

configurationFiles:
  hazelcast.xml: |-
  {{ .Files.Get "hazelcast.xml" | indent 4}}

Template guide

请记住,您可以从图表中复制原始values.yaml,并使用-f来指定您自己的值,而不是每次都使用--set