Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.29] Fixes minio addon #294

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions addons/minio/disable
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash -ex

echo "Cleaning up MinIO tenants and operator"
"${SNAP}/usr/bin/yes" | "${SNAP_COMMON}/plugins/kubectl-minio" delete

echo "Remove kubectl-minio"
rm "${SNAP_COMMON}/plugins/kubectl-minio"
rm "${SNAP_COMMON}/plugins/.kubectl-minio"
HELM="$SNAP/microk8s-helm3.wrapper"
NAMESPACE="minio-operator"
$HELM list -n $NAMESPACE --short | xargs $HELM uninstall -n $NAMESPACE

echo "Disabled minio addon."
63 changes: 26 additions & 37 deletions addons/minio/enable
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ CAPACITY="20Gi"
SERVERS=1
VOLUMES=1
TENANT="microk8s"
VERSION="4.5.1"
VERSION="v6.0.2"
TLS="no"
PROMETHEUS="no"
REPO="https://github.com/minio/operator"
REPO="https://operator.min.io"

# Enable dependenciess
MICROK8S_ENABLE="${SNAP}/microk8s-enable.wrapper"
"${MICROK8S_ENABLE}" dns
"${MICROK8S_ENABLE}" helm3
"${MICROK8S_ENABLE}" hostpath-storage

function usage {
Expand All @@ -29,13 +30,13 @@ function usage {
echo " -h Print this help message"
echo " -k Do not create default tenant"
echo " -s STORAGECLASS Storage class to use for the default tenant (default: ${STORAGE_CLASS})"
echo " -c CAPACITY Capacity of the default tenant (default: ${CAPACITY})"
echo " -n SERVERS Servers of the default tenant (default: ${SERVERS})"
echo " -v VOLUMES Volumes of the default tenant (default: ${VOLUMES})"
echo " -c CAPACITY Capacity of each volume for the default tenant (default: ${CAPACITY})"
echo " -n SERVERS Number of servers of the default tenant (default: ${SERVERS})"
echo " -v VOLUMES Number of volumes for each server of the default tenant (default: ${VOLUMES})"
echo " -t TENANTNAME Name of the default tenant (default: ${TENANT})"
echo " -T Enable TLS for the default tenant (default: disabled)"
echo " -p Enable Prometheus for the default tenant (default: disabled)"
echo " -r REPOSITORY Minio Operator GitHub repository (default: ${REPO})"
echo " -r REPOSITORY Minio Operator Helm chart repository (default: ${REPO})"
echo " -V VERSION Minio Operator version (default: ${VERSION})"
}

Expand Down Expand Up @@ -68,25 +69,12 @@ while getopts ":hkTps:c:n:v:t:r:V:" arg; do
esac
done

echo "Download kubectl-minio"
HELM="$SNAP/microk8s-helm3.wrapper"

if [ ! -f "${SNAP_COMMON}/plugins/kubectl-minio" ]; then
fetch_as "${REPO}/releases/download/v${VERSION}/kubectl-minio_${VERSION}_linux_${ARCH}" "${SNAP_COMMON}/plugins/.kubectl-minio"
run_with_sudo chmod +x "${SNAP_COMMON}/plugins/.kubectl-minio"
cp "${DIR}/kubectl-minio" "${SNAP_COMMON}/plugins/kubectl-minio"
fi

# Ensure kubectl exists in PATH
mkdir -p "${SNAP_COMMON}/plugins/.kubectl"
ln -f -s "${SNAP}/microk8s-kubectl.wrapper" "${SNAP_COMMON}/plugins/.kubectl/kubectl"

if ! "${SNAP_COMMON}/plugins/kubectl-minio" version > /dev/null; then
echo "Could not execute kubectl-minio"
exit 1
fi

echo "Initialize minio operator"
"${SNAP_COMMON}/plugins/kubectl-minio" init
echo "Installing minio operator"
$HELM upgrade --install minio-operator operator \
--repo $REPO --version "${VERSION}" \
--create-namespace --namespace "minio-operator"

if [ "x${CREATE_TENANT}" = "xyes" ]; then
echo "Create default tenant with:"
Expand All @@ -100,26 +88,27 @@ if [ "x${CREATE_TENANT}" = "xyes" ]; then
echo " Prometheus: ${PROMETHEUS}"
echo ""

declare -a ARGS=(
"${TENANT}"
--storage-class "${STORAGE_CLASS}"
--capacity "${CAPACITY}"
--servers "${SERVERS}"
--volumes "${VOLUMES}"
--namespace "minio-operator"
--enable-audit-logs="false"
)
HELM_OPTS=

if [ "x${TLS}" = "xno" ]; then
ARGS+=("--disable-tls")
HELM_OPTS+="--set tenant.certificate.requestAutoCert=false "
fi

if [ "x${PROMETHEUS}" = "xno" ]; then
ARGS+=("--enable-prometheus=false")
if [ "x${PROMETHEUS}" != "xno" ]; then
HELM_OPTS+="--set tenant.prometheusOperator=true "
fi

set -x
"${SNAP_COMMON}/plugins/kubectl-minio" tenant create ${ARGS[@]}
$HELM upgrade --install "${TENANT}" tenant \
--repo $REPO --version "${VERSION}" \
--namespace "minio-operator" \
--set "tenant.name=${TENANT}" \
--set "tenant.pools[0].name=${TENANT}" \
--set "tenant.pools[0].storageClassName=${STORAGE_CLASS}" \
--set "tenant.pools[0].size=${CAPACITY}" \
--set "tenant.pools[0].servers=${SERVERS}" \
--set "tenant.pools[0].volumesPerServer=${VOLUMES}" \
${HELM_OPTS}
set +x
fi

Expand Down
Loading