diff --git a/charts/memgraph-high-availability/Chart.yaml b/charts/memgraph-high-availability/Chart.yaml index 180aca3..0782d1c 100644 --- a/charts/memgraph-high-availability/Chart.yaml +++ b/charts/memgraph-high-availability/Chart.yaml @@ -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 diff --git a/charts/memgraph-high-availability/README.md b/charts/memgraph-high-availability/README.md index c99d203..ed99eef 100644 --- a/charts/memgraph-high-availability/README.md +++ b/charts/memgraph-high-availability/README.md @@ -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` | diff --git a/charts/memgraph-high-availability/templates/NOTES.txt b/charts/memgraph-high-availability/templates/NOTES.txt index 9e2eb72..1b0b336 100644 --- a/charts/memgraph-high-availability/templates/NOTES.txt +++ b/charts/memgraph-high-availability/templates/NOTES.txt @@ -31,11 +31,14 @@ CommonLoadBalancer configuration example ADD COORDINATOR 2 WITH CONFIG {"bolt_server": ":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": ":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": ":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": ":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"}; diff --git a/charts/memgraph-high-availability/templates/ingress-nginx-namespace.yaml b/charts/memgraph-high-availability/templates/ingress-nginx-namespace.yaml new file mode 100644 index 0000000..43e4ecf --- /dev/null +++ b/charts/memgraph-high-availability/templates/ingress-nginx-namespace.yaml @@ -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 diff --git a/charts/memgraph-high-availability/templates/load-balancer.yaml b/charts/memgraph-high-availability/templates/load-balancer.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/charts/memgraph-high-availability/templates/services-coordinators-external.yaml b/charts/memgraph-high-availability/templates/services-coordinators-external.yaml new file mode 100644 index 0000000..1dcf2db --- /dev/null +++ b/charts/memgraph-high-availability/templates/services-coordinators-external.yaml @@ -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}} diff --git a/charts/memgraph-high-availability/templates/services-coordinators.yaml b/charts/memgraph-high-availability/templates/services-coordinators.yaml index d620103..227898b 100644 --- a/charts/memgraph-high-availability/templates/services-coordinators.yaml +++ b/charts/memgraph-high-availability/templates/services-coordinators.yaml @@ -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 @@ -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}} diff --git a/charts/memgraph-high-availability/templates/services-data-external.yaml b/charts/memgraph-high-availability/templates/services-data-external.yaml new file mode 100644 index 0000000..9098707 --- /dev/null +++ b/charts/memgraph-high-availability/templates/services-data-external.yaml @@ -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 }} diff --git a/charts/memgraph-high-availability/templates/services-data.yaml b/charts/memgraph-high-availability/templates/services-data.yaml index bb0bd7b..609f59c 100644 --- a/charts/memgraph-high-availability/templates/services-data.yaml +++ b/charts/memgraph-high-availability/templates/services-data.yaml @@ -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 @@ -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 }} diff --git a/charts/memgraph-high-availability/templates/tcp-services-configmap.yaml b/charts/memgraph-high-availability/templates/tcp-services-configmap.yaml new file mode 100644 index 0000000..36a3f2d --- /dev/null +++ b/charts/memgraph-high-availability/templates/tcp-services-configmap.yaml @@ -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 }}