Skip to content

Commit

Permalink
allow to change the size of each volume separately
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <szaimen@e.mail.de>
  • Loading branch information
szaimen committed Feb 1, 2023
1 parent b6c3a77 commit 141bc39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ spec:
value: "{{ .Values.TIMEZONE }}"
- name: UPDATE_NEXTCLOUD_APPS
value: "{{ .Values.UPDATE_NEXTCLOUD_APPS }}"
image: nextcloud/aio-nextcloud:20230124_100035-{{ .Values.IMAGE_TAG }}
image: nextcloud/aio-nextcloud:20230124_100031-{{ .Values.IMAGE_TAG }}
name: nextcloud-aio-nextcloud
volumeMounts:
- mountPath: /var/www/html
Expand Down
33 changes: 11 additions & 22 deletions helm-chart/update-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ find ./ -name '*deployment.yaml' -exec sed -i "s|manual-install-nextcloud-aio|ne
# shellcheck disable=SC1083
find ./ -name '*deployment.yaml' -exec sed -i "/^ spec:/a\ \ \ \ \ \ securityContext:\n\ \ \ \ \ \ \ \ fsGroup: 65534\n\ \ \ \ \ \ \ \ fsGroupChangePolicy: \"OnRootMismatch\"" \{} \;
# shellcheck disable=SC1083
find ./ \( -not -name '*apache*' -not -name '*collabora-fonts*' -not -name '*trusted-cacerts*' -name '*persistentvolumeclaim.yaml' \) -exec sed -i "s|storage: 100Mi|storage: 1Gi|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*nextcloud-data-persistentvolumeclaim.yaml' -exec sed -i "s|storage: 1Gi|storage: {{ .Values.NEXTCLOUD_DATA_STORAGE_SIZE }}|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*database*persistentvolumeclaim.yaml' -exec sed -i "s|storage: 1Gi|storage: {{ .Values.DATABASE_STORAGE_SIZE }}|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*elasticsearch-persistentvolumeclaim.yaml' -exec sed -i "s|storage: 1Gi|storage: {{ .Values.FULLTEXTSEARCH_STORAGE_SIZE }}|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*persistentvolumeclaim.yaml' -exec sed -i "s|storage: 100Mi|storage: {{ .Values.DEFAULT_100M_STORAGE_SIZE }}|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*persistentvolumeclaim.yaml' -exec sed -i "s|storage: 1Gi|storage: {{ .Values.DEFAULT_1G_STORAGE_SIZE }}|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*persistentvolumeclaim.yaml' -exec sed -i "s|ReadOnlyMany|ReadWriteOnce|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*persistentvolumeclaim.yaml' -exec sed -i "/accessModes:/i\ \ {{- if .Values.STORAGE_CLASS }}" \{} \;
Expand Down Expand Up @@ -86,6 +74,14 @@ find ./ \( -not -name '*service.yaml' -name '*.yaml' \) -exec sed -i "/^status:/
find ./ \( -not -name '*persistentvolumeclaim.yaml' -name '*.yaml' \) -exec sed -i "/resources:/d" \{} \;
# shellcheck disable=SC1083
find ./ -name '*.yaml' -exec sed -i "/creationTimestamp: null/d" \{} \;
VOLUMES="$(find ./ -name '*persistentvolumeclaim.yaml' | sed 's|-persistentvolumeclaim.yaml||g;s|.*nextcloud-aio-||g')"
mapfile -t VOLUMES <<< "$VOLUMES"
for variable in "${VOLUMES[@]}"; do
name="$(echo "$variable" | sed 's|-|_|g' | tr '[:lower:]' '[:upper:]')_STORAGE_SIZE"
VOLUME_VARIABLE+=("$name")
# shellcheck disable=SC1083
find ./ -name "nextcloud-aio-$variable-persistentvolumeclaim.yaml" -exec sed -i "s|storage: 100Mi|storage: {{ .Values.$name }}|" \{} \;
done

cd ../
mkdir -p ../helm-chart/
Expand All @@ -110,16 +106,9 @@ sed -i '/^NEXTCLOUD_MOUNT/d' /tmp/sample.conf
sed -i 's|^NEXTCLOUD_TRUSTED_CACERTS_DIR: .*|NEXTCLOUD_TRUSTED_CACERTS_DIR: # Setting this to any value allows to automatically import root certificates into the Nextcloud container|' /tmp/sample.conf
# shellcheck disable=SC2129
echo 'STORAGE_CLASS: # By setting this, you can adjust the storage class for your volumes' >> /tmp/sample.conf
# shellcheck disable=SC2129
echo 'NEXTCLOUD_DATA_STORAGE_SIZE: 10Gi # You can change the size of Nextclouds Datadir with this value' >> /tmp/sample.conf
# shellcheck disable=SC2129
echo 'DATABASE_STORAGE_SIZE: 1Gi # You can change the size of the database volume with this value' >> /tmp/sample.conf
# shellcheck disable=SC2129
echo 'FULLTEXTSEARCH_STORAGE_SIZE: 1Gi # You can change the size of the fulltextsearch volume with this value' >> /tmp/sample.conf
# shellcheck disable=SC2129
echo 'DEFAULT_100M_STORAGE_SIZE: 100Mi # You can change the size of the remaining volumes that default to 100Mi with this value' >> /tmp/sample.conf
# shellcheck disable=SC2129
echo 'DEFAULT_1G_STORAGE_SIZE: 1Gi # You can change the size of the remaining volumes that default to 1Gi with this value' >> /tmp/sample.conf
for variable in "${VOLUME_VARIABLE[@]}"; do
echo "$variable: 1Gi # You can change the size of the $(echo "$variable" | sed 's|_STORAGE_SIZE||;s|_|-|' | tr '[:upper:]' '[:lower:]') volumes that default to 1Gi with this value" >> /tmp/sample.conf
done
mv /tmp/sample.conf ../helm-chart/values.yaml

ENABLED_VARIABLES="$(grep -oP '^[A-Z]+_ENABLED' ../helm-chart/values.yaml)"
Expand Down

0 comments on commit 141bc39

Please sign in to comment.