memgraph / helm-charts

Helm charts for deploying Memgraph, an open-source in-memory graph database.
https://memgraph.github.io/helm-charts/
Apache License 2.0
14 stars 11 forks source link

Memgraph configMap for configuration #1

Open foodiq-pk opened 1 year ago

foodiq-pk commented 1 year ago

Hi,

I would like to discuss a way of configuring memgraph using a configMap or possibly combining current approach with startup args with the configuration in values.yaml

What I currently use:

# values.yaml excerpt
config:  
  options:
    storage-properties-on-edges: true
    log-level: WARNING
    also-log-to-stderr: true
    data-directory: /var/lib/memgraph/
    log-file: /var/log/memgraph/memgraph.log
    memory-limit: 4096
    memory-warning-threshold: 1024
    storage-snapshot-on-exit: true
    storage-recover-on-startup: true
    storage-snapshot-interval-sec: 300
    storage-gc-cycle-sec: 30
    storage-snapshot-retention-count: 3
    storage-wal-enabled: true
    storage-wal-file-flush-every-n-tx: 100000
    storage-wal-file-size-kib: 20480
    query-plan-cache-ttl: 31536000
    query-max-plans: 1000

Then configMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: memgraph-config
data:
  {{- $options := .Values.config.options }}
  memgraph.conf: |
  {{- range $key, $value := $options }}
    --{{ $key }}={{ $value }}
  {{- end }}

The above function translate the key: vaule pairs into the memgraph.conf format options --key=value

and finally volume mount for the StatefulSet.yaml

    spec:
      ...
      containers:
        - name: memgraph
          ...
          volumeMounts:
            ....
            - name: memgraph-etc-config
              mountPath: /etc/memgraph/memgraph.conf
              subPath: memgraph.conf
      volumes:
        ...
        - name: memgraph-etc-config
          configMap:
            name: memgraph-config

IMHO the approach where you specify the key: value in yaml values is a bit more approachable than the --key=value format.

There might be issue where if you dont specify all the options memgraph seems to grab hardcoded default values instead of values of the default memgraph.conf as specified in the docs

It might be better approach combining using the added args to the launch arguments as is in the current state

e.g.

config:
  log-level: WARNING
  also-log-to-stderr:true

into args line

--log-level=WARNING --also-log-to-stderr=true

and pass that to args for startup

antejavor commented 1 year ago

Hi @foodiq-pk, this is a great suggestion and a much better solution. 🙌 I spent a few hours looking into this when we pushed the initial chart, but we decided to do that for the next iteration.

We will add this/or something like this in the upcoming weeks, thanks for the recommendation.