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: