diff --git a/.github/workflows/lint-test-high-availability.yaml b/.github/workflows/lint-test-high-availability.yaml index f3fb32d..ba2559f 100644 --- a/.github/workflows/lint-test-high-availability.yaml +++ b/.github/workflows/lint-test-high-availability.yaml @@ -59,7 +59,8 @@ jobs: run: | helm install mem-ha-test ./charts/memgraph-high-availability \ --set memgraph.env.MEMGRAPH_ENTERPRISE_LICENSE=$MEMGRAPH_ENTERPRISE_LICENSE \ - --set memgraph.env.MEMGRAPH_ORGANIZATION_NAME=$MEMGRAPH_ORGANIZATION_NAME + --set memgraph.env.MEMGRAPH_ORGANIZATION_NAME=$MEMGRAPH_ORGANIZATION_NAME \ + --set memgraph.affinity.enabled=false - name: Wait for Memgraph setup to complete if: steps.list-changed.outputs.changed == 'true' diff --git a/charts/memgraph-high-availability/README.md b/charts/memgraph-high-availability/README.md index ac7dbad..6031386 100644 --- a/charts/memgraph-high-availability/README.md +++ b/charts/memgraph-high-availability/README.md @@ -47,6 +47,7 @@ The following table lists the configurable parameters of the Memgraph chart and | `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` | | `data` | Configuration for data instances | See `data` section | | `coordinators` | Configuration for coordinator instances | See `coordinators` section | diff --git a/charts/memgraph-high-availability/templates/coordinators.yaml b/charts/memgraph-high-availability/templates/coordinators.yaml index 759b29b..74aeb00 100644 --- a/charts/memgraph-high-availability/templates/coordinators.yaml +++ b/charts/memgraph-high-availability/templates/coordinators.yaml @@ -14,6 +14,22 @@ spec: labels: app: memgraph-coordinator-{{ $coordinator.id }} spec: + {{ if $.Values.memgraph.affinity.enabled }} + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - memgraph-coordinator-1 + - memgraph-coordinator-2 + - memgraph-coordinator-3 + - memgraph-data-0 + - memgraph-data-1 + topologyKey: "kubernetes.io/hostname" + {{ end }} initContainers: - name: init image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" diff --git a/charts/memgraph-high-availability/templates/data.yaml b/charts/memgraph-high-availability/templates/data.yaml index 81790ad..5d1758a 100644 --- a/charts/memgraph-high-availability/templates/data.yaml +++ b/charts/memgraph-high-availability/templates/data.yaml @@ -14,6 +14,22 @@ spec: labels: app: memgraph-data-{{ $data.id }} spec: + {{ if $.Values.memgraph.affinity.enabled }} + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app + operator: In + values: + - memgraph-coordinator-1 + - memgraph-coordinator-2 + - memgraph-coordinator-3 + - memgraph-data-0 + - memgraph-data-1 + topologyKey: "kubernetes.io/hostname" + {{ end }} initContainers: - name: init image: "{{ $.Values.memgraph.image.repository }}:{{ $.Values.memgraph.image.tag }}" diff --git a/charts/memgraph-high-availability/values.yaml b/charts/memgraph-high-availability/values.yaml index a6a756c..eb5dcaf 100644 --- a/charts/memgraph-high-availability/values.yaml +++ b/charts/memgraph-high-availability/values.yaml @@ -36,6 +36,8 @@ memgraph: logPVCClassName: "" logPVC: true logPVCSize: "256Mi" + affinity: + enabled: true data: