diff --git a/geoserver/latest/CHANGELOG.md b/geoserver/latest/CHANGELOG.md index 97c6332..e15b767 100644 --- a/geoserver/latest/CHANGELOG.md +++ b/geoserver/latest/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 0.2.4 + +**Changes** + +Add a CronJob to prune old logs daily. + +**Commits** + +Francesco Camuffo (1): + gs: add CronJob to prune old logs + ## 0.2.3 **Changes** diff --git a/geoserver/latest/Chart.yaml b/geoserver/latest/Chart.yaml index eb5567b..fe6e4b1 100644 --- a/geoserver/latest/Chart.yaml +++ b/geoserver/latest/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.3 +version: 0.2.4 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/geoserver/latest/templates/cronjob-logs-pruning.yaml b/geoserver/latest/templates/cronjob-logs-pruning.yaml new file mode 100644 index 0000000..30b1a8d --- /dev/null +++ b/geoserver/latest/templates/cronjob-logs-pruning.yaml @@ -0,0 +1,77 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "geoserver.fullname" . }}-logs-pruning + labels: + {{- include "geoserver.labels" . | nindent 4 }} +spec: + schedule: '0 1 * * *' + jobTemplate: + metadata: + name: {{ include "geoserver.fullname" . }}-logs-pruning + spec: + template: + metadata: {} + spec: + restartPolicy: Never + + containers: + - name: prune + image: busybox:1.37 + imagePullPolicy: IfNotPresent + + command: + - /bin/sh + - -eux + - -c + - | + date + printf "Pruning log files...\n\n" + + if [ -d /var/geoserver/audits ]; then + find /var/geoserver/audits/ -name '*.log' -type f -mtime +14 -print -delete + fi + + if [ -d /usr/local/tomcat/logs ]; then + find /usr/local/tomcat/logs/ -name '*.catalina.*.log' -type f -mtime +14 -print -delete + find /usr/local/tomcat/logs/ -name '*.host-manager.*.log' -type f -mtime +14 -print -delete + find /usr/local/tomcat/logs/ -name '*.localhost.*.log' -type f -mtime +14 -print -delete + find /usr/local/tomcat/logs/ -name '*.localhost_access_log.*.txt' -type f -mtime +14 -print -delete + find /usr/local/tomcat/logs/ -name '*.manager.*.log' -type f -mtime +14 -print -delete + fi + + volumeMounts: + {{- if .Values.persistence.tomcatlogs }} + - name: gs-tomcatlogs + mountPath: /usr/local/tomcat/logs + {{- end }} + {{- if .Values.persistence.audits }} + - name: gs-audits + mountPath: /var/geoserver/audits + {{- end }} + + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} + + volumes: + {{- if .Values.persistence.tomcatlogs }} + - name: gs-tomcatlogs + persistentVolumeClaim: + claimName: {{ include "geoserver.fullname" . }}-tomcatlogs + {{- end }} + {{- if .Values.persistence.audits }} + - name: gs-audits + persistentVolumeClaim: + claimName: {{ include "geoserver.fullname" . }}-audits + {{- end }} +