Skip to content

Commit

Permalink
Add IngressNginx as revery proxy ingress solution (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
as51340 authored Dec 4, 2024
1 parent 36627d4 commit 3c77fe6
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 77 deletions.
2 changes: 1 addition & 1 deletion charts/memgraph-high-availability/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: memgraph-high-availability
description: A Helm chart for Kubernetes with Memgraph High availabiliy capabilites

version: 0.1.4
version: 0.1.5
appVersion: "2.22.0"

type: application
Expand Down
4 changes: 2 additions & 2 deletions charts/memgraph-high-availability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ 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.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` |
| `memgraph.externalAccess.dataInstance.serviceType` | NodePort or LoadBalancer. Use LoadBalancer for Cloud production deployment and NodePort for local testing. | `NodePort` |
| `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` |
| `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` |
| `memgraph.ports.boltPort` | Bolt port used on coordinator and data instances. | `7687` |
| `memgraph.ports.managementPort` | Management port used on coordinator and data instances. | `10000` |
| `memgraph.ports.replicationPort` | Replication port used on data instances. | `20000` |
Expand Down
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 3c77fe6

Please sign in to comment.