From f6e7f38a8cc0e46ac57a4c2ad75afaa7cecc580a Mon Sep 17 00:00:00 2001 From: Josipmrden Date: Thu, 28 Nov 2024 09:14:34 +0100 Subject: [PATCH 1/2] Update README.md for local setup (affinity disabled) (#75) README instructions update. --------- Co-authored-by: katarinasupe --- charts/memgraph-high-availability/README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/charts/memgraph-high-availability/README.md b/charts/memgraph-high-availability/README.md index 78e8dd7..4e1b078 100644 --- a/charts/memgraph-high-availability/README.md +++ b/charts/memgraph-high-availability/README.md @@ -1,5 +1,5 @@ -## Helm chart for Memgraph high availability cluster (Enterprise) -A Helm Chart for deploying Memgraph in [high availability setup](https://memgraph.com/docs/clustering/high-availability). This helm chart requires an enterprise version of Memgraph. +# Helm chart for Memgraph high availability (HA) cluster (Enterprise) +A Helm Chart for deploying Memgraph in [high availability setup](https://memgraph.com/docs/clustering/high-availability). This Helm Chart requires an [Enterprise version of Memgraph](https://memgraph.com/docs/database-management/enabling-memgraph-enterprise). Memgraph HA cluster includes 3 coordinators, 2 data instances by default. The cluster setup is performed via the cluster-setup job. The HA cluster is still work in progress and started with "--experimental-enabled=high-availability". The cluster is started in the configuration without the node selector, which means that in the current configuration, it is not highly available if the node fails. @@ -21,6 +21,18 @@ Or you can modify a `values.yaml` file and override the desired values: helm install memgraph/memgraph-high-availability -f values.yaml ``` +## Running the Memgraph HA Helm Chart locally + +To run Memgraph HA Helm Chart locally, affinity needs to be disabled because the cluster will be running on a single node. + +To disable the affinity, run the following command with the specified set of flags: + +``` +helm install memgraph/memgraph-high-availability --set memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE=,memgraph.env.MEMGRAPH_ORGANIZATION_NAME=,memgraph.affinity.enabled=false +``` + +The affinity is disabled either by running the command above, or by modifying the `values.yaml` file. + ## Configuration Options From 4f174b908022248e7325a52256a6abb73e184584 Mon Sep 17 00:00:00 2001 From: Ante Javor Date: Thu, 28 Nov 2024 09:40:23 +0100 Subject: [PATCH 2/2] Fix max map count (#79) Add a fix for max map count. --- charts/memgraph-high-availability/README.md | 66 ++++++++++--------- .../templates/coordinators.yaml | 9 +++ .../templates/data.yaml | 9 +++ charts/memgraph-high-availability/values.yaml | 7 ++ charts/memgraph/README.md | 3 +- charts/memgraph/templates/statefulset.yaml | 9 ++- charts/memgraph/values.yaml | 11 +++- 7 files changed, 79 insertions(+), 35 deletions(-) diff --git a/charts/memgraph-high-availability/README.md b/charts/memgraph-high-availability/README.md index 4e1b078..c10f556 100644 --- a/charts/memgraph-high-availability/README.md +++ b/charts/memgraph-high-availability/README.md @@ -38,41 +38,43 @@ The affinity is disabled either by running the command above, or by modifying th The following table lists the configurable parameters of the Memgraph chart and their default values. -| Parameter | Description | Default | -|---------------------------------------------|-----------------------------------------------------------------------------------------------------|-----------------------------------------| -| `memgraph.image.repository` | Memgraph Docker image repository | `memgraph/memgraph` | -| `memgraph.image.tag` | Specific tag for the Memgraph Docker image. Overrides the image tag whose default is chart version. | `2.17.0` | -| `memgraph.image.pullPolicy` | Image pull policy | `IfNotPresent` | -| `memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE` | Memgraph enterprise license | `` | -| `memgraph.env.MEMGRAPH_ORGANIZATION_NAME` | Organization name | `` | -| `memgraph.probes.startup.failureThreshold` | Startup probe failure threshold | `30` | -| `memgraph.probes.startup.periodSeconds` | Startup probe period in seconds | `10` | -| `memgraph.probes.readiness.initialDelaySeconds` | Readiness probe initial delay in seconds | `5` | -| `memgraph.probes.readiness.periodSeconds` | Readiness probe period in seconds | `5` | -| `memgraph.probes.liveness.initialDelaySeconds` | Liveness probe initial delay in seconds | `30` | -| `memgraph.probes.liveness.periodSeconds` | Liveness probe period in seconds | `10` | -| `memgraph.data.volumeClaim.storagePVC` | Enable storage PVC | `true` | -| `memgraph.data.volumeClaim.storagePVCSize` | Size of the storage PVC | `1Gi` | -| `memgraph.data.volumeClaim.logPVC` | Enable log PVC | `false` | -| `memgraph.data.volumeClaim.logPVCSize` | Size of the log PVC | `256Mi` | -| `memgraph.coordinators.volumeClaim.storagePVC` | Enable storage PVC for coordinators | `true` | -| `memgraph.coordinators.volumeClaim.storagePVCSize` | Size of the storage PVC for coordinators | `1Gi` | -| `memgraph.coordinators.volumeClaim.logPVC` | Enable log PVC for coordinators | `false` | -| `memgraph.coordinators.volumeClaim.logPVCSize` | Size of the log PVC for coordinators | `256Mi` | -| `memgraph.affinity.enabled` | Enables affinity so each instance is deployed to unique node | `true` | -| `data` | Configuration for data instances | See `data` section | -| `coordinators` | Configuration for coordinator instances | See `coordinators` section | +| Parameter | Description | Default | +| -------------------------------------------------- | --------------------------------------------------------------------------------------------------- | -------------------------- | +| `memgraph.image.repository` | Memgraph Docker image repository | `memgraph/memgraph` | +| `memgraph.image.tag` | Specific tag for the Memgraph Docker image. Overrides the image tag whose default is chart version. | `2.17.0` | +| `memgraph.image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE` | Memgraph enterprise license | `` | +| `memgraph.env.MEMGRAPH_ORGANIZATION_NAME` | Organization name | `` | +| `memgraph.probes.startup.failureThreshold` | Startup probe failure threshold | `30` | +| `memgraph.probes.startup.periodSeconds` | Startup probe period in seconds | `10` | +| `memgraph.probes.readiness.initialDelaySeconds` | Readiness probe initial delay in seconds | `5` | +| `memgraph.probes.readiness.periodSeconds` | Readiness probe period in seconds | `5` | +| `memgraph.probes.liveness.initialDelaySeconds` | Liveness probe initial delay in seconds | `30` | +| `memgraph.probes.liveness.periodSeconds` | Liveness probe period in seconds | `10` | +| `memgraph.data.volumeClaim.storagePVC` | Enable storage PVC | `true` | +| `memgraph.data.volumeClaim.storagePVCSize` | Size of the storage PVC | `1Gi` | +| `memgraph.data.volumeClaim.logPVC` | Enable log PVC | `false` | +| `memgraph.data.volumeClaim.logPVCSize` | Size of the log PVC | `256Mi` | +| `memgraph.coordinators.volumeClaim.storagePVC` | Enable storage PVC for coordinators | `true` | +| `memgraph.coordinators.volumeClaim.storagePVCSize` | Size of the storage PVC for coordinators | `1Gi` | +| `memgraph.coordinators.volumeClaim.logPVC` | Enable log PVC for coordinators | `false` | +| `memgraph.coordinators.volumeClaim.logPVCSize` | Size of the log PVC for coordinators | `256Mi` | +| `memgraph.affinity.enabled` | Enables affinity so each instance is deployed to unique node | `true` | +| `data` | Configuration for data instances | See `data` section | +| `coordinators` | Configuration for coordinator instances | See `coordinators` section | +| `sysctlInitContainer.enabled` | Enable the init container to set sysctl parameters | `true` | +| `sysctlInitContainer.maxMapCount` | Value for `vm.max_map_count` to be set by the init container | `262144` | For the `data` and `coordinators` sections, each item in the list has the following parameters: -| Parameter | Description | Default | -|---------------------------------------------|-----------------------------------------------------------------------------------------------------|-----------------------------------------| -| `id` | ID of the instance | `0` for data, `1` for coordinators | -| `boltPort` | Bolt port of the instance | `7687` | -| `managementPort` | Management port of the data instance | `10000` | -| `replicationPort` (data only) | Replication port of the data instance | `20000` | -| `coordinatorPort` (coordinators only) | Coordinator port of the coordinator instance | `12000` | -| `args` | List of arguments for the instance | See `args` section | +| Parameter | Description | Default | +| ------------------------------------- | -------------------------------------------- | ---------------------------------- | +| `id` | ID of the instance | `0` for data, `1` for coordinators | +| `boltPort` | Bolt port of the instance | `7687` | +| `managementPort` | Management port of the data instance | `10000` | +| `replicationPort` (data only) | Replication port of the data instance | `20000` | +| `coordinatorPort` (coordinators only) | Coordinator port of the coordinator instance | `12000` | +| `args` | List of arguments for the instance | See `args` section | The `args` section contains a list of arguments for the instance. The default values are the same for all instances: diff --git a/charts/memgraph-high-availability/templates/coordinators.yaml b/charts/memgraph-high-availability/templates/coordinators.yaml index 74aeb00..1b36e64 100644 --- a/charts/memgraph-high-availability/templates/coordinators.yaml +++ b/charts/memgraph-high-availability/templates/coordinators.yaml @@ -52,6 +52,15 @@ spec: add: [ "CHOWN" ] runAsUser: 0 runAsNonRoot: false + {{- if $.Values.sysctlInitContainer.enabled }} + - name: init-sysctl + image: busybox + command: ['sh', '-c', 'sysctl -w vm.max_map_count={{ $.Values.sysctlInitContainer.maxMapCount }}'] + securityContext: + privileged: true + runAsUser: 0 + {{- end }} + containers: - name: memgraph-coordinator image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" diff --git a/charts/memgraph-high-availability/templates/data.yaml b/charts/memgraph-high-availability/templates/data.yaml index 5d1758a..f2c53a5 100644 --- a/charts/memgraph-high-availability/templates/data.yaml +++ b/charts/memgraph-high-availability/templates/data.yaml @@ -52,6 +52,15 @@ spec: add: [ "CHOWN" ] runAsUser: 0 runAsNonRoot: false + {{- if $.Values.sysctlInitContainer.enabled }} + - name: init-sysctl + image: busybox + command: ['sh', '-c', 'sysctl -w vm.max_map_count={{ $.Values.sysctlInitContainer.maxMapCount }}'] + securityContext: + privileged: true + runAsUser: 0 + {{- end }} + containers: - name: memgraph-data image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" diff --git a/charts/memgraph-high-availability/values.yaml b/charts/memgraph-high-availability/values.yaml index eb5dcaf..3edaa70 100644 --- a/charts/memgraph-high-availability/values.yaml +++ b/charts/memgraph-high-availability/values.yaml @@ -39,6 +39,13 @@ memgraph: affinity: enabled: true +# If you are experiencing issues with the sysctlInitContainer, you can disable it here. +# This is made to increase the max_map_count, necessary for high memory loads in Memgraph +# If you are experiencing crashing pod with the: Max virtual memory areas vm.max_map_count is too low +# you can increase the maxMapCount value. +sysctlInitContainer: + enabled: true + maxMapCount: 262144 data: - id: "0" diff --git a/charts/memgraph/README.md b/charts/memgraph/README.md index d4a12bd..5582b0a 100644 --- a/charts/memgraph/README.md +++ b/charts/memgraph/README.md @@ -78,7 +78,8 @@ The following table lists the configurable parameters of the Memgraph chart and | `probes.startup.failureThreshold` | Failure threshold for startup probe | `30` | | `nodeSelectors` | Node selectors for pod. Left empty by default. | `{}` | | `customQueryModules` | List of custom Query modules that should be mounted to Memgraph Pod | `[]` | - +| `sysctlInitContainer.enabled` | Enable the init container to set sysctl parameters | `true` | +| `sysctlInitContainer.maxMapCount` | Value for `vm.max_map_count` to be set by the init container | `262144` | **Note:** It's often recommended not to specify default resources and leave it as a conscious choice for the user. If you want to specify resources, uncomment the following lines in your `values.yaml`, adjust them as necessary: ```yaml diff --git a/charts/memgraph/templates/statefulset.yaml b/charts/memgraph/templates/statefulset.yaml index 3b55c5d..d9aa1b3 100644 --- a/charts/memgraph/templates/statefulset.yaml +++ b/charts/memgraph/templates/statefulset.yaml @@ -69,7 +69,14 @@ spec: add: ["CHOWN"] runAsUser: 0 runAsNonRoot: false - + {{- if .Values.sysctlInitContainer.enabled }} + - name: init-sysctl + image: busybox + command: ['sh', '-c', 'sysctl -w vm.max_map_count={{ .Values.sysctlInitContainer.maxMapCount }}'] + securityContext: + privileged: true + runAsUser: 0 + {{- end }} terminationGracePeriodSeconds: {{ .Values.container.terminationGracePeriodSeconds }} securityContext: {{- if .Values.useImagePullSecrets }} diff --git a/charts/memgraph/values.yaml b/charts/memgraph/values.yaml index 0600f3c..b05730d 100644 --- a/charts/memgraph/values.yaml +++ b/charts/memgraph/values.yaml @@ -20,6 +20,7 @@ affinity: nodeKey: nodeValue: + nodeSelector: {} tolerations: [] @@ -120,7 +121,6 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: "" - container: terminationGracePeriodSeconds: 1800 probes: @@ -145,3 +145,12 @@ customQueryModules: [] # - volume: "" # Must be present in the ConfigMap referenced with `volume` # file: "" + + +# If you are experiencing issues with the sysctlInitContainer, you can disable it here. +# This is made to increase the max_map_count, necessary for high memory loads in Memgraph +# If you are experiencing crashing pod with the: Max virtual memory areas vm.max_map_count is too low +# you can increase the maxMapCount value. +sysctlInitContainer: + enabled: true + maxMapCount: 262144