From d8dbf546e523af0c1f34448e94b2944369c9c330 Mon Sep 17 00:00:00 2001 From: Andi Skrgat Date: Mon, 25 Nov 2024 09:19:02 +0100 Subject: [PATCH 1/5] Add single NodePort svc --- .../templates/coordinators.yaml | 7 +++-- .../templates/data.yaml | 7 +++-- .../templates/external-access.yaml | 13 ++++++++ .../templates/services-coordinators.yaml | 30 ++++--------------- .../templates/services-data.yaml | 30 ++++--------------- charts/memgraph-high-availability/values.yaml | 23 +++++--------- 6 files changed, 40 insertions(+), 70 deletions(-) create mode 100644 charts/memgraph-high-availability/templates/external-access.yaml diff --git a/charts/memgraph-high-availability/templates/coordinators.yaml b/charts/memgraph-high-availability/templates/coordinators.yaml index 74aeb00..c6d329a 100644 --- a/charts/memgraph-high-availability/templates/coordinators.yaml +++ b/charts/memgraph-high-availability/templates/coordinators.yaml @@ -13,6 +13,7 @@ spec: metadata: labels: app: memgraph-coordinator-{{ $coordinator.id }} + instance-type: coordinator spec: {{ if $.Values.memgraph.affinity.enabled }} affinity: @@ -57,9 +58,9 @@ spec: image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" imagePullPolicy: {{ $.Values.memgraph.image.pullPolicy }} ports: - - containerPort: {{ $coordinator.boltPort }} - - containerPort: {{ $coordinator.managementPort }} - - containerPort: {{ $coordinator.coordinatorPort }} + - containerPort: {{ $.Values.memgraph.ports.boltPort }} + - containerPort: {{ $.Values.memgraph.ports.managementPort }} + - containerPort: {{ $.Values.memgraph.ports.coordinatorPort }} args: {{- range $arg := $coordinator.args }} - "{{ $arg }}" diff --git a/charts/memgraph-high-availability/templates/data.yaml b/charts/memgraph-high-availability/templates/data.yaml index 5d1758a..2ec45ad 100644 --- a/charts/memgraph-high-availability/templates/data.yaml +++ b/charts/memgraph-high-availability/templates/data.yaml @@ -13,6 +13,7 @@ spec: metadata: labels: app: memgraph-data-{{ $data.id }} + instance-type: data spec: {{ if $.Values.memgraph.affinity.enabled }} affinity: @@ -57,9 +58,9 @@ spec: image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" imagePullPolicy: {{ $.Values.memgraph.image.pullPolicy }} ports: - - containerPort: {{ $data.boltPort }} - - containerPort: {{ $data.managementPort }} - - containerPort: {{ $data.replicationPort }} + - containerPort: {{ $.Values.memgraph.ports.boltPort }} + - containerPort: {{ $.Values.memgraph.ports.managementPort }} + - containerPort: {{ $.Values.memgraph.ports.replicationPort }} args: {{- range $arg := $data.args }} - "{{ $arg }}" diff --git a/charts/memgraph-high-availability/templates/external-access.yaml b/charts/memgraph-high-availability/templates/external-access.yaml new file mode 100644 index 0000000..3118ae8 --- /dev/null +++ b/charts/memgraph-high-availability/templates/external-access.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: external-access +spec: + type: NodePort + selector: + instance-type: coordinator + ports: + - protocol: TCP + name: bolt + port: {{ $.Values.memgraph.ports.boltPort }} + targetPort: {{ $.Values.memgraph.ports.boltPort }} diff --git a/charts/memgraph-high-availability/templates/services-coordinators.yaml b/charts/memgraph-high-availability/templates/services-coordinators.yaml index f8a4153..4f75302 100644 --- a/charts/memgraph-high-availability/templates/services-coordinators.yaml +++ b/charts/memgraph-high-availability/templates/services-coordinators.yaml @@ -12,32 +12,14 @@ spec: ports: - protocol: TCP name: bolt - port: {{ .boltPort }} - targetPort: {{ .boltPort }} + port: {{ $.Values.memgraph.ports.boltPort }} + targetPort: {{ $.Values.memgraph.ports.boltPort }} - protocol: TCP name: coordinator - port: {{ .coordinatorPort }} - targetPort: {{ .coordinatorPort }} + port: {{ $.Values.memgraph.ports.coordinatorPort }} + targetPort: {{ $.Values.memgraph.ports.coordinatorPort }} - protocol: TCP name: management - port: {{ .managementPort }} - targetPort: {{ .managementPort }} -{{- end }} - -# Service for coordinators instances external -{{- range .Values.coordinators }} ---- -apiVersion: v1 -kind: Service -metadata: - name: memgraph-coordinator-{{ .id }}-external -spec: - type: NodePort - selector: - app: memgraph-coordinator-{{ .id }} - ports: - - protocol: TCP - name: bolt - port: {{ .boltPort }} - targetPort: {{ .boltPort }} + port: {{ $.Values.memgraph.ports.managementPort }} + targetPort: {{ $.Values.memgraph.ports.managementPort }} {{- end }} diff --git a/charts/memgraph-high-availability/templates/services-data.yaml b/charts/memgraph-high-availability/templates/services-data.yaml index 30b5c22..51d93c4 100644 --- a/charts/memgraph-high-availability/templates/services-data.yaml +++ b/charts/memgraph-high-availability/templates/services-data.yaml @@ -12,32 +12,14 @@ spec: ports: - protocol: TCP name: bolt - port: {{ .boltPort }} - targetPort: {{ .boltPort }} + port: {{ $.Values.memgraph.ports.boltPort }} + targetPort: {{ $.Values.memgraph.ports.boltPort }} - protocol: TCP name: management - port: {{ .managementPort }} - targetPort: {{ .managementPort }} + port: {{ $.Values.memgraph.ports.managementPort }} + targetPort: {{ $.Values.memgraph.ports.managementPort }} - protocol: TCP name: replication - port: {{ .replicationPort }} - targetPort: {{ .replicationPort }} -{{- end }} - -# Service for data instances external -{{- range .Values.data }} ---- -apiVersion: v1 -kind: Service -metadata: - name: memgraph-data-{{ .id }}-external -spec: - type: NodePort - selector: - app: memgraph-data-{{ .id }} - ports: - - protocol: TCP - name: bolt - port: {{ .boltPort }} - targetPort: {{ .boltPort }} + port: {{ $.Values.memgraph.ports.replicationPort }} + targetPort: {{ $.Values.memgraph.ports.replicationPort }} {{- end }} diff --git a/charts/memgraph-high-availability/values.yaml b/charts/memgraph-high-availability/values.yaml index eb5dcaf..a308899 100644 --- a/charts/memgraph-high-availability/values.yaml +++ b/charts/memgraph-high-availability/values.yaml @@ -1,4 +1,4 @@ -# Default values for memgraph-high-availability. +#{{ $.Values.memgraph.image.repository }}: Default values for memgraph-high-availability. # This is a YAML-formatted file. # Declare variables to be passed into your templates.| @@ -38,13 +38,16 @@ memgraph: logPVCSize: "256Mi" affinity: enabled: true + ports: + boltPort: 7687 + managementPort: 10000 + replicationPort: 20000 + coordinatorPort: 12000 + data: - id: "0" - boltPort: 7687 - managementPort: 10000 - replicationPort: 20000 args: - "--experimental-enabled=high-availability" - "--management-port=10000" @@ -54,9 +57,6 @@ data: - "--log-file=/var/log/memgraph/memgraph.log" - id: "1" - boltPort: 7687 - managementPort: 10000 - replicationPort: 20000 args: - "--experimental-enabled=high-availability" - "--management-port=10000" @@ -67,9 +67,6 @@ data: coordinators: - id: "1" - boltPort: 7687 - managementPort: 10000 - coordinatorPort: 12000 args: - "--experimental-enabled=high-availability" - "--coordinator-id=1" @@ -83,9 +80,6 @@ coordinators: - "--nuraft-log-file=/var/log/memgraph/memgraph.log" - id: "2" - boltPort: 7687 - managementPort: 10000 - coordinatorPort: 12000 args: - "--experimental-enabled=high-availability" - "--coordinator-id=2" @@ -99,9 +93,6 @@ coordinators: - "--nuraft-log-file=/var/log/memgraph/memgraph.log" - id: "3" - boltPort: 7687 - managementPort: 10000 - coordinatorPort: 12000 args: - "--experimental-enabled=high-availability" - "--coordinator-id=3" From 0cad7da06f35cc561ef667231f847a2468ca843a Mon Sep 17 00:00:00 2001 From: Andi Skrgat Date: Mon, 25 Nov 2024 10:04:58 +0100 Subject: [PATCH 2/5] Fix linting --- charts/memgraph-high-availability/values.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/charts/memgraph-high-availability/values.yaml b/charts/memgraph-high-availability/values.yaml index a308899..18d4065 100644 --- a/charts/memgraph-high-availability/values.yaml +++ b/charts/memgraph-high-availability/values.yaml @@ -1,7 +1,3 @@ -#{{ $.Values.memgraph.image.repository }}: Default values for memgraph-high-availability. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates.| - memgraph: image: repository: memgraph/memgraph @@ -44,8 +40,6 @@ memgraph: replicationPort: 20000 coordinatorPort: 12000 - - data: - id: "0" args: From 15a6fa8b3a172cda6ddb684a72c85236345f5ed4 Mon Sep 17 00:00:00 2001 From: Andi Skrgat Date: Mon, 25 Nov 2024 12:14:05 +0100 Subject: [PATCH 3/5] Add support for Load balancer --- charts/memgraph-high-availability/README.md | 11 ++++++----- charts/memgraph-high-availability/aws/README.md | 5 +++-- charts/memgraph-high-availability/templates/NOTES.txt | 6 ++++-- .../templates/external-access.yaml | 4 ++++ charts/memgraph-high-availability/values.yaml | 3 +++ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/charts/memgraph-high-availability/README.md b/charts/memgraph-high-availability/README.md index 78e8dd7..0c3e42e 100644 --- a/charts/memgraph-high-availability/README.md +++ b/charts/memgraph-high-availability/README.md @@ -29,7 +29,7 @@ The following table lists the configurable parameters of the Memgraph chart and | 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.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 | `` | | `memgraph.env.MEMGRAPH_ORGANIZATION_NAME` | Organization name | `` | @@ -48,6 +48,11 @@ The following table lists the configurable parameters of the Memgraph chart and | `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 | @@ -56,10 +61,6 @@ For the `data` and `coordinators` sections, each item in the list has the follow | 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/aws/README.md b/charts/memgraph-high-availability/aws/README.md index 2879872..1f2ff24 100644 --- a/charts/memgraph-high-availability/aws/README.md +++ b/charts/memgraph-high-availability/aws/README.md @@ -26,7 +26,7 @@ eksctl create cluster -f cluster.yaml` ``` should be sufficient. Make sure to change the path to the public SSH key if you want to have SSH access to EC2 instances. After creating the cluster, `kubectl` should pick up -the AWS context and you can verify this by running `kubectl context current-context`. My is pointing to `andi.skrgat@test-cluster-ha.eu-west-1.eksctl.io`. +the AWS context and you can verify this by running `kubectl config current-context`. My is pointing to `andi.skrgat@test-cluster-ha.eu-west-1.eksctl.io`. ## Add Helm Charts repository @@ -57,7 +57,8 @@ aws eks describe-nodegroup --cluster-name test-cluster-ha --nodegroup-name stand and then provide full access to it: ``` -aws iam list-attached-role-policies --role-name eksctl-test-cluster-ha-nodegroup-s-NodeInstanceRole- +aws iam attach-role-policy --role-name eksctl-test-cluster-ha-nodegroup-s-NodeInstanceRole- --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess +aws iam list-attached-role-policies --role-name eksctl-test-cluster-ha-nodegroup-s-NodeInstanceRole- ``` It is also important to create Inbound Rule in the Security Group attached to the eksctl cluster which will allow TCP traffic diff --git a/charts/memgraph-high-availability/templates/NOTES.txt b/charts/memgraph-high-availability/templates/NOTES.txt index cf1e705..ce9861a 100644 --- a/charts/memgraph-high-availability/templates/NOTES.txt +++ b/charts/memgraph-high-availability/templates/NOTES.txt @@ -8,9 +8,11 @@ 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.) -If you are connecting via mgconsole, you can use the following command: +If you are using NodePort as the service type for the external access, use node IP and node port to connect. Example using mgconsole: +mgconsole --host= --port= -mgconsole --host --port +If you are using LoadBalancer as the service type for the external access, use IP of the load balancer and its target port to connect. Example using mgconsole: +mgconsole --host= --port= If you are connecting via Lab, specify your instance IP address and port in Memgraph Lab GUI. diff --git a/charts/memgraph-high-availability/templates/external-access.yaml b/charts/memgraph-high-availability/templates/external-access.yaml index 3118ae8..2aa1f4a 100644 --- a/charts/memgraph-high-availability/templates/external-access.yaml +++ b/charts/memgraph-high-availability/templates/external-access.yaml @@ -3,7 +3,11 @@ kind: Service metadata: name: external-access spec: +{{- if eq $.Values.memgraph.externalAccess.serviceType "NodePort"}} type: NodePort +{{- else }} + type: LoadBalancer +{{- end }} selector: instance-type: coordinator ports: diff --git a/charts/memgraph-high-availability/values.yaml b/charts/memgraph-high-availability/values.yaml index 18d4065..a54736e 100644 --- a/charts/memgraph-high-availability/values.yaml +++ b/charts/memgraph-high-availability/values.yaml @@ -39,6 +39,9 @@ memgraph: managementPort: 10000 replicationPort: 20000 coordinatorPort: 12000 + externalAccess: + serviceType: "LoadBalancer" + data: - id: "0" From 3e60e2d129ca86c15c165e901a3422379d844ad7 Mon Sep 17 00:00:00 2001 From: Andi Skrgat Date: Mon, 25 Nov 2024 15:16:34 +0100 Subject: [PATCH 4/5] Restore NodePort svcs on data instances --- .../templates/cluster-setup.yaml | 4 ++-- .../templates/services-data.yaml | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/charts/memgraph-high-availability/templates/cluster-setup.yaml b/charts/memgraph-high-availability/templates/cluster-setup.yaml index e533b61..f2e5e49 100644 --- a/charts/memgraph-high-availability/templates/cluster-setup.yaml +++ b/charts/memgraph-high-availability/templates/cluster-setup.yaml @@ -28,8 +28,8 @@ spec: # Run the mgconsole commands echo "Running mgconsole commands..." - echo 'ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "memgraph-coordinator-2.default.svc.cluster.local:7687", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 - echo 'ADD COORDINATOR 3 WITH CONFIG {"bolt_server": "memgraph-coordinator-3.default.svc.cluster.local:7687", "management_server": "memgraph-coordinator-3.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-3.default.svc.cluster.local:12000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 + echo 'ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "memgraph-coordinator-2.default.svc.cluster.local:7687", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 + echo 'ADD COORDINATOR 3 WITH CONFIG {"bolt_server": "memgraph-coordinator-3.default.svc.cluster.local:7687", "management_server": "memgraph-coordinator-3.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-3.default.svc.cluster.local:12000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 echo 'REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "memgraph-data-0.default.svc.cluster.local:7687", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 echo 'REGISTER INSTANCE instance_2 WITH CONFIG {"bolt_server": "memgraph-data-1.default.svc.cluster.local:7687", "management_server": "memgraph-data-1.default.svc.cluster.local:10000", "replication_server": "memgraph-data-1.default.svc.cluster.local:20000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 echo 'SET INSTANCE instance_1 TO MAIN;' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 diff --git a/charts/memgraph-high-availability/templates/services-data.yaml b/charts/memgraph-high-availability/templates/services-data.yaml index 51d93c4..0e9ad89 100644 --- a/charts/memgraph-high-availability/templates/services-data.yaml +++ b/charts/memgraph-high-availability/templates/services-data.yaml @@ -23,3 +23,21 @@ spec: port: {{ $.Values.memgraph.ports.replicationPort }} targetPort: {{ $.Values.memgraph.ports.replicationPort }} {{- end }} + +# Service for data instances external +{{- range .Values.data }} +--- +apiVersion: v1 +kind: Service +metadata: + name: memgraph-data-{{ .id }}-external +spec: + type: NodePort + selector: + app: memgraph-data-{{ .id }} + ports: + - protocol: TCP + name: bolt + port: {{ $.Values.memgraph.ports.boltPort }} + targetPort: {{ $.Values.memgraph.ports.boltPort }} +{{- end }} From 3e41c2ef772dc3b70d34d39d563954fc73f6885d Mon Sep 17 00:00:00 2001 From: Andi Skrgat Date: Tue, 26 Nov 2024 12:03:06 +0100 Subject: [PATCH 5/5] Update network --- .../aws/cluster.yaml | 4 +- .../templates/NOTES.txt | 18 ++++--- .../templates/cluster-setup.yaml | 51 ------------------- ...xternal-access.yaml => load-balancer.yaml} | 6 +-- .../templates/services-coordinators.yaml | 19 +++++++ .../templates/services-data.yaml | 1 + charts/memgraph-high-availability/values.yaml | 4 +- 7 files changed, 38 insertions(+), 65 deletions(-) delete mode 100644 charts/memgraph-high-availability/templates/cluster-setup.yaml rename charts/memgraph-high-availability/templates/{external-access.yaml => load-balancer.yaml} (75%) diff --git a/charts/memgraph-high-availability/aws/cluster.yaml b/charts/memgraph-high-availability/aws/cluster.yaml index acec423..6d98ab2 100644 --- a/charts/memgraph-high-availability/aws/cluster.yaml +++ b/charts/memgraph-high-availability/aws/cluster.yaml @@ -37,7 +37,7 @@ managedNodeGroups: instanceSelector: {} instanceType: t3.small labels: - alpha.eksctl.io/cluster-name: test-cluster-ha + alpha.eksctl.io/cluster-name: mg-ha alpha.eksctl.io/nodegroup-name: standard-workers maxSize: 5 minSize: 5 @@ -58,7 +58,7 @@ managedNodeGroups: volumeThroughput: 125 volumeType: gp3 metadata: - name: test-cluster-ha + name: mg-ha region: eu-west-1 version: "1.30" privateCluster: diff --git a/charts/memgraph-high-availability/templates/NOTES.txt b/charts/memgraph-high-availability/templates/NOTES.txt index ce9861a..64581a7 100644 --- a/charts/memgraph-high-availability/templates/NOTES.txt +++ b/charts/memgraph-high-availability/templates/NOTES.txt @@ -8,12 +8,18 @@ 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.) -If you are using NodePort as the service type for the external access, use node IP and node port to connect. Example using mgconsole: -mgconsole --host= --port= +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: -If you are using LoadBalancer as the service type for the external access, use IP of the load balancer and its target port to connect. Example using mgconsole: -mgconsole --host= --port= +ADD COORDINATOR 2 WITH CONFIG {"bolt_server": ":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": ":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": ":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": ":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 instance IP address and port in Memgraph Lab GUI. +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. -If you are using minikube, you can find out your instance ip using `minikube ip`. +If you are using minikube, you can find out your node ip using `minikube ip`. + +ADD COORDINATOR 3 WITH CONFIG {"bolt_server": "34.251.38.32: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": "52.50.209.155: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": "34.24.10.69:32011", "management_server": "memgraph-data-1.default.svc.cluster.local:10000", "replication_server": "memgraph-data-1.default.svc.cluster.local:20000"}; diff --git a/charts/memgraph-high-availability/templates/cluster-setup.yaml b/charts/memgraph-high-availability/templates/cluster-setup.yaml deleted file mode 100644 index f2e5e49..0000000 --- a/charts/memgraph-high-availability/templates/cluster-setup.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: memgraph-setup -spec: - template: - spec: - containers: - - name: memgraph-setup - image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" - command: ["/bin/bash", "-c"] - args: - - | - # Install netcat - echo "Installing netcat..." - apt-get update && apt-get install -y netcat-openbsd - - # Wait until the pods are available - echo "Waiting for pods to become available for Bolt connection..." - until nc -z memgraph-coordinator-1.default.svc.cluster.local 7687; do sleep 1; done - until nc -z memgraph-coordinator-2.default.svc.cluster.local 7687; do sleep 1; done - until nc -z memgraph-coordinator-3.default.svc.cluster.local 7687; do sleep 1; done - until nc -z memgraph-data-0.default.svc.cluster.local 7687; do sleep 1; done - until nc -z memgraph-data-1.default.svc.cluster.local 7687; do sleep 1; done - echo "Pods are available for Bolt connection!" - - sleep 5 - - # Run the mgconsole commands - echo "Running mgconsole commands..." - echo 'ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "memgraph-coordinator-2.default.svc.cluster.local:7687", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 - echo 'ADD COORDINATOR 3 WITH CONFIG {"bolt_server": "memgraph-coordinator-3.default.svc.cluster.local:7687", "management_server": "memgraph-coordinator-3.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-3.default.svc.cluster.local:12000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 - echo 'REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "memgraph-data-0.default.svc.cluster.local:7687", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 - echo 'REGISTER INSTANCE instance_2 WITH CONFIG {"bolt_server": "memgraph-data-1.default.svc.cluster.local:7687", "management_server": "memgraph-data-1.default.svc.cluster.local:10000", "replication_server": "memgraph-data-1.default.svc.cluster.local:20000"};' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 - echo 'SET INSTANCE instance_1 TO MAIN;' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 - sleep 3 - echo "SHOW INSTANCES on coord1" - echo 'SHOW INSTANCES;' | mgconsole --host memgraph-coordinator-1.default.svc.cluster.local --port 7687 - echo "SHOW INSTANCES on coord2" - echo 'SHOW INSTANCES;' | mgconsole --host memgraph-coordinator-2.default.svc.cluster.local --port 7687 - echo "SHOW INSTANCES on coord3" - echo 'SHOW INSTANCES;' | mgconsole --host memgraph-coordinator-3.default.svc.cluster.local --port 7687 - echo "RETURN 0 on 1st data instance" - echo 'RETURN 0;' | mgconsole --host memgraph-data-0.default.svc.cluster.local --port 7687 - echo "RETURN 0 on 2nd data instance" - echo 'RETURN 0;' | mgconsole --host memgraph-data-1.default.svc.cluster.local --port 7687 - securityContext: - runAsUser: 0 - - restartPolicy: Never - backoffLimit: 4 diff --git a/charts/memgraph-high-availability/templates/external-access.yaml b/charts/memgraph-high-availability/templates/load-balancer.yaml similarity index 75% rename from charts/memgraph-high-availability/templates/external-access.yaml rename to charts/memgraph-high-availability/templates/load-balancer.yaml index 2aa1f4a..c8c497f 100644 --- a/charts/memgraph-high-availability/templates/external-access.yaml +++ b/charts/memgraph-high-availability/templates/load-balancer.yaml @@ -1,13 +1,10 @@ +{{- if $.Values.memgraph.coordLoadBalancer.enabled}} apiVersion: v1 kind: Service metadata: name: external-access spec: -{{- if eq $.Values.memgraph.externalAccess.serviceType "NodePort"}} - type: NodePort -{{- else }} type: LoadBalancer -{{- end }} selector: instance-type: coordinator ports: @@ -15,3 +12,4 @@ spec: name: bolt port: {{ $.Values.memgraph.ports.boltPort }} targetPort: {{ $.Values.memgraph.ports.boltPort }} +{{- end }} diff --git a/charts/memgraph-high-availability/templates/services-coordinators.yaml b/charts/memgraph-high-availability/templates/services-coordinators.yaml index 4f75302..13ed7aa 100644 --- a/charts/memgraph-high-availability/templates/services-coordinators.yaml +++ b/charts/memgraph-high-availability/templates/services-coordinators.yaml @@ -23,3 +23,22 @@ spec: port: {{ $.Values.memgraph.ports.managementPort }} targetPort: {{ $.Values.memgraph.ports.managementPort }} {{- end }} + +# Service for coordinators instances external +{{- range .Values.coordinators }} +--- +apiVersion: v1 +kind: Service +metadata: + name: memgraph-coordinator-{{ .id }}-external +spec: + type: NodePort + selector: + app: memgraph-coordinator-{{ .id }} + ports: + - protocol: TCP + name: bolt + port: {{ $.Values.memgraph.ports.boltPort }} + targetPort: {{ $.Values.memgraph.ports.boltPort }} + nodePort: {{ add 32000 .id }} +{{- end }} diff --git a/charts/memgraph-high-availability/templates/services-data.yaml b/charts/memgraph-high-availability/templates/services-data.yaml index 0e9ad89..e9c3569 100644 --- a/charts/memgraph-high-availability/templates/services-data.yaml +++ b/charts/memgraph-high-availability/templates/services-data.yaml @@ -40,4 +40,5 @@ spec: name: bolt port: {{ $.Values.memgraph.ports.boltPort }} targetPort: {{ $.Values.memgraph.ports.boltPort }} + nodePort: {{ add 32010 .id }} {{- end }} diff --git a/charts/memgraph-high-availability/values.yaml b/charts/memgraph-high-availability/values.yaml index a54736e..ef2fbf6 100644 --- a/charts/memgraph-high-availability/values.yaml +++ b/charts/memgraph-high-availability/values.yaml @@ -39,8 +39,8 @@ memgraph: managementPort: 10000 replicationPort: 20000 coordinatorPort: 12000 - externalAccess: - serviceType: "LoadBalancer" + coordLoadBalancer: + enabled: true data: