From a92a59f8313af1bca8e18e942d206cc2c239e1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Vosla=C5=99?= Date: Mon, 19 Aug 2019 11:15:29 +0200 Subject: [PATCH] [stable/neo4j] Added resources to replica deployment and HPA. (#16306) * Added resources to replica deployment and HPA. Signed-off-by: Tomas Voslar * HPA not mandatory. Signed-off-by: Tomas Voslar * Bump version. Signed-off-by: Tomas Voslar * Add docs. Signed-off-by: Tomas Voslar * Added standard labels. Signed-off-by: Tomas Voslar * Add nodeSelector, tolerations and affinity. Signed-off-by: Tomas Voslar * Fix. Signed-off-by: Tomas Voslar --- stable/neo4j/Chart.yaml | 2 +- stable/neo4j/README.md | 4 +++ stable/neo4j/templates/core-statefulset.yaml | 12 +++++++++ .../templates/readreplicas-deployment.yaml | 14 +++++++++++ stable/neo4j/templates/readreplicas-hpa.yaml | 21 ++++++++++++++++ stable/neo4j/values.yaml | 25 +++++++++++++++++++ 6 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 stable/neo4j/templates/readreplicas-hpa.yaml diff --git a/stable/neo4j/Chart.yaml b/stable/neo4j/Chart.yaml index 8db1edb185..fc21caabe4 100644 --- a/stable/neo4j/Chart.yaml +++ b/stable/neo4j/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: neo4j home: https://www.neo4j.com -version: 1.1.0 +version: 1.2.0 appVersion: 3.4.5 description: Neo4j is the world's leading graph database icon: http://info.neo4j.com/rs/773-GON-065/images/neo4j_logo.png diff --git a/stable/neo4j/README.md b/stable/neo4j/README.md index 8d4bbb706e..aaea1cea51 100644 --- a/stable/neo4j/README.md +++ b/stable/neo4j/README.md @@ -73,6 +73,10 @@ their default values. | `core.persistentVolume.subPath` | Subdirectory of the volume to mount | `nil` | | `core.persistentVolume.annotations` | Persistent Volume Claim annotations | `{}` | | `readReplica.numberOfServers` | Number of machines in READ_REPLICA mode | `0` | +| `readReplica.autoscaling.enabled` | Enable horizontal pod autoscaler | `false` | +| `readReplica.autoscaling.targetAverageUtilization` | Target CPU utilization | `70` | +| `readReplica.autoscaling.minReplicas` | Min replicas for autoscaling | `1` | +| `readReplica.autoscaling.maxReplicas` | Max replicas for autoscaling | `3` | | `readReplica.initContainers` | Init containers to add to the replica pod. Example use case is a script that installs the APOC library | `{}` | | `resources` | Resources required (e.g. CPU, memory) | `{}` | | `clusterDomain` | Cluster domain | `cluster.local` | diff --git a/stable/neo4j/templates/core-statefulset.yaml b/stable/neo4j/templates/core-statefulset.yaml index dae3d70e8b..3430204613 100644 --- a/stable/neo4j/templates/core-statefulset.yaml +++ b/stable/neo4j/templates/core-statefulset.yaml @@ -101,6 +101,18 @@ spec: {{- end }} - name: plugins emptyDir: {} +{{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 6 }} +{{- end }} +{{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 6 }} +{{- end }} +{{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 6 }} +{{- end }} {{- if .Values.core.persistentVolume.enabled }} volumeClaimTemplates: - metadata: diff --git a/stable/neo4j/templates/readreplicas-deployment.yaml b/stable/neo4j/templates/readreplicas-deployment.yaml index b97c4c137e..93886aacd7 100644 --- a/stable/neo4j/templates/readreplicas-deployment.yaml +++ b/stable/neo4j/templates/readreplicas-deployment.yaml @@ -66,12 +66,26 @@ spec: volumeMounts: - name: plugins mountPath: /plugins + resources: +{{ toYaml .Values.readReplica.resources | indent 10 }} {{- if .Values.core.sidecarContainers }} {{ toYaml .Values.core.sidecarContainers | indent 6 }} {{- end }} {{- if .Values.readReplica.initContainers }} initContainers: {{ toYaml .Values.readReplica.initContainers | indent 6 }} +{{- end }} +{{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 6 }} +{{- end }} +{{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 6 }} +{{- end }} +{{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 6 }} {{- end }} volumes: - name: plugins diff --git a/stable/neo4j/templates/readreplicas-hpa.yaml b/stable/neo4j/templates/readreplicas-hpa.yaml new file mode 100644 index 0000000000..6a3d023d6a --- /dev/null +++ b/stable/neo4j/templates/readreplicas-hpa.yaml @@ -0,0 +1,21 @@ +{{- if .Values.readReplica.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "neo4j.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "neo4j.name" . }} + minReplicas: {{ .Values.readReplica.autoscaling.minReplicas }} + maxReplicas: {{ .Values.readReplica.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.readReplica.autoscaling.targetAverageUtilization }} +{{- end }} diff --git a/stable/neo4j/values.yaml b/stable/neo4j/values.yaml index 88bf955b81..be451552d7 100644 --- a/stable/neo4j/values.yaml +++ b/stable/neo4j/values.yaml @@ -15,6 +15,18 @@ podDisruptionBudget: {} # minAvailable: 2 # maxUnavailable: 1 +## Node labels for pod assignment +## ref: https://kubernetes.io/docs/user-guide/node-selection/ +nodeSelector: {} + +## Tolerations for pod assignment +## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +tolerations: [] + +## Affinity for pod assignment +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +affinity: {} + # Use password authentication authEnabled: true @@ -89,6 +101,19 @@ core: # Read Replicas readReplica: + resources: {} + # limits: + # cpu: 100m + # memory: 512Mi + # requests: + # cpu: 100m + # memory: 512Mi + autoscaling: + enabled: false + targetAverageUtilization: 70 + minReplicas: 1 + maxReplicas: 3 + numberOfServers: 0 ## Pass extra environment variables to the Neo4j container. ##