Skip to content

Commit

Permalink
Add ingress-nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
as51340 committed Dec 4, 2024
1 parent 239d061 commit 26f99f6
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 74 deletions.
11 changes: 7 additions & 4 deletions charts/memgraph-high-availability/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ CommonLoadBalancer configuration example
ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "<COMMON-LB-IP>:7687", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};
REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "<INST1-LB-IP>:7687", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};

IngressNginx

If you are using ingress-nginx there are several steps we need to do in order to make use of it.

ADD COORDINATOR 2 WITH CONFIG {"bolt_server": "<ingress-LB-external-ip>:9012", "management_server": "memgraph-coordinator-2.default.svc.cluster.local:10000", "coordinator_server": "memgraph-coordinator-2.default.svc.cluster.local:12000"};
REGISTER INSTANCE instance_1 WITH CONFIG {"bolt_server": "<ingress-LB-external-ip>:9001", "management_server": "memgraph-data-0.default.svc.cluster.local:10000", "replication_server": "memgraph-data-0.default.svc.cluster.local:20000"};


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 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"};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Namespace
metadata:
name: ingress-nginx
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- $validCoordServices := list "CommonLoadBalancer" "LoadBalancer" "NodePort" "IngressNginx" }}
{{- if not (has .Values.memgraph.externalAccessConfig.coordinator.serviceType $validCoordServices) }}
{{- fail "Invalid environment value for memgraph.externlAccessConfig.coordinator.serviceType. Use 'CommonLoadBalancer', 'LoadBalancer', 'NodePort' or 'IngressNginx'."}}
{{- end }}

{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "IngressNginx"}}
# Placeholder
{{ else if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "CommonLoadBalancer"}}
apiVersion: v1
kind: Service
metadata:
name: coordinators
spec:
type: LoadBalancer
selector:
role: coordinator
ports:
- protocol: TCP
name: bolt
port: {{ $.Values.memgraph.ports.boltPort }}
targetPort: {{ $.Values.memgraph.ports.boltPort }}
{{ else }}
{{- range .Values.coordinators }}
---
apiVersion: v1
kind: Service
metadata:
name: memgraph-coordinator-{{ .id }}-external
spec:
{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "LoadBalancer"}}
type: LoadBalancer
{{ else }}
type: NodePort
{{ end }}
selector:
app: memgraph-coordinator-{{ .id }}
ports:
- protocol: TCP
name: bolt
port: {{ $.Values.memgraph.ports.boltPort }}
targetPort: {{ $.Values.memgraph.ports.boltPort }}
{{- end }}
{{ end}}
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{{- $validCoordServices := list "CommonLoadBalancer" "LoadBalancer" "NodePort" }}
{{- if not (has .Values.memgraph.externalAccessConfig.coordinator.serviceType $validCoordServices) }}
{{- fail "Invalid environment value for memgraph.externlAccessConfig.coordinator.serviceType. Use 'CommonLoadBalancer', 'LoadBalancer' or 'NodePort'."}}
{{- end }}


{{- range .Values.coordinators }}
---
apiVersion: v1
Expand All @@ -28,40 +22,3 @@ spec:
port: {{ $.Values.memgraph.ports.managementPort }}
targetPort: {{ $.Values.memgraph.ports.managementPort }}
{{- end }}

{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "CommonLoadBalancer"}}
apiVersion: v1
kind: Service
metadata:
name: coordinators
spec:
type: LoadBalancer
selector:
role: coordinator
ports:
- protocol: TCP
name: bolt
port: {{ $.Values.memgraph.ports.boltPort }}
targetPort: {{ $.Values.memgraph.ports.boltPort }}
{{ else }}
{{- range .Values.coordinators }}
---
apiVersion: v1
kind: Service
metadata:
name: memgraph-coordinator-{{ .id }}-external
spec:
{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "LoadBalancer"}}
type: LoadBalancer
{{ else }}
type: NodePort
{{ end }}
selector:
app: memgraph-coordinator-{{ .id }}
ports:
- protocol: TCP
name: bolt
port: {{ $.Values.memgraph.ports.boltPort }}
targetPort: {{ $.Values.memgraph.ports.boltPort }}
{{- end }}
{{ end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- $validDataServices := list "LoadBalancer" "NodePort" "IngressNginx" }}
{{- if not (has .Values.memgraph.externalAccessConfig.dataInstance.serviceType $validDataServices) }}
{{- fail "Invalid environment value for memgraph.externalAccessConfig.dataInstance.serviceType. Use 'LoadBalancer', 'NodePort' or 'IngressNginx'."}}
{{- end }}


{{ if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "IngressNginx"}}
# Placeholder
{{ else }}
{{- range .Values.data }}
---
apiVersion: v1
kind: Service
metadata:
name: memgraph-data-{{ .id }}-external
spec:
{{ if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "NodePort"}}
type: NodePort
{{ else }}
type: LoadBalancer
{{ end }}
selector:
app: memgraph-data-{{ .id }}
ports:
- protocol: TCP
name: bolt
port: {{ $.Values.memgraph.ports.boltPort }}
targetPort: {{ $.Values.memgraph.ports.boltPort }}
{{- end }}
{{ end }}
27 changes: 0 additions & 27 deletions charts/memgraph-high-availability/templates/services-data.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{{- $validDataServices := list "LoadBalancer" "NodePort" }}
{{- if not (has .Values.memgraph.externalAccessConfig.dataInstance.serviceType $validDataServices) }}
{{- fail "Invalid environment value for memgraph.externalAccessConfig.dataInstance.serviceType. Use 'LoadBalancer' or 'NodePort'."}}
{{- end }}

{{- range .Values.data }}
---
apiVersion: v1
Expand All @@ -27,25 +22,3 @@ 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:
{{ if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "NodePort"}}
type: NodePort
{{ else }}
type: LoadBalancer
{{ end }}
selector:
app: memgraph-data-{{ .id }}
ports:
- protocol: TCP
name: bolt
port: {{ $.Values.memgraph.ports.boltPort }}
targetPort: {{ $.Values.memgraph.ports.boltPort }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if or (eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "IngressNginx") (eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "IngressNginx") }}
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
{{- if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "IngressNginx"}}
9000: "default/memgraph-data-0:7687"
9001: "default/memgraph-data-1:7687"
{{- end }}
{{- if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "IngressNginx"}}
9011: "default/memgraph-coordinator-1:7687"
9012: "default/memgraph-coordinator-2:7687"
9013: "default/memgraph-coordinator-3:7687"
{{- end }}
{{- end }}

0 comments on commit 26f99f6

Please sign in to comment.