Dynamic Persistence Configuration
If you want to enable Dynamic Persistence Configuration
feature on your cluster, there are few instructions that you must apply in your chart configurations.
The first one is to change the Hazelcast configuration file path to /data/external
directory. It can be achieved by initContainers
. You also need to provide PersistentVolumeClaim
as external volume.
PersistentVolumeClaim sample:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: <PVC Name>
spec:
storageClassName: <Storage Class>
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
The AccessMode of Persistent Volume has an important role in spreading out pods among nodes in the cluster. \
ReadWriteOnce - the volume can be mounted as read-write by a single node. ReadWriteOnce access mode still can allow multiple pods to access the volume when the pods are running on the same node.\
ReadWriteMany - the volume can be mounted as read-write by many nodes.
|
Add initContainers, which changes Hazelcast configuration file path, in your values file.
externalVolume:
persistentVolumeClaim:
claimName: <PVC Name>
...
initContainers:
- name: init-container
image: alpine
command: ["/bin/sh", "-c", "cp -n /data/hazelcast/hazelcast.yaml /data/external/hazelcast.yaml && chmod 777 /data/external/hazelcast.yaml"]
volumeMounts:
- name: hazelcast-external
mountPath: /data/external/
- name: hazelcast-storage
mountPath: /data/hazelcast/
Then, update the new path of Hazelcast configuration file.
hazelcast:
javaOpts: -Dhazelcast.config=/data/external/hazelcast.yaml
Getting all these instructions together in your values yaml file.
hazelcast:
licenseKey: <license key>
yaml:
hazelcast:
...
dynamic-configuration:
persistence-enabled: true
backup-dir: /data/external/backups
javaOpts: -Dhazelcast.config=/data/external/hazelcast.yaml
externalVolume:
persistentVolumeClaim:
claimName: <pvc>
initContainers:
- name: init-container
image: alpine
command: ["/bin/sh", "-c", "cp -n /data/hazelcast/hazelcast.yaml /data/external/hazelcast.yaml && chmod 777 /data/external/hazelcast.yaml"]
volumeMounts:
- name: hazelcast-external
mountPath: /data/external/
- name: hazelcast-storage
mountPath: /data/hazelcast/