core/scripts/05_install_longhorn.sh
Guillaume B.B. Van Hemmen a8b66cbb54 #0000 - Add support for custom S3 endpoint in Longhorn installer
This update modifies the installation script to require a custom S3-compatible endpoint as a parameter. It ensures the endpoint is passed to both the script's environment and the Kubernetes secret used by Longhorn. This improves flexibility for setups using non-standard S3-compatible storage.
2024-12-28 13:53:55 +01:00

53 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
set -e
if [ -z "$1" ]; then
echo "Error: Missing S3 access key ID."
echo "Usage: $0 <AWS_ACCESS_KEY_ID> <AWS_SECRET_ACCESS_KEY>"
echo "You must provide your access key ID as a parameter to run this script."
exit 1
fi
if [ -z "$2" ]; then
echo "Error: Missing S3 secret access key ID."
echo "Usage: $0 <AWS_ACCESS_KEY_ID> <AWS_SECRET_ACCESS_KEY>"
echo "You must provide your secret access key ID as a parameter to run this script."
exit 1
fi
if [ -z "$3" ]; then
echo "Error: Missing S3 endpoint."
echo "Usage: $0 <AWS_ACCESS_KEY_ID> <AWS_SECRET_ACCESS_KEY> <AWS_ENDPOINT>"
echo "You must provide your s3 compatible endpoint as a parameter to run this script."
exit 1
fi
AWS_ACCESS_KEY_ID=$1
AWS_SECRET_ACCESS_KEY=$2
AWS_ENDPOINTS=$3
# Add the longhorn Helm repository
helm repo add longhorn https://charts.longhorn.io
helm repo update
# Create the namespace for longhorn
kubectl create namespace longhorn-system || true
kubectl label namespace longhorn-system pod-security.kubernetes.io/enforce=privileged
kubectl label namespace longhorn-system pod-security.kubernetes.io/audit=privileged
kubectl label namespace longhorn-system pod-security.kubernetes.io/warn=privileged
kubectl delete secret longhorn-s3-secret -n longhorn-system || true
kubectl create secret generic longhorn-s3-secret \
--namespace longhorn-system \
--from-literal=AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
--from-literal=AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
--from-literal=AWS_ENDPOINTS=$AWS_ENDPOINTS \
--from-literal=AWS_REGION=eu-west-1
# Install the longhorn chart
helm install longhorn longhorn/longhorn \
--namespace longhorn-system \
--version 1.7.2 \
-f ./helm-values/longhorn.yaml