Skip to content

Commit

Permalink
bump appVersion, allow multiple replicas (+HPA) for Deployment, allow…
Browse files Browse the repository at this point in the history
… setting externalService annotations, allow disabling allocateLoadBalancerNodePorts
  • Loading branch information
tamcore committed Dec 9, 2023
1 parent f18572c commit 15af2f4
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 8 deletions.
7 changes: 5 additions & 2 deletions charts/traccar/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ dependencies:
- name: mysql
repository: https://charts.bitnami.com/bitnami
version: 9.4.8
digest: sha256:c54ca45ec9055b33d96c582be62d5c4afd9501f2edfee0afaa73876b7ae13cfa
generated: "2023-01-28T11:57:35.495179799+01:00"
- name: redis-ha
repository: https://dandydeveloper.github.io/charts
version: 4.23.0
digest: sha256:91b7dd321c826a5721204763f11ac8a641c60cc23690250ca2eecd8c368cdac8
generated: "2023-12-09T13:20:23.900368+01:00"
8 changes: 6 additions & 2 deletions charts/traccar/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ 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
repository: https://charts.bitnami.com/bitnami
condition: mysql.enabled
- name: redis-ha
version: 4.23.0
repository: https://dandydeveloper.github.io/charts
condition: redis-ha.enabled
maintainers:
- email: laszlo.kondas@gmail.com
name: kondas
14 changes: 14 additions & 0 deletions charts/traccar/ci/ha-with-redis-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
replicaCount: 2

deploymentStrategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate

redis-ha:
enabled: true
# defaults to 3. but we wan't CI to run through in a reasonable time.
replicas: 1
haproxy:
replicas: 1
4 changes: 4 additions & 0 deletions charts/traccar/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ data:
<entry key='notificator.telegram.sendLocation'>{{ .Values.traccar.notificator.telegram.sendLocation }}</entry>
{{- end }}
{{- end }}
{{- end }}
{{- if (index .Values "redis-ha").enabled }}
<entry key='broadcast.type'>redis</entry>
<entry key='broadcast.address'>redis://{{ include "traccar.fullname" . }}-redis-ha-haproxy:6379</entry>
{{- end }}
</properties>
{{- end }}
25 changes: 21 additions & 4 deletions charts/traccar/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -32,13 +36,13 @@ spec:
- name: config
configMap:
name: {{ include "traccar.fullname" . }}
{{- if or .Values.mysql.enabled .Values.initContainers }}
{{- if or .Values.mysql.enabled (index .Values "redis-ha").enabled .Values.initContainers }}
initContainers:
{{- if .Values.mysql.enabled }}
- name: wait-for-db
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "alpine:3.6"
image: "alpine:3.19"
command:
- 'sh'
- '-c'
Expand All @@ -47,6 +51,19 @@ spec:
do sleep 2;
done
{{- end }}
{{- if (index .Values "redis-ha").enabled }}
- name: wait-for-redis
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "alpine:3.19"
command:
- 'sh'
- '-c'
- >
until nc -z -w 2 {{ include "traccar.fullname" . }}-redis-ha-haproxy 6379 && echo redis ok;
do sleep 2;
done
{{- end }}
{{- with .Values.initContainers }}
{{- if eq (typeOf .) "string" }}
{{- tpl . $ | nindent 8 }}
Expand Down
32 changes: 32 additions & 0 deletions charts/traccar/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
7 changes: 7 additions & 0 deletions charts/traccar/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ 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 }}
loadBalancerIP: {{ .Values.externalService.loadBalancerIP }}
{{- 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 }}
Expand Down
39 changes: 39 additions & 0 deletions charts/traccar/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ mysql:
persistence:
enabled: false

# NOTE: When using multiple replicas, you must configure broadcast.type and broadcast.address
# This can be done via configOverride. See https://www.traccar.org/configuration-file/#:~:text=attributes%20to%20log.-,broadcast.type,-config
# Or by setting redis.enabled=true
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
Expand Down Expand Up @@ -193,8 +206,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
Expand Down Expand Up @@ -876,8 +896,27 @@ externalService:

resources: {}

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

nodeSelector:

tolerations: []

affinity: {}

redis-ha:
# enables the redis subchart
enabled: false
persistentVolume:
enabled: false
redis:
masterGroupName: traccar
config:
save: '""'
haproxy:
enabled: true
1 change: 1 addition & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ chart-dirs:
- charts
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
- dandydeveloper=https://dandydeveloper.github.io/charts
helm-extra-args: --timeout 600s

0 comments on commit 15af2f4

Please sign in to comment.