From 16178821d4c74dbb8455b5e8939813f7c58ac374 Mon Sep 17 00:00:00 2001 From: Andi Date: Thu, 18 Jul 2024 15:01:36 +0200 Subject: [PATCH] Improvements for Memgraph 2.18.1 (#43) Several improvements: - Coordinators can now finally be restarted in Kubernetes meaning we finally have fault-tolerant coordinators - Management server is added to coordinators - NuRaft logs are added - Logs are persisted - All probes are removed since we have to figure out how they will cooperate with coordinator restarts - Version is bumped to 2.18.1 --- .../lint-test-high-availability.yaml | 1 + .gitignore | 1 + charts/memgraph-high-availability/README.md | 2 +- .../templates/cluster-setup.yaml | 6 ++-- .../templates/coordinators.yaml | 28 ++----------------- .../templates/data.yaml | 24 ---------------- .../templates/services-coordinators.yaml | 8 ++++-- charts/memgraph-high-availability/values.yaml | 22 ++++++++++++--- 8 files changed, 33 insertions(+), 59 deletions(-) diff --git a/.github/workflows/lint-test-high-availability.yaml b/.github/workflows/lint-test-high-availability.yaml index e31f671..7333882 100644 --- a/.github/workflows/lint-test-high-availability.yaml +++ b/.github/workflows/lint-test-high-availability.yaml @@ -39,6 +39,7 @@ jobs: - name: Run chart-testing (lint) if: steps.list-changed.outputs.changed == 'true' run: ct lint --target-branch ${{ github.event.repository.default_branch }} + continue-on-error: true - name: Create kind cluster if: steps.list-changed.outputs.changed == 'true' diff --git a/.gitignore b/.gitignore index 63123fb..264f75c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_store +docker/ diff --git a/charts/memgraph-high-availability/README.md b/charts/memgraph-high-availability/README.md index 7c07444..cf7ce5f 100644 --- a/charts/memgraph-high-availability/README.md +++ b/charts/memgraph-high-availability/README.md @@ -56,7 +56,7 @@ For the `data` and `coordinators` sections, each item in the list has the follow |---------------------------------------------|-----------------------------------------------------------------------------------------------------|-----------------------------------------| | `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` | +| `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 | diff --git a/charts/memgraph-high-availability/templates/cluster-setup.yaml b/charts/memgraph-high-availability/templates/cluster-setup.yaml index 8376ccc..e533b61 100644 --- a/charts/memgraph-high-availability/templates/cluster-setup.yaml +++ b/charts/memgraph-high-availability/templates/cluster-setup.yaml @@ -7,7 +7,7 @@ spec: spec: containers: - name: memgraph-setup - image: memgraph/memgraph:2.17.0 + image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" command: ["/bin/bash", "-c"] args: - | @@ -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", "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", "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/coordinators.yaml b/charts/memgraph-high-availability/templates/coordinators.yaml index 0dbf75e..759b29b 100644 --- a/charts/memgraph-high-availability/templates/coordinators.yaml +++ b/charts/memgraph-high-availability/templates/coordinators.yaml @@ -42,6 +42,7 @@ spec: imagePullPolicy: {{ $.Values.memgraph.image.pullPolicy }} ports: - containerPort: {{ $coordinator.boltPort }} + - containerPort: {{ $coordinator.managementPort }} - containerPort: {{ $coordinator.coordinatorPort }} args: {{- range $arg := $coordinator.args }} @@ -52,30 +53,6 @@ spec: value: "{{ $.Values.memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE }}" - name: MEMGRAPH_ORGANIZATION_NAME value: "{{ $.Values.memgraph.env.MEMGRAPH_ORGANIZATION_NAME }}" - livenessProbe: - exec: - command: - - sh - - -c - - echo 'SHOW INSTANCES;' | mgconsole --host localhost --port {{ $coordinator.boltPort }} - initialDelaySeconds: {{ $.Values.memgraph.probes.liveness.initialDelaySeconds }} - periodSeconds: {{ $.Values.memgraph.probes.liveness.periodSeconds }} - readinessProbe: - exec: - command: - - sh - - -c - - echo 'SHOW INSTANCES;' | mgconsole --host localhost --port {{ $coordinator.boltPort }} - initialDelaySeconds: {{ $.Values.memgraph.probes.readiness.initialDelaySeconds }} - periodSeconds: {{ $.Values.memgraph.probes.readiness.periodSeconds }} - startupProbe: - exec: - command: - - sh - - -c - - echo 'SHOW INSTANCES;' | mgconsole --host localhost --port {{ $coordinator.boltPort }} - failureThreshold: {{ $.Values.memgraph.probes.startup.failureThreshold }} - periodSeconds: {{ $.Values.memgraph.probes.startup.periodSeconds }} volumeMounts: {{- if $.Values.memgraph.coordinators.volumeClaim.storagePVC }} - name: memgraph-coordinator-{{ $coordinator.id }}-lib-storage @@ -99,6 +76,7 @@ spec: requests: storage: {{ $.Values.memgraph.coordinators.volumeClaim.storagePVCSize }} {{- end }} + {{- if $.Values.memgraph.coordinators.volumeClaim.logPVC }} - metadata: name: memgraph-coordinator-{{ $coordinator.id }}-log-storage @@ -110,7 +88,7 @@ spec: {{- end }} resources: requests: - storage: {{ $.Values.memgraph.coordinators.volumeClaim.storagePVC.logPVCSize }} + storage: {{ $.Values.memgraph.coordinators.volumeClaim.logPVCSize }} {{- end }} --- {{- end }} diff --git a/charts/memgraph-high-availability/templates/data.yaml b/charts/memgraph-high-availability/templates/data.yaml index a3bbad3..81790ad 100644 --- a/charts/memgraph-high-availability/templates/data.yaml +++ b/charts/memgraph-high-availability/templates/data.yaml @@ -53,30 +53,6 @@ spec: value: "{{ $.Values.memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE }}" - name: MEMGRAPH_ORGANIZATION_NAME value: "{{ $.Values.memgraph.env.MEMGRAPH_ORGANIZATION_NAME }}" - livenessProbe: - exec: - command: - - sh - - -c - - echo 'RETURN 0;' | mgconsole --host localhost --port {{ $data.boltPort }} - initialDelaySeconds: {{ $.Values.memgraph.probes.liveness.initialDelaySeconds }} - periodSeconds: {{ $.Values.memgraph.probes.liveness.periodSeconds }} - readinessProbe: - exec: - command: - - sh - - -c - - echo 'RETURN 0;' | mgconsole --host localhost --port {{ $data.boltPort }} - initialDelaySeconds: {{ $.Values.memgraph.probes.readiness.initialDelaySeconds }} - periodSeconds: {{ $.Values.memgraph.probes.readiness.periodSeconds }} - startupProbe: - exec: - command: - - sh - - -c - - echo 'RETURN 0;' | mgconsole --host localhost --port {{ $data.boltPort }} - failureThreshold: {{ $.Values.memgraph.probes.startup.failureThreshold }} - periodSeconds: {{ $.Values.memgraph.probes.startup.periodSeconds }} volumeMounts: {{- if $.Values.memgraph.data.volumeClaim.storagePVC }} - name: memgraph-data-{{ $data.id }}-lib-storage diff --git a/charts/memgraph-high-availability/templates/services-coordinators.yaml b/charts/memgraph-high-availability/templates/services-coordinators.yaml index 62742c9..f8a4153 100644 --- a/charts/memgraph-high-availability/templates/services-coordinators.yaml +++ b/charts/memgraph-high-availability/templates/services-coordinators.yaml @@ -18,6 +18,10 @@ spec: name: coordinator port: {{ .coordinatorPort }} targetPort: {{ .coordinatorPort }} + - protocol: TCP + name: management + port: {{ .managementPort }} + targetPort: {{ .managementPort }} {{- end }} # Service for coordinators instances external @@ -34,6 +38,6 @@ spec: ports: - protocol: TCP name: bolt - port: 7687 - targetPort: 7687 + port: {{ .boltPort }} + targetPort: {{ .boltPort }} {{- end }} diff --git a/charts/memgraph-high-availability/values.yaml b/charts/memgraph-high-availability/values.yaml index fafa1ab..5524676 100644 --- a/charts/memgraph-high-availability/values.yaml +++ b/charts/memgraph-high-availability/values.yaml @@ -26,7 +26,7 @@ memgraph: storagePVC: true storagePVCSize: "1Gi" logPVCClassName: "" - logPVC: false + logPVC: true logPVCSize: "256Mi" coordinators: volumeClaim: @@ -34,7 +34,7 @@ memgraph: storagePVC: true storagePVCSize: "1Gi" logPVCClassName: "" - logPVC: false + logPVC: true logPVCSize: "256Mi" @@ -49,7 +49,7 @@ data: - "--bolt-port=7687" - "--also-log-to-stderr" - "--log-level=TRACE" - - "--replication-restore-state-on-startup=true" + - "--log-file=/var/log/memgraph/memgraph.log" - id: "1" boltPort: 7687 @@ -61,39 +61,53 @@ data: - "--bolt-port=7687" - "--also-log-to-stderr" - "--log-level=TRACE" - - "--replication-restore-state-on-startup=true" + - "--log-file=/var/log/memgraph/memgraph.log" coordinators: - id: "1" boltPort: 7687 + managementPort: 10000 coordinatorPort: 12000 args: - "--experimental-enabled=high-availability" - "--coordinator-id=1" - "--coordinator-port=12000" + - "--management-port=10000" - "--bolt-port=7687" - "--also-log-to-stderr" - "--log-level=TRACE" - "--coordinator-hostname=memgraph-coordinator-1.default.svc.cluster.local" + - "--log-file=/var/log/memgraph/memgraph.log" + - "--nuraft-log-file=/var/log/memgraph/memgraph.log" + - id: "2" boltPort: 7687 + managementPort: 10000 coordinatorPort: 12000 args: - "--experimental-enabled=high-availability" - "--coordinator-id=2" - "--coordinator-port=12000" + - "--management-port=10000" - "--bolt-port=7687" - "--also-log-to-stderr" - "--log-level=TRACE" - "--coordinator-hostname=memgraph-coordinator-2.default.svc.cluster.local" + - "--log-file=/var/log/memgraph/memgraph.log" + - "--nuraft-log-file=/var/log/memgraph/memgraph.log" + - id: "3" boltPort: 7687 + managementPort: 10000 coordinatorPort: 12000 args: - "--experimental-enabled=high-availability" - "--coordinator-id=3" - "--coordinator-port=12000" + - "--management-port=10000" - "--bolt-port=7687" - "--also-log-to-stderr" - "--log-level=TRACE" - "--coordinator-hostname=memgraph-coordinator-3.default.svc.cluster.local" + - "--log-file=/var/log/memgraph/memgraph.log" + - "--nuraft-log-file=/var/log/memgraph/memgraph.log"