Skip to content

Commit

Permalink
HA affinity (#55)
Browse files Browse the repository at this point in the history
* Add affinity to HA chart.
  • Loading branch information
antejavor authored Aug 14, 2024
1 parent 072af5a commit d73a57c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/lint-test-high-availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions charts/memgraph-high-availability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
16 changes: 16 additions & 0 deletions charts/memgraph-high-availability/templates/coordinators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
16 changes: 16 additions & 0 deletions charts/memgraph-high-availability/templates/data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
2 changes: 2 additions & 0 deletions charts/memgraph-high-availability/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ memgraph:
logPVCClassName: ""
logPVC: true
logPVCSize: "256Mi"
affinity:
enabled: true


data:
Expand Down

0 comments on commit d73a57c

Please sign in to comment.