From 12041072c19a635334b19b57cd1ffd8b8d51c67c Mon Sep 17 00:00:00 2001 From: Harshit Singhvi Date: Mon, 20 May 2024 13:46:33 +0100 Subject: [PATCH 1/5] changes to use ClusterIP internals service instead of headless service --- internal/unit_tests/helm_template_cluster_core_test.go | 1 + .../unit_tests/helm_template_cluster_read_replica_test.go | 2 +- neo4j-cluster-core/values.yaml | 4 +++- neo4j-cluster-read-replica/values.yaml | 4 +++- neo4j-standalone/templates/neo4j-svc.yaml | 4 ++-- neo4j-standalone/values.yaml | 4 +++- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/unit_tests/helm_template_cluster_core_test.go b/internal/unit_tests/helm_template_cluster_core_test.go index b08449e4..e0d68ce7 100644 --- a/internal/unit_tests/helm_template_cluster_core_test.go +++ b/internal/unit_tests/helm_template_cluster_core_test.go @@ -70,6 +70,7 @@ func TestClusterCoreInternalPorts(t *testing.T) { } internalService := readReplicaManifest.OfTypeWithName(&v1.Service{}, core.InternalServiceName()).(*v1.Service) + assert.Equal(t, internalService.Spec.Type, v1.ServiceTypeClusterIP) checkPortsMatchExpected(t, expectedPorts, internalService) } diff --git a/internal/unit_tests/helm_template_cluster_read_replica_test.go b/internal/unit_tests/helm_template_cluster_read_replica_test.go index 2abbbb3e..f2b72810 100644 --- a/internal/unit_tests/helm_template_cluster_read_replica_test.go +++ b/internal/unit_tests/helm_template_cluster_read_replica_test.go @@ -64,7 +64,7 @@ func TestReadReplicaInternalPorts(t *testing.T) { } internalService := readReplicaManifest.OfTypeWithName(&v1.Service{}, readReplica.InternalServiceName()).(*v1.Service) - + assert.Equal(t, internalService.Spec.Type, v1.ServiceTypeClusterIP) checkPortsMatchExpected(t, expectedPorts, internalService) } diff --git a/neo4j-cluster-core/values.yaml b/neo4j-cluster-core/values.yaml index 7e21e7e4..cf9b53c7 100644 --- a/neo4j-cluster-core/values.yaml +++ b/neo4j-cluster-core/values.yaml @@ -250,12 +250,14 @@ services: type: ClusterIP # n.b. there is no ports object for this service. Ports are autogenerated based on the neo4j configuration - # A "headless" service for admin/ops and Neo4j cluster-internal communications + # A service for admin/ops and Neo4j cluster-internal communications # This service is available even if the deployment is not "ready" internals: enabled: false # Annotations for the internals service annotations: { } + spec: + type: ClusterIP # n.b. there is no ports object for this service. Ports are autogenerated based on the neo4j configuration # Neo4j Configuration (yaml format) diff --git a/neo4j-cluster-read-replica/values.yaml b/neo4j-cluster-read-replica/values.yaml index 0abf0916..b810fbd6 100644 --- a/neo4j-cluster-read-replica/values.yaml +++ b/neo4j-cluster-read-replica/values.yaml @@ -247,12 +247,14 @@ services: type: ClusterIP # n.b. there is no ports object for this service. Ports are autogenerated based on the neo4j configuration - # A "headless" service for admin/ops and Neo4j cluster-internal communications + # A service for admin/ops and Neo4j cluster-internal communications # This service is available even if the deployment is not "ready" internals: enabled: false # Annotations for the internals service annotations: { } + spec: + type: ClusterIP # n.b. there is no ports object for this service. Ports are autogenerated based on the neo4j configuration # Neo4j Configuration (yaml format) diff --git a/neo4j-standalone/templates/neo4j-svc.yaml b/neo4j-standalone/templates/neo4j-svc.yaml index c8d72c87..04c22e45 100644 --- a/neo4j-standalone/templates/neo4j-svc.yaml +++ b/neo4j-standalone/templates/neo4j-svc.yaml @@ -142,8 +142,8 @@ metadata: {{- end }} spec: publishNotReadyAddresses: true - clusterIP: None - {{- with .spec }}{{ include "neo4j.services.extraSpec" . | nindent 2 }}{{ end }} + type: "{{ .spec.type | required "The 'type' field is required in service.internals.spec" }}" + {{- with omit .spec "type" }}{{ include "neo4j.services.extraSpec" . | nindent 2 }}{{ end }} selector: app: "{{ template "neo4j.appName" $ }}" helm.neo4j.com/instance: "{{ include "neo4j.fullname" $ }}" diff --git a/neo4j-standalone/values.yaml b/neo4j-standalone/values.yaml index 10d7373a..83904f4b 100644 --- a/neo4j-standalone/values.yaml +++ b/neo4j-standalone/values.yaml @@ -249,12 +249,14 @@ services: type: ClusterIP # n.b. there is no ports object for this service. Ports are autogenerated based on the neo4j configuration - # A "headless" service for admin/ops and Neo4j cluster-internal communications + # A service for admin/ops and Neo4j cluster-internal communications # This service is available even if the deployment is not "ready" internals: enabled: false # Annotations for the internals service annotations: { } + spec: + type: ClusterIP # n.b. there is no ports object for this service. Ports are autogenerated based on the neo4j configuration From d08a3a5ba6b259af96a4882e114521772c74f691 Mon Sep 17 00:00:00 2001 From: Harshit Singhvi Date: Mon, 20 May 2024 14:03:59 +0100 Subject: [PATCH 2/5] changes to workflow --- .github/workflows/tests.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3a85546d..07279eb1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -167,7 +167,9 @@ jobs: export KUBECONFIG="${CURRENT_DIRECTORY}/.kube/config" echo "printing kubeconfig path $KUBECONFIG" export IPS_PASS=$(gcloud auth print-access-token) - if [[ ${{ inputs.RELEASE }} ]]; then + #inputs.RELEASE does not hold value when workflow_dispatch is not called + ISRELEASE=${{ inputs.RELEASE }} + if [[ ${#ISRELEASE} != 0 ]]; then export NEO4J_DOCKER_IMG="neo4j:${{ inputs.NEO4J_VERSION }}-enterprise" fi echo "NEO4J_DOCKER_IMG=${NEO4J_DOCKER_IMG}" @@ -223,7 +225,9 @@ jobs: export KUBECONFIG="${CURRENT_DIRECTORY}/.kube/config" echo "printing kubeconfig path $KUBECONFIG" export IPS_PASS=$(gcloud auth print-access-token) - if [[ ${{ inputs.RELEASE }} ]]; then + #inputs.RELEASE does not hold value when workflow_dispatch is not called + ISRELEASE=${{ inputs.RELEASE }} + if [[ ${#ISRELEASE} != 0 ]]; then export NEO4J_DOCKER_IMG="neo4j:${{ inputs.NEO4J_VERSION }}" fi echo "NEO4J_DOCKER_IMG=${NEO4J_DOCKER_IMG}" From ab77cb0cdfba445acdda8cf11d17b46ed2065246 Mon Sep 17 00:00:00 2001 From: Harshit Singhvi Date: Wed, 29 May 2024 08:25:03 +0100 Subject: [PATCH 3/5] adding temporary headless service fix for read replica --- neo4j-standalone/templates/neo4j-svc.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neo4j-standalone/templates/neo4j-svc.yaml b/neo4j-standalone/templates/neo4j-svc.yaml index 04c22e45..be29fa83 100644 --- a/neo4j-standalone/templates/neo4j-svc.yaml +++ b/neo4j-standalone/templates/neo4j-svc.yaml @@ -142,7 +142,11 @@ metadata: {{- end }} spec: publishNotReadyAddresses: true + {{- if $replicaEnabled }} + clusterIP: None + {{- else }} type: "{{ .spec.type | required "The 'type' field is required in service.internals.spec" }}" + {{- end }} {{- with omit .spec "type" }}{{ include "neo4j.services.extraSpec" . | nindent 2 }}{{ end }} selector: app: "{{ template "neo4j.appName" $ }}" From 68efca55103f40a6c1de0773465f23d52b4f9359 Mon Sep 17 00:00:00 2001 From: Harshit Singhvi Date: Tue, 11 Jun 2024 11:23:36 +0100 Subject: [PATCH 4/5] adding changes for clusterip for read replica --- neo4j-standalone/templates/neo4j-svc.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neo4j-standalone/templates/neo4j-svc.yaml b/neo4j-standalone/templates/neo4j-svc.yaml index be29fa83..4ce61456 100644 --- a/neo4j-standalone/templates/neo4j-svc.yaml +++ b/neo4j-standalone/templates/neo4j-svc.yaml @@ -142,11 +142,11 @@ metadata: {{- end }} spec: publishNotReadyAddresses: true - {{- if $replicaEnabled }} - clusterIP: None - {{- else }} +{{/* {{- if $replicaEnabled }}*/}} +{{/* clusterIP: None*/}} +{{/* {{- else }}*/}} type: "{{ .spec.type | required "The 'type' field is required in service.internals.spec" }}" - {{- end }} +{{/* {{- end }}*/}} {{- with omit .spec "type" }}{{ include "neo4j.services.extraSpec" . | nindent 2 }}{{ end }} selector: app: "{{ template "neo4j.appName" $ }}" From 5e0b4e47676ceab51d7b0d8689a0e85e599380b5 Mon Sep 17 00:00:00 2001 From: Harshit Singhvi Date: Tue, 2 Jul 2024 13:41:12 +0100 Subject: [PATCH 5/5] changes to use clusterip service for read replicas --- internal/model/helm_model.go | 4 ++-- .../helm_template_cluster_read_replica_test.go | 2 ++ neo4j-standalone/templates/neo4j-svc.yaml | 17 +---------------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/internal/model/helm_model.go b/internal/model/helm_model.go index 58096c27..8796accb 100644 --- a/internal/model/helm_model.go +++ b/internal/model/helm_model.go @@ -175,10 +175,10 @@ var DefaultNeo4jBackupValues = Neo4jBackupValues{ }, Resources: Neo4jBackupResources{ Requests: Neo4jBackupRequests{ - EphemeralStorage: "4Gi", + EphemeralStorage: "1Gi", }, Limits: Neo4jBackupLimits{ - EphemeralStorage: "4Gi", + EphemeralStorage: "2Gi", }, }, SecurityContext: SecurityContext{ diff --git a/internal/unit_tests/helm_template_cluster_read_replica_test.go b/internal/unit_tests/helm_template_cluster_read_replica_test.go index f2b72810..d9ee2180 100644 --- a/internal/unit_tests/helm_template_cluster_read_replica_test.go +++ b/internal/unit_tests/helm_template_cluster_read_replica_test.go @@ -54,6 +54,8 @@ func TestReadReplicaInternalPorts(t *testing.T) { 7474: 7474, 7688: 7688, 6000: 6000, + 5000: 5000, + 7000: 7000, } readReplica := model.NewReleaseName("foo") diff --git a/neo4j-standalone/templates/neo4j-svc.yaml b/neo4j-standalone/templates/neo4j-svc.yaml index 4ce61456..5810d16f 100644 --- a/neo4j-standalone/templates/neo4j-svc.yaml +++ b/neo4j-standalone/templates/neo4j-svc.yaml @@ -142,11 +142,7 @@ metadata: {{- end }} spec: publishNotReadyAddresses: true -{{/* {{- if $replicaEnabled }}*/}} -{{/* clusterIP: None*/}} -{{/* {{- else }}*/}} type: "{{ .spec.type | required "The 'type' field is required in service.internals.spec" }}" -{{/* {{- end }}*/}} {{- with omit .spec "type" }}{{ include "neo4j.services.extraSpec" . | nindent 2 }}{{ end }} selector: app: "{{ template "neo4j.appName" $ }}" @@ -174,18 +170,7 @@ spec: targetPort: 7473 name: tcp-https {{- end }} - {{- if $replicaEnabled }} - #enable the ports 7688 , 6000 only for Read Replicas - - protocol: TCP - port: 7688 - targetPort: 7688 - name: tcp-boltrouting - - protocol: TCP - port: 6000 - targetPort: 6000 - name: tcp-tx - {{- end }} - {{- if and (not $replicaEnabled ) $clusterEnabled }} + {{- if $clusterEnabled }} #enable the ports for non Read Replicas - protocol: TCP port: 7688