Merge pull request #110 from xenserver-next/setup_external_dev_services.postgres

hack/setup_external_dev_services: Improve postgresql installation
This commit is contained in:
resf-prow[bot] 2023-03-17 17:30:18 +00:00 committed by GitHub
commit 65ba92ea9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 1 deletions

View File

@ -31,9 +31,46 @@
# POSSIBILITY OF SUCH DAMAGE.
#
# TODO: Setup an bash error trap, to make errors from failing commands more
# visible and draw attention of the user to these errors.
# Install postgres
helm repo add bitnami https://charts.bitnami.com/bitnami
helm upgrade --install postgres bitnami/postgresql --set global.postgresql.auth.postgresPassword=postgres --set auth.postgresPassword=postgres --set auth.enablePostgresUser=true
# Documentation and source of the used chart with all configuration parameters:
# https://artifacthub.io/packages/helm/bitnami/postgresql
# https://github.com/helm/charts/tree/master/stable/postgresql
# The postgresql helm chart requires the cluster to provide a PersistentVolume
# and places a PersisentVolumeClaim for this.
# Ensure that the cluster provides PersistentVolumes:
if kubectl get PersistentVolume -o json
| jq -e '.items | .[].status | select(.phase == "Bound")' ; then
echo "Ok found at least one PersistentVolume"
else
echo "The postgresql helm chart has a PersistentVolumeClaim (PVC)."
echo "The cluster needs to provide at one PersistentVolume (PV) for this."
echo "For information how to create a PersistentVolume, see:"
echo "https://github.com/felipecruz91/k8s-postgresql-persistent-volume#create-persistent-volume"
exit 5
fi
# Note: The chart mounts the PV at persistence.mountPath,
# which defaults to /bitnami/postgresql and creates a directory /data in it.
# If it has no permission to create it, this error happens:
# mkdir: cannot create directory /bitnami/postgresql/data: Permission denied
# https://github.com/bitnami/charts/issues/1210
#
# Adding --set volumePermissions.enabled=true helps:
# https://github.com/bitnami/charts/issues/1210#issuecomment-1145923630
helm upgrade --install postgres bitnami/postgresql \
--set volumePermissions.enabled=true \
--set global.postgresql.auth.postgresPassword=postgres \
--set auth.postgresPassword=postgres \
--set auth.enablePostgresUser=true \
kubectl patch svc postgres-postgresql --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"}]'
# Install localstack