Kubernetes
Available charts
Memgraph can be deployed on Kubernetes. Currently, supported deployment methods for Memgraph are:
There is also support for deploying Memgraph Lab on Kubernetes:
For details on the implementation of the Helm charts, you can go to Memgraph Helm charts repository (opens in a new tab). Due to numerous possible use cases and deployment setups via Kubernetes, the provided Helm charts are a starting point you can modify according to your needs.
This docs page contains the basic information on how to deploy Memgraph or Memgraph Lab on Kubernetes using Helm charts.
Helm chart for standalone Memgraph
Since Helm chart for standalone
Memgraph (opens in a new tab) is
configured to deploy Memgraph as a Kubernetes StatefulSet
workload, it is also
necessary to define a PersistentVolumeClaims
to store the data
directory (/var/lib/memgraph
).
This enables the data to be persisted even if the pod is restarted or deleted.
If you don't require data persistence or your dataset is static, using the
StatefulSet
workload is unnecessary. Stateful applications are more complex to
set up and maintain, as they require more attention when handling storage
information and security.
To include a standalone Memgraph as a part of your Kubernetes cluster, you need to add the repository and install Memgraph.
Add the repository
Add the Memgraph Helm chart repository to your local Helm setup by running the following command:
helm repo add memgraph https://memgraph.github.io/helm-charts
Make sure to update the repository to fetch the latest Helm charts available:
helm repo update
Install Memgraph
To install Memgraph Helm Chart, run the following command:
helm install <release-name> memgraph/memgraph
Replace <release-name>
with the name of the release you chose.
Access Memgraph
Once Memgraph is installed, you can access it using the provided services and
endpoints, such as various client libraries, command-line
interface mgconsole
or visual user interface Memgraph
Lab.
Configuration options
The following table lists the configurable parameters of the Memgraph chart and their default values.
Parameter | Description | Default |
---|---|---|
image.repository | Memgraph Docker image repository | memgraph/memgraph |
image.tag | Specific tag for the Memgraph Docker image. Overrides the image tag whose default is chart version. | "" (Defaults to chart's app version) |
image.pullPolicy | Image pull policy | IfNotPresent |
useImagePullSecrets | Override the default imagePullSecrets | false |
imagePullSecrets | Specify image pull secrets | - name: regcred |
replicaCount | Number of Memgraph instances to run. Note: no replication or HA support. | 1 |
affinity.nodeKey | Key for node affinity (Preferred) | "" |
affinity.nodeValue | Value for node affinity (Preferred) | "" |
nodeSelector | Constrain which nodes your Memgraph pod is eligible to be scheduled on, based on the labels on the nodes. Left empty by default. | {} |
tolerations | A toleration is applied to a pod and allows the pod to be scheduled on nodes with matching taints. Left empty by default. | [] |
service.type | Kubernetes service type | ClusterIP |
service.enableBolt | Enable Bolt protocol | true |
service.boltPort | Bolt protocol port | 7687 |
service.boltProtocol | Protocol used by Bolt | TCP |
service.enableWebsocketMonitoring | Enable WebSocket monitoring | false |
service.websocketPortMonitoring | WebSocket monitoring port | 7444 |
service.websocketPortMonitoringProtocol | Protocol used by WebSocket monitoring | TCP |
service.enableHttpMonitoring | Enable HTTP monitoring | false |
service.httpPortMonitoring | HTTP monitoring port | 9091 |
service.httpPortMonitoringProtocol | Protocol used by HTTP monitoring | http |
service.annotations | Annotations to add to the service | {} |
persistentVolumeClaim.createStorageClaim | Enable creation of a Persistent Volume Claim for storage | true |
persistentVolumeClaim.storageClassName | Storage class name for the persistent volume claim | "" |
persistentVolumeClaim.storageSize | Size of the persistent volume claim for storage | 10Gi |
persistentVolumeClaim.existingClaim | Use an existing Persistent Volume Claim | memgraph-0 |
persistentVolumeClaim.storageVolumeName | Name of an existing Volume to create a PVC for | "" |
persistentVolumeClaim.createLogStorage | Enable creation of a Persistent Volume Claim for logs | true |
persistentVolumeClaim.logStorageClassName | Storage class name for the persistent volume claim for logs | "" |
persistentVolumeClaim.logStorageSize | Size of the persistent volume claim for logs | 1Gi |
memgraphConfig | List of strings defining Memgraph configuration settings | ["--also-log-to-stderr=true"] |
secrets.enabled | Enable the use of Kubernetes secrets for Memgraph credentials | false |
secrets.name | The name of the Kubernetes secret containing Memgraph credentials | memgraph-secrets |
secrets.userKey | The key in the Kubernetes secret for the Memgraph user, the value is passed to the MEMGRAPH_USER env | USER |
secrets.passwordKey | The key in the Kubernetes secret for the Memgraph password, the value is passed to the MEMGRAPH_PASSWORD | PASSWORD |
memgraphEnterpriseLicense | Memgraph Enterprise License | "" |
memgraphOrganizationName | Organization name for Memgraph Enterprise License | "" |
statefulSetAnnotations | Annotations to add to the stateful set | {} |
podAnnotations | Annotations to add to the pod | {} |
resources | CPU/Memory resource requests/limits. Left empty by default. | {} |
serviceAccount.create | Specifies whether a service account should be created | true |
serviceAccount.annotations | Annotations to add to the service account | {} |
serviceAccount.name | The name of the service account to use. If not set and create is true, a name is generated. | "" |
container.terminationGracePeriodSeconds | Grace period for pod termination | 1800 |
probes.liveliness.initialDelaySeconds | Initial delay for liveliness probe | 10 |
probes.liveliness.periodSeconds | Period seconds for liveliness probe | 60 |
probes.liveliness.failureThreshold | Failure threshold for liveliness probe | 3 |
probes.readiness.initialDelaySeconds | Initial delay for readiness probe | 10 |
probes.readiness.periodSeconds | Period seconds for readiness probe | 30 |
probes.readiness.failureThreshold | Failure threshold for readiness probe | 3 |
probes.startup.initialDelaySeconds | Initial delay for startup probe | 10 |
probes.startup.periodSeconds | Period seconds for startup probe | 10 |
probes.startup.failureThreshold | Failure threshold for startup probe | 30 |
To change the default chart values, provide your own values.yaml
file during
the installation:
helm install <resource-name> memgraph/memgraph -f values.yaml
Default chart values can also be changed by setting the values of appropriate parameters:
helm install <resource-name> memgraph/memgraph --set <flag1>=<value1>,<flag2>=<value2>,...
Memgraph will start with the --also-log-to-stderr=true
flag, meaning the logs
will also be written to the standard error output and you can access logs using
the kubectl logs
command. To modify other Memgraph database settings, you
should update the memgraphConfig
parameter. It should be a list of strings
defining the values of Memgraph configuration settings. For example, this is how
you can define memgraphConfig
parameter in your values.yaml
:
memgraphConfig:
- "--also-log-to-stderr=true"
- "--log-level=TRACE"
For all available database settings, refer to the Configuration settings reference guide.
Since Memgraph Docker image has root privileges on the data located on volumes
and log directories, it is necessary that runAsUser
is set to 0
in the
securityContext
section of the pod to override the memgraph
user from the
Docker image. Currently, Memgraph must have root privileges on the volumes.
Helm chart for Memgraph high availability cluster (Enterprise)
A Helm Chart for deploying Memgraph in high availability setup (opens in a new tab). This helm chart requires an enterprise version of Memgraph.
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.
Installing the Memgraph HA Helm Chart
To install the Memgraph HA Helm Chart, follow the steps below:
helm install <release-name> memgraph/memgraph-high-availability --set memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE=<your-license>,memgraph.env.MEMGRAPH_ORGANIZATION_NAME=<your-organization-name>
Replace <release-name>
with a name of your choice for the release and set the
enterprise license.
Changing the default chart values
To change the default chart values, run the command with the specified set of flags:
helm install <resource-name> memgraph/memgraph-high-availability --set <flag1>=<value1>,<flag2>=<value2>,...
Or you can modify a values.yaml
file and override the desired values:
helm install <resource-name> memgraph/memgraph-high-availability-f values.yaml
Configuration Options
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 | <your-license> |
memgraph.env.MEMGRAPH_ORGANIZATION_NAME | Organization name | <your-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 | Each pod and instance is deployed to unique node in the cluster | true |
data | Configuration for data instances | See data section |
coordinators | Configuration for coordinator instances | See coordinators section |
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 (data only) | 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:
- "--also-log-to-stderr"
- "--log-level=TRACE"
- "--replication-restore-state-on-startup=true"
For all available database settings, refer to the Configuration settings reference guide (opens in a new tab).
Helm Chart for Memgraph Lab
A Helm Chart for deploying Memgraph Lab on Kubernetes.
Installing the Memgraph Lab Helm Chart
To install the Memgraph Lab Helm Chart, follow the steps below:
helm install <release-name> memgraph/memgraph-lab
Replace <release-name>
with a name of your choice for the release.
Changing the default chart values
To change the default chart values, run the command with the specified set of flags:
helm install <resource-name> memgraph/memgraph-lab --set <flag1>=<value1>,<flag2>=<value2>,...
Or you can modify a values.yaml
file and override the desired values:
helm install <resource-name> memgraph/memgraph-lab -f values.yaml
Configuration Options
The following table lists the configurable parameters of the Memgraph Lab chart and their default values.
Parameter | Description | Default |
---|---|---|
image.repository | Memgraph Lab Docker image repository | memgraph/memgraph-lab |
image.tag | Specific tag for the Memgraph Lab Docker image. Overrides the image tag whose default is chart version. | "" (Defaults to chart's app version) |
image.pullPolicy | Image pull policy | IfNotPresent |
replicaCount | Number of Memgraph Lab instances to run. | 1 |
service.type | Kubernetes service type | ClusterIP |
service.port | Kubernetes service port | 3000 |
service.targetPort | Kubernetes service target port | 3000 |
service.protocol | Protocol used by the service | TCP |
service.annotations | Annotations to add to the service | {} |
podAnnotations | Annotations to add to the pod | {} |
resources | CPU/Memory resource requests/limits. Left empty by default. | {} (See note on uncommenting) |
serviceAccount.create | Specifies whether a service account should be created | true |
serviceAccount.annotations | Annotations to add to the service account | {} |
serviceAccount.name | The name of the service account to use. If not set and create is true, a name is generated. | "" |
Memgraph Lab can be further configured with environment variables in your
values.yaml
file.
env:
- name: QUICK_CONNECT_MG_HOST
value: memgraph
- name: QUICK_CONNECT_MG_PORT
value: "7687"
- name: KEEP_ALIVE_TIMEOUT_MS
value: 65000
In case you added Nginx Ingress service or web server for a reverse proxy, update the following proxy timeout annotations to avoid potential timeouts:
proxy_read_timeout X;
proxy_connect_timeout X;
proxy_send_timeout X;
where X
is the number of seconds the connection (request query) can be alive.
Additionally, update the Memgraph Lab KEEP_ALIVE_TIMEOUT_MS
environment
variable to a higher value to ensure that Memgraph Lab stays connected to Memgraph
when running queries over 65 seconds.
Refer to the Memgraph Lab documentation for details on how to connect to and interact with Memgraph.