From 495ec7186521c6faaae5b940b49df95caceb0adf Mon Sep 17 00:00:00 2001 From: Philipp Born Date: Sat, 9 Dec 2023 11:03:41 +0100 Subject: [PATCH] bump appVersion, allow multiple replicas (+HPA) for Deployment, allow setting externalService annotations, allow disabling allocateLoadBalancerNodePorts --- charts/traccar/Chart.yaml | 4 +-- charts/traccar/templates/deployment.yaml | 8 ++++-- charts/traccar/templates/hpa.yaml | 32 ++++++++++++++++++++++++ charts/traccar/templates/service.yaml | 7 ++++++ charts/traccar/values.yaml | 26 +++++++++++++++++++ 5 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 charts/traccar/templates/hpa.yaml diff --git a/charts/traccar/Chart.yaml b/charts/traccar/Chart.yaml index 179628a..a319688 100644 --- a/charts/traccar/Chart.yaml +++ b/charts/traccar/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: traccar description: A Helm chart for Traccar GPS Server type: application -version: 1.6.0 -appVersion: "5.6" +version: 1.7.0 +appVersion: "5.10" dependencies: - name: mysql version: 9.4.8 diff --git a/charts/traccar/templates/deployment.yaml b/charts/traccar/templates/deployment.yaml index fd80a4e..c8e903e 100644 --- a/charts/traccar/templates/deployment.yaml +++ b/charts/traccar/templates/deployment.yaml @@ -5,12 +5,16 @@ metadata: labels: {{- include "traccar.labels" . | nindent 4 }} spec: - replicas: 1 + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} selector: matchLabels: {{- include "traccar.selectorLabels" . | nindent 6 }} + {{- with .Values.deploymentStrategy }} strategy: - type: Recreate + {{- toYaml . | nindent 4 }} + {{- end }} template: metadata: annotations: diff --git a/charts/traccar/templates/hpa.yaml b/charts/traccar/templates/hpa.yaml new file mode 100644 index 0000000..a0fa418 --- /dev/null +++ b/charts/traccar/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "traccar.fullname" . }} + labels: + {{- include "traccar.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "traccar.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/traccar/templates/service.yaml b/charts/traccar/templates/service.yaml index fb6b142..1f1f25b 100644 --- a/charts/traccar/templates/service.yaml +++ b/charts/traccar/templates/service.yaml @@ -25,6 +25,10 @@ metadata: name: {{ $externalfullname }} labels: {{- include "traccar.labels" . | nindent 4 }} + {{- with .Values.externalService.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: type: {{ .Values.externalService.type }} {{- if .Values.externalService.loadBalancerIP }} @@ -32,6 +36,9 @@ spec: {{- end }} {{- if .Values.externalService.loadBalancerSourceRanges }} loadBalancerSourceRanges: {{ toYaml .Values.externalService.loadBalancerSourceRanges | nindent 4 }} +{{- end }} +{{- if hasKey .Values.externalService "allocateLoadBalancerNodePorts" }} + allocateLoadBalancerNodePorts: {{ .Values.externalService.allocateLoadBalancerNodePorts }} {{- end }} ports: {{- toYaml .Values.externalService.protocolPorts | nindent 4 }} diff --git a/charts/traccar/values.yaml b/charts/traccar/values.yaml index 363e4b2..9b5c5fe 100644 --- a/charts/traccar/values.yaml +++ b/charts/traccar/values.yaml @@ -115,6 +115,18 @@ mysql: persistence: enabled: false +# NOTE: When using multiple replicas, you must configure broadcast.type and broadcast.address +# This must be done via configOverride. See https://www.traccar.org/configuration-file/#:~:text=attributes%20to%20log.-,broadcast.type,-config +replicaCount: 1 + +deploymentStrategy: + # Recreate has been the default until chart version 1.6.0 and is required if running a non-HA compatible setup + type: Recreate + # rollingUpdate: + # maxSurge: 25% + # maxUnavailable: 25% + # type: RollingUpdate + image: repository: traccar/traccar pullPolicy: IfNotPresent @@ -193,8 +205,15 @@ service: externalService: type: LoadBalancer enabled: false + annotations: {} + # metallb.universe.tf/loadBalancerIPs: 192.168.1.100 # loadBalancerIP: "" # loadBalancerSourceRanges: [] + + # -- Enable node port allocation for the external controller service or not. Applies to type `LoadBalancer` only. + # Ref: https://kubernetes.io/docs/concepts/services-networking/service/#load-balancer-nodeport-allocation + # allocateLoadBalancerNodePorts: true + protocolPorts: - name: gps103 port: 5001 @@ -876,6 +895,13 @@ externalService: resources: {} +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + nodeSelector: tolerations: []