Skip to content

Commit

Permalink
Support where overlay config maps are mounted
Browse files Browse the repository at this point in the history
Since config map values can't have "/" in them, we need to
support multiple config maps (which we already do), and be
able to specify different paths the files are rooted at.

Copy the content into the top-level overlay volume so we
support files in more than just "etc".

Move the "uncompress" option into a key in the configmap
list, which feels much cleaner.

Co-authored-by: mershad-manesh <[email protected]>
  • Loading branch information
deejgregor and mershad-manesh committed Nov 1, 2023
1 parent 4b4f9e2 commit 47f6a60
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion horizon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ For information on requirements, installation, manual configuration, and trouble
| core.configuration.storage.mibs | string | `nil` | |
| core.configuration.storage.rrd | string | `"1000Gi"` | |
| core.configuration.tolerations | string | `nil` | |
| core.etcOverlayConfigMaps | list | `[]` | |
| core.image.pullPolicy | string | `"IfNotPresent"` | |
| core.image.repository | string | `"opennms/horizon"` | |
| core.image.tag | string | `""` | |
| core.inspector.enabled | bool | `false` | |
| core.overlayConfigMaps | list | `[]` | |
| core.postConfigJob.ttlSecondsAfterFinished | int | `300` | |
| core.resources.limits.cpu | string | `"2"` | |
| core.resources.limits.memory | string | `"8Gi"` | |
Expand Down
18 changes: 9 additions & 9 deletions horizon/scripts/onms-core-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ DEPLOY_DIR="/opennms-deploy" # Mounted Externally

CONFIG_DIR_OVERLAY=${OVERLAY_DIR}/etc

ETC_CONFIG_MAPS="/opennms-etc-overlay-configmaps" # Mounted externally
OVERLAY_CONFIG_MAPS="/opennms-overlay-configmaps" # Mounted externally

KARAF_FILES=( \
"config.properties" \
Expand Down Expand Up @@ -604,22 +604,22 @@ else
exit 1
fi

if [ -d ${ETC_CONFIG_MAPS} ]; then
echo "Processing etc overlay config maps because /opennms-etc-overlay-configmaps exists ..."
if [ -d ${OVERLAY_CONFIG_MAPS} ]; then
echo "Processing overlay config maps ..."
# We need to make sure the directories are numerically sorted to match the configured configmap order.
for dir in $(ls -1d ${ETC_CONFIG_MAPS}/* | sort -n); do
for dir in $(ls -1d ${OVERLAY_CONFIG_MAPS}/* | sort -n); do
# When we first copy off of the configmap volume, we copy symlinks as files and ignore Kubernetes configmap volume ".." files.
# See: https://github.com/spring-projects/spring-boot/issues/23232
if [ -f $dir/.uncompress ]; then
echo " Copying etc files from $dir to ${CONFIG_DIR}/ (and uncompressing .gz files) ..."
if [[ $(basename $dir) =~ .*-uncompress ]]; then
echo " Copying files from $dir to ${OVERLAY_DIR}/ (and uncompressing .gz files) ..."
mkdir /tmp/uncompress
rsync -arO -L --exclude='..*' --no-perms --no-owner --no-group $dir/ /tmp/uncompress # don't bother outputting files copied yet
find /tmp/uncompress -name '*.gz' | xargs gzip -d -v 2>&1 | sed 's/^/ /'
rsync -arO --exclude=.uncompress --no-perms --no-owner --no-group --out-format="%n %C" /tmp/uncompress/ ${CONFIG_DIR}/ | sed 's/^/ /'
rsync -arO --no-perms --no-owner --no-group --out-format="%n %C" /tmp/uncompress/ ${OVERLAY_DIR}/ | sed 's/^/ /'
rm -rf /tmp/uncompress
else
echo " Copying etc files from $dir to ${CONFIG_DIR}/ ..."
rsync -arO -L --exclude='..*' --no-perms --no-owner --no-group --out-format="%n %C" $dir/ ${CONFIG_DIR}/ | sed 's/^/ /'
echo " Copying files from $dir to ${OVERLAY_DIR}/ ..."
rsync -arO -L --exclude='..*' --no-perms --no-owner --no-group --out-format="%n %C" $dir/ ${OVERLAY_DIR}/ | sed 's/^/ /'
fi
done
fi
12 changes: 6 additions & 6 deletions horizon/templates/opennms-core.statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ spec:
mountPath: /opt/opennms-overlay # Required by the script - OVERLAY_DIR
- name: scripts
mountPath: /scripts # Required by the script
{{- range $i, $configMap := .Values.core.etcOverlayConfigMaps }}
- name: etc-overlay-configmap-{{ $i }}
mountPath: /opennms-etc-overlay-configmaps/{{ $i }}
{{- range $k, $r := .Values.core.overlayConfigMaps }}
- name: overlay-configmap-{{ $k }}
mountPath: /opennms-overlay-configmaps/{{ $k }}{{- if $r.uncompress }}-uncompress{{ end }}/{{ $r.path | default "etc" }}
{{- end }}
nodeSelector:
{{- toYaml .Values.core.configuration.nodeSelector | nindent 8 }}
Expand Down Expand Up @@ -292,8 +292,8 @@ spec:
claimName: onms-mibs-pvc
readOnly: false
{{- end }}
{{- range $i, $configMap := .Values.core.etcOverlayConfigMaps }}
- name: etc-overlay-configmap-{{ $i }}
{{- range $k, $r := .Values.core.overlayConfigMaps }}
- name: overlay-configmap-{{ $k }}
configMap:
name: {{ $configMap | quote }}
name: {{ $r.name | quote }}
{{- end }}
2 changes: 1 addition & 1 deletion horizon/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ingress:
core:
inspector:
enabled: false
etcOverlayConfigMaps: []
overlayConfigMaps: []
terminationGracePeriodSeconds: 120
image:
repository: opennms/horizon
Expand Down

0 comments on commit 47f6a60

Please sign in to comment.