Skip to content

Commit 3c77fe6

Browse files
authored
Add IngressNginx as revery proxy ingress solution (memgraph#92)
1 parent 36627d4 commit 3c77fe6

10 files changed

+108
-77
lines changed

charts/memgraph-high-availability/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: memgraph-high-availability
33
description: A Helm chart for Kubernetes with Memgraph High availabiliy capabilites
44

5-
version: 0.1.4
5+
version: 0.1.5
66
appVersion: "2.22.0"
77

88
type: application

charts/memgraph-high-availability/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ The following table lists the configurable parameters of the Memgraph chart and
4646
| `memgraph.coordinators.volumeClaim.storagePVCSize` | Size of the storage PVC for coordinators | `1Gi` |
4747
| `memgraph.coordinators.volumeClaim.logPVC` | Enable log PVC for coordinators | `false` |
4848
| `memgraph.coordinators.volumeClaim.logPVCSize` | Size of the log PVC for coordinators | `256Mi` |
49-
| `memgraph.externalAccess.coordinator.serviceType` | NodePort, CommonLoadBalancer or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing. 'CommonLoadBalancer' will open one load balancer for all coordinators while 'LoadBalancer' will open one load balancer for each coordinators. | `NodePort` |
50-
| `memgraph.externalAccess.dataInstance.serviceType` | NodePort or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing. | `NodePort` |
49+
| `memgraph.externalAccess.coordinator.serviceType` | IngressNginx, NodePort, CommonLoadBalancer or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing. 'CommonLoadBalancer' will open one load balancer for all coordinators while 'LoadBalancer' will open one load balancer for each coordinators. IngressNginx will create ingress controller that will allow TCP connections towards coordinator services. | `NodePort` |
50+
| `memgraph.externalAccess.dataInstance.serviceType` | IngressNginx, NodePort or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing. IngressNginx will create ingress controller that will allow TCP connections towards data instances' services. | `NodePort` |
5151
| `memgraph.ports.boltPort` | Bolt port used on coordinator and data instances. | `7687` |
5252
| `memgraph.ports.managementPort` | Management port used on coordinator and data instances. | `10000` |
5353
| `memgraph.ports.replicationPort` | Replication port used on data instances. | `20000` |

charts/memgraph-high-availability/templates/NOTES.txt

+7-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ CommonLoadBalancer configuration example
3131
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"};
3232
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"};
3333

34+
IngressNginx
35+
36+
If you are using ingress-nginx there are several steps we need to do in order to make use of it.
37+
38+
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"};
39+
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"};
40+
3441

3542
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.
3643

3744
If you are using minikube, you can find out your node ip using `minikube ip`.
38-
39-
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"};
40-
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"};
41-
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 numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: ingress-nginx
5+
annotations:
6+
"helm.sh/hook": pre-install
7+
"helm.sh/hook-weight": "-5"
8+
"helm.sh/hook-delete-policy": before-hook-creation

charts/memgraph-high-availability/templates/load-balancer.yaml

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- $validCoordServices := list "CommonLoadBalancer" "LoadBalancer" "NodePort" "IngressNginx" }}
2+
{{- if not (has .Values.memgraph.externalAccessConfig.coordinator.serviceType $validCoordServices) }}
3+
{{- fail "Invalid environment value for memgraph.externlAccessConfig.coordinator.serviceType. Use 'CommonLoadBalancer', 'LoadBalancer', 'NodePort' or 'IngressNginx'."}}
4+
{{- end }}
5+
6+
{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "IngressNginx"}}
7+
# Placeholder
8+
{{ else if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "CommonLoadBalancer"}}
9+
apiVersion: v1
10+
kind: Service
11+
metadata:
12+
name: coordinators
13+
spec:
14+
type: LoadBalancer
15+
selector:
16+
role: coordinator
17+
ports:
18+
- protocol: TCP
19+
name: bolt
20+
port: {{ $.Values.memgraph.ports.boltPort }}
21+
targetPort: {{ $.Values.memgraph.ports.boltPort }}
22+
{{ else }}
23+
{{- range .Values.coordinators }}
24+
---
25+
apiVersion: v1
26+
kind: Service
27+
metadata:
28+
name: memgraph-coordinator-{{ .id }}-external
29+
spec:
30+
{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "LoadBalancer"}}
31+
type: LoadBalancer
32+
{{ else }}
33+
type: NodePort
34+
{{ end }}
35+
selector:
36+
app: memgraph-coordinator-{{ .id }}
37+
ports:
38+
- protocol: TCP
39+
name: bolt
40+
port: {{ $.Values.memgraph.ports.boltPort }}
41+
targetPort: {{ $.Values.memgraph.ports.boltPort }}
42+
{{- end }}
43+
{{ end}}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
{{- $validCoordServices := list "CommonLoadBalancer" "LoadBalancer" "NodePort" }}
2-
{{- if not (has .Values.memgraph.externalAccessConfig.coordinator.serviceType $validCoordServices) }}
3-
{{- fail "Invalid environment value for memgraph.externlAccessConfig.coordinator.serviceType. Use 'CommonLoadBalancer', 'LoadBalancer' or 'NodePort'."}}
4-
{{- end }}
5-
6-
71
{{- range .Values.coordinators }}
82
---
93
apiVersion: v1
@@ -28,40 +22,3 @@ spec:
2822
port: {{ $.Values.memgraph.ports.managementPort }}
2923
targetPort: {{ $.Values.memgraph.ports.managementPort }}
3024
{{- end }}
31-
32-
{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "CommonLoadBalancer"}}
33-
apiVersion: v1
34-
kind: Service
35-
metadata:
36-
name: coordinators
37-
spec:
38-
type: LoadBalancer
39-
selector:
40-
role: coordinator
41-
ports:
42-
- protocol: TCP
43-
name: bolt
44-
port: {{ $.Values.memgraph.ports.boltPort }}
45-
targetPort: {{ $.Values.memgraph.ports.boltPort }}
46-
{{ else }}
47-
{{- range .Values.coordinators }}
48-
---
49-
apiVersion: v1
50-
kind: Service
51-
metadata:
52-
name: memgraph-coordinator-{{ .id }}-external
53-
spec:
54-
{{ if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "LoadBalancer"}}
55-
type: LoadBalancer
56-
{{ else }}
57-
type: NodePort
58-
{{ end }}
59-
selector:
60-
app: memgraph-coordinator-{{ .id }}
61-
ports:
62-
- protocol: TCP
63-
name: bolt
64-
port: {{ $.Values.memgraph.ports.boltPort }}
65-
targetPort: {{ $.Values.memgraph.ports.boltPort }}
66-
{{- end }}
67-
{{ end}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{- $validDataServices := list "LoadBalancer" "NodePort" "IngressNginx" }}
2+
{{- if not (has .Values.memgraph.externalAccessConfig.dataInstance.serviceType $validDataServices) }}
3+
{{- fail "Invalid environment value for memgraph.externalAccessConfig.dataInstance.serviceType. Use 'LoadBalancer', 'NodePort' or 'IngressNginx'."}}
4+
{{- end }}
5+
6+
7+
{{ if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "IngressNginx"}}
8+
# Placeholder
9+
{{ else }}
10+
{{- range .Values.data }}
11+
---
12+
apiVersion: v1
13+
kind: Service
14+
metadata:
15+
name: memgraph-data-{{ .id }}-external
16+
spec:
17+
{{ if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "NodePort"}}
18+
type: NodePort
19+
{{ else }}
20+
type: LoadBalancer
21+
{{ end }}
22+
selector:
23+
app: memgraph-data-{{ .id }}
24+
ports:
25+
- protocol: TCP
26+
name: bolt
27+
port: {{ $.Values.memgraph.ports.boltPort }}
28+
targetPort: {{ $.Values.memgraph.ports.boltPort }}
29+
{{- end }}
30+
{{ end }}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
{{- $validDataServices := list "LoadBalancer" "NodePort" }}
2-
{{- if not (has .Values.memgraph.externalAccessConfig.dataInstance.serviceType $validDataServices) }}
3-
{{- fail "Invalid environment value for memgraph.externalAccessConfig.dataInstance.serviceType. Use 'LoadBalancer' or 'NodePort'."}}
4-
{{- end }}
5-
61
{{- range .Values.data }}
72
---
83
apiVersion: v1
@@ -27,25 +22,3 @@ spec:
2722
port: {{ $.Values.memgraph.ports.replicationPort }}
2823
targetPort: {{ $.Values.memgraph.ports.replicationPort }}
2924
{{- end }}
30-
31-
# Service for data instances external
32-
{{- range .Values.data }}
33-
---
34-
apiVersion: v1
35-
kind: Service
36-
metadata:
37-
name: memgraph-data-{{ .id }}-external
38-
spec:
39-
{{ if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "NodePort"}}
40-
type: NodePort
41-
{{ else }}
42-
type: LoadBalancer
43-
{{ end }}
44-
selector:
45-
app: memgraph-data-{{ .id }}
46-
ports:
47-
- protocol: TCP
48-
name: bolt
49-
port: {{ $.Values.memgraph.ports.boltPort }}
50-
targetPort: {{ $.Values.memgraph.ports.boltPort }}
51-
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if or (eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "IngressNginx") (eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "IngressNginx") }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: tcp-services
6+
namespace: ingress-nginx
7+
data:
8+
{{- if eq $.Values.memgraph.externalAccessConfig.dataInstance.serviceType "IngressNginx"}}
9+
9000: "default/memgraph-data-0:7687"
10+
9001: "default/memgraph-data-1:7687"
11+
{{- end }}
12+
{{- if eq $.Values.memgraph.externalAccessConfig.coordinator.serviceType "IngressNginx"}}
13+
9011: "default/memgraph-coordinator-1:7687"
14+
9012: "default/memgraph-coordinator-2:7687"
15+
9013: "default/memgraph-coordinator-3:7687"
16+
{{- end }}
17+
{{- end }}

0 commit comments

Comments
 (0)