Skip to content

Commit

Permalink
Node selectors and improved affinity options (#86)
Browse files Browse the repository at this point in the history
This PR introduces the four modes for affinity:

Default - By default, data pods will avoid being scheduled on the same node as other data pods and coordinator pods will avoid being scheduled on the same node as other coordinator pods. Deployment won't fail if there is no sufficient nodes.

Unique - The unique affinity, will schedule the pods on different nodes in the cluster. This means coordinators and data nodes will not be scheduled on the same node. If there is more pods than nodes, deployment will fail.

Parity - The parity affinity, will enable scheduling of the pods on the same node, but with the rule that one node can host pair made of coordinator and data node. This means each node can have max two pods, one coordinator and one data node. If not sufficient nodes, deployment will fail.

NodeSelection - The nodeSelection affinity, will enable scheduling of the pods on the nodes with specific labels. So the coordinators will be scheduled on the nodes with label coordinator-node and data nodes will be scheduled on the nodes with label data-node. If not sufficient nodes, deployment will fail.

Add load balancer service (#90)
  • Loading branch information
antejavor authored and as51340 committed Dec 2, 2024
1 parent ae58a8b commit 239d061
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 96 deletions.
90 changes: 42 additions & 48 deletions charts/memgraph-high-availability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,62 +20,56 @@ Or you can modify a `values.yaml` file and override the desired values:
helm install <release-name> 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 <release-name> memgraph/memgraph-high-availability --set memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE=<your-license>,memgraph.env.MEMGRAPH_ORGANIZATION_NAME=<your-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

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.22.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` | Enables affinity so each instance is deployed to unique node | `true` |
| `memgraph.externalAccess.serviceType` | NodePort or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing | `LoadBalancer` |
| `memgraph.ports.boltPort` | Bolt port used on coordinator and data instances. | `7687` |
| `memgraph.ports.managementPort` | Management port used on coordinator and data instances. | `10000` |
| `memgraph.ports.replicationPort` | Replication port used on data instances. | `20000` |
| `memgraph.ports.coordinatorPort` | Coordinator port used on coordinators. | `12000` |
| `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` |
| 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.22.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.externalAccess.coordinator.serviceType` | NodePort, CommonLoadBalancer or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing. 'CommonLoadBalancer' will open one load balancer for all coordinators while 'LoadBalancer' will open one load balancer for each coordinators. | `NodePort` |
| `memgraph.externalAccess.dataInstance.serviceType` | NodePort or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing. | `NodePort` |
| `memgraph.ports.boltPort` | Bolt port used on coordinator and data instances. | `7687` |
| `memgraph.ports.managementPort` | Management port used on coordinator and data instances. | `10000` |
| `memgraph.ports.replicationPort` | Replication port used on data instances. | `20000` |
| `memgraph.ports.coordinatorPort` | Coordinator port used on coordinators. | `12000` |
| `memgraph.affinity.unique` | Schedule pods on different nodes in the cluster | `false` |
| `memgraph.affinity.parity` | Schedule pods on the same node with maximum one coordinator and one data node | `false` |
| `memgraph.affinity.nodeSelection` | Schedule pods on nodes with specific labels | `false` |
| `memgraph.affinity.roleLabelKey` | Label key for node selection | `role` |
| `memgraph.affinity.dataNodeLabelValue` | Label value for data nodes | `data-node` |
| `memgraph.affinity.coordinatorNodeLabelValue` | Label value for coordinator nodes | `coordinator-node` |
| `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 |
| `args` | List of arguments for the instance | See `args` section |
| Parameter | Description | Default |
| --------- | ---------------------------------- | ---------------------------------- |
| `id` | ID of the instance | `0` for data, `1` for coordinators |
| `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:
Expand Down
28 changes: 22 additions & 6 deletions charts/memgraph-high-availability/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@ The cluster setup requires the proper enterprise license to work since HA is an
You can connect to Memgraph instances via Lab, mgconsole, or any other client. By default, all Memgraph instances (coordinators and data instances) listen on port 7687 for a bolt connection.
Make sure your are connecting to the correct ip address and port. For details check the configuration on your cloud provider(aws, gcp, azure, etc.)

To start, you should add coordinators and register data instances in order to completely setup cluster. In both cases you only need to modify 'bolt_server' part and set it to the DNS
of the node on which instance is being started. Node ports are fixed. Example:
To start, you should add coordinators and register data instances in order to completely setup cluster. Depending on whether you use LoadBalancers or
NodePorts to expose your service, queries will be slightly different. In both cases you only need to modify 'bolt_server' part of the query while
'management_server', 'coordinator_server' and 'replication_server' will stay the same. If you are connecting via Lab, select 'Memgraph instance'
type of connection when adding instances to the cluster.


NodePort configuration example

ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "<NODE-IP2>:<NodePort2>", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};
REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "<NODE-IP4>:<NodePort4>", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};


LoadBalancer configuration example

ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "<COORD2-LB-IP>:7687", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};
REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "<INST1-LB-IP>:7687", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};


CommonLoadBalancer configuration example

ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "<COMMON-LB-IP>:7687", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};
REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "<INST1-LB-IP>:7687", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};

ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "<NODE-2-IP>:32002", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};
ADD COORDINATOR 3 WITH CONFIG {"bolt_server": "<NODE-3-IP>:32003", "management_server": "memgraph-coordinator-3.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-3.default.svc.cluster.local:12000"};
REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "<NODE-4-IP>:32010", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};
REGISTER INSTANCE instance_2 WITH CONFIG {"bolt_server": "<NODE-5-IP>:32011", "management_server": "memgraph-data-1.default.svc.cluster.local:10000", "replication_server": "memgraph-data-1.default.svc.cluster.local:20000"};

If you are connecting via Lab, specify your coordinator instance IP address and port in Memgraph Lab GUI and select Memgraph HA cluster type of connection.

Expand Down
Loading

0 comments on commit 239d061

Please sign in to comment.