hazelcast helm template, how do i pass my hazelcast.xml?

7/4/2019

Helm greenhorn. I have to "inject" a specific hazelcast.xml into the configMap with the chart. I am supposed to --set hazelcast.configurationFiles

I've tried several ways:

  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)"

none of them works, and i couldn't find or understand how to correctly do it.

I expect that i get configMap correctly configured like it should be:

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

instead of this (closest result obtained with try nr 3):

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

1 Answer

7/4/2019

Following the README example

you need to uncomment the configurationFiles on values and put paste your own xml file conten:

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>

but if you don't want to past the content insede the values.yaml you can use. File to get the content of a file in the same path

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

Template guide

Remember you can copy the original values.yaml from the chart and use -f to specify you own values instead of using --set every time.

-- wolmi
Source: StackOverflow