Skip to content

Commit

Permalink
feat: introduce gs monitor extension init script
Browse files Browse the repository at this point in the history
  • Loading branch information
buehner committed Aug 15, 2024
1 parent 3097ba7 commit 347e3f4
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/geoserver/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: geoserver
description: Helm chart for GeoServer
icon: https://geoserver.org/img/uploads/geoserver_icon.png
version: 4.1.0
version: 4.2.0
appVersion: 2.25.2
5 changes: 4 additions & 1 deletion charts/geoserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ The following parameters can be configured in (a custom) `values.yaml`:
* `persistence.existingPvcName`: The name of an existing pvc (persistent volume claim) that should be used to store geoserver data
* `geofence.enableInitScript`: A flag to control whether a init script for geofence should run or not. default: `false`.
* `geofence.dataSourceUrl`: This will only be used if `geofence.enableInitScript` is `true`. Have a look at the `values.yaml` for an example value.
* `geofence.env`: This will only be used if `geofence.enableInitScript` is `true`. Have a look at the `values.yaml` for an example value.
* `geofence.env`: This will only be used if `geofence.enableInitScript` is `true`. Have a look at the `values.yaml` for an example value.
* `monitoring.enableInitScript`: A flag to control whether a init script for the gs monitoring extension should run or not. default: `false`.
* `monitoring.filterProperties`: The file content of the [filter.properties](https://docs.geoserver.org/stable/en/user/extensions/monitoring/configuration.html) used by the monitoring extension. This will only be used if `monitoring.enableInitScript` is `true`. default: see `values.yaml`
* `monitoring.monitorProperties`: The file content of the [monitor.properties](https://docs.geoserver.org/stable/en/user/extensions/monitoring/configuration.html) used by the monitoring extension. This will only be used if `monitoring.enableInitScript` is `true`. default: see `values.yaml`
14 changes: 11 additions & 3 deletions charts/geoserver/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ data:
{{- if .Values.geofence.enableInitScript }}
init-geofence.sh: |-
#!/bin/sh
echo "Initialising geofence config in /opt/geoserver_data/geofence/geofence-datasource-ovr.properties"
mkdir -p /opt/geoserver_data/geofence
cat > /opt/geoserver_data/geofence/geofence-datasource-ovr.properties << EOL
echo "Initializing geofence config in {{ .Values.storage.dataDir }}/geofence/geofence-datasource-ovr.properties"
mkdir -p {{ .Values.storage.dataDir }}/geofence
cat > {{ .Values.storage.dataDir }}/geofence/geofence-datasource-ovr.properties << EOL
geofenceVendorAdapter.databasePlatform=org.hibernatespatial.postgis.PostgisDialect
geofenceDataSource.driverClassName=org.postgresql.Driver
geofenceDataSource.url={{ .Values.geofence.dataSourceUrl }}
Expand All @@ -79,5 +79,13 @@ data:
geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=update
EOL
{{- end}}
{{- if .Values.monitoring.enableInitScript }}
init-monitoring.sh: |-
#!/bin/sh
echo "Initializing monitoring config by copying properties files to {{ .Values.storage.dataDir }}/monitoring"
mkdir -p {{ .Values.storage.dataDir }}/monitoring && cp /mnt/{filter,monitor}.properties {{ .Values.storage.dataDir }}/monitoring/
filter.properties: {{ .Values.monitoring.filterProperties | toYaml | indent 2 }}
monitor.properties: {{ .Values.monitoring.monitorProperties | toYaml | indent 2 }}
{{- end}}

{{- end}}
29 changes: 26 additions & 3 deletions charts/geoserver/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,34 @@ spec:
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.geofence.enableInitScript }}
{{- if not .Values.initContainers }}
{{- if and (not .Values.initContainers) (or (.Values.geofence.enableInitScript) (.Values.monitoring.enableInitScript)) }}
# only add this if we do not have initContainers, but at least one extension init script
initContainers:
{{- end }}
{{- if .Values.geofence.enableInitScript }}
- name: init-geofence
image: docker.terrestris.de/alpine
command: [ "/bin/sh","/mnt/init-geofence.sh" ]
volumeMounts:
- name: init-geofence-volume
mountPath: /mnt/
- name: datadir
mountPath: /opt/geoserver_data
mountPath: {{ .Values.storage.dataDir }}
env:
{{- with .Values.geofence.env }}
{{- tpl . $ | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.monitoring.enableInitScript }}
- name: init-monitoring
image: docker.terrestris.de/alpine
command: [ "/bin/sh","/mnt/init-monitoring.sh" ]
volumeMounts:
- name: init-monitoring-volume
mountPath: /mnt/
- name: datadir
mountPath: {{ .Values.storage.dataDir }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down Expand Up @@ -131,3 +142,15 @@ spec:
- key: init-geofence.sh
path: init-geofence.sh
{{- end }}
{{- if .Values.monitoring.enableInitScript }}
- name: init-monitoring-volume
configMap:
name: geoserver-init-configmap
items:
- key: init-monitoring.sh
path: init-monitoring.sh
- key: filter.properties
path: filter.properties
- key: monitor.properties
path: monitor.properties
{{- end }}
15 changes: 15 additions & 0 deletions charts/geoserver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ geofence:
name: shogun-postgis-shogun-credentials
key: shogun-password
monitoring:
enableInitScript: false
filterProperties: |-
/rest/monitor/**
/web
/web/**
/pdf/**
monitorProperties: |-
storage=memory
mode=history
sync=async
maxBodySize=1024
bboxLogCrs=EPSG:4326
bboxLogLevel=no_wfs
# extraEnv: |
# - name: QUERY_LAYER_MAX_FEATURES
# value: 100000
Expand Down

0 comments on commit 347e3f4

Please sign in to comment.