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

Deprecate storage addon #2833

Merged
merged 10 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
23 changes: 23 additions & 0 deletions microk8s-resources/actions/disable.hostpath-storage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -e

source $SNAP/actions/common/utils.sh

echo "Disabling hostpath storage."
read -ra ARGUMENTS <<< "$1"

declare -A map
map[\$SNAP_COMMON]="$SNAP_COMMON"
use_manifest storage delete "$(declare -p map)"
sleep 5
echo "Storage removed."
if [ ! -z "${ARGUMENTS[@]}" ] && [ "${ARGUMENTS[@]}" = "destroy-storage" ]
then
run_with_sudo rm -rf "$SNAP_COMMON/default-storage"
echo "Storage space reclaimed."
else
read -p "Remove PVC storage at $SNAP_COMMON/default-storage ? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
run_with_sudo rm -rf "$SNAP_COMMON/default-storage"
echo "Storage space reclaimed."
fi
2 changes: 1 addition & 1 deletion microk8s-resources/actions/disable.registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ source $SNAP/actions/common/utils.sh
echo "Disabling the private registry"
use_manifest registry delete
use_manifest registry-help apply
echo "The registry is disabled. Use 'microk8s disable storage:destroy-storage' to free the storage space."
echo "The registry is disabled. Use 'microk8s disable hostpath-storage:destroy-storage' to free the storage space."
19 changes: 3 additions & 16 deletions microk8s-resources/actions/disable.storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,7 @@ set -e

source $SNAP/actions/common/utils.sh

echo "Disabling default storage"
read -ra ARGUMENTS <<< "$1"
echo "DEPRECIATION WARNING: 'storage' is deprecated and will soon be removed. Please use 'hostpath-storage' instead."
echo ""

declare -A map
map[\$SNAP_COMMON]="$SNAP_COMMON"
use_manifest storage delete "$(declare -p map)"
sleep 5
echo "Storage removed"
if [ ! -z "${ARGUMENTS[@]}" ] && [ "${ARGUMENTS[@]}" = "destroy-storage" ]
then
run_with_sudo rm -rf "$SNAP_COMMON/default-storage"
echo "Storage space reclaimed"
else
read -p "Remove PVC storage at $SNAP_COMMON/default-storage ? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
run_with_sudo rm -rf "$SNAP_COMMON/default-storage"
echo "Storage space reclaimed"
fi
"$SNAP/microk8s-disable.wrapper" hostpath-storage
28 changes: 28 additions & 0 deletions microk8s-resources/actions/enable.hostpath-storage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -e

source $SNAP/actions/common/utils.sh

if [ -d "$SNAP_COMMON/default-storage" ]
then
echo "Hostpath storage is already enabled."
exit 0
fi

echo "Enabling default storage class."
echo "WARNING: Hostpath storage is not suitable for production environments."
echo ""
run_with_sudo mkdir -p ${SNAP_COMMON}/default-storage

declare -A map
map[\$SNAP_COMMON]="$SNAP_COMMON"
use_manifest storage apply "$(declare -p map)"
echo "Storage will be available soon."

if [ -e ${SNAP_DATA}/var/lock/clustered.lock ]
then
echo ""
echo "WARNING: The storage class enabled does not persist volumes across nodes."
echo ""
fi
4 changes: 2 additions & 2 deletions microk8s-resources/actions/enable.portainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ MANIFEST_PTR="https://raw.githubusercontent.com/portainer/k8s/master/deploy/mani

KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"

microk8s enable storage
microk8s enable dns
"$SNAP/microk8s-enable.wrapper" hostpath-storage
"$SNAP/microk8s-enable.wrapper" dns

echo "Enabling portainer"

Expand Down
4 changes: 2 additions & 2 deletions microk8s-resources/actions/enable.registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ -z "${ARGUMENTS[@]}" ]; then
echo "You can use the \"size\" argument while enabling the registry, eg microk8s.enable registry:size=30Gi"
declare -A map
map[\$DISKSIZE]="20Gi"
"$SNAP/microk8s-enable.wrapper" storage
"$SNAP/microk8s-enable.wrapper" hostpath-storage
echo "Applying registry manifest"
use_manifest registry apply "$(declare -p map)"
echo "The registry is enabled"
Expand All @@ -29,7 +29,7 @@ elif [[ ${ARGUMENTS[@]} =~ $regex_args ]]; then
echo "The size of the registry should be higher or equal to 20Gi and match the regex: (^[2-9][0-9]{1,}|^[1-9][0-9]{2,})(Gi$)"
exit 1
elif [ "$key" = "size" ] && [[ $value =~ $REGEX_DISK_SIZE ]]; then
"$SNAP/microk8s-enable.wrapper" storage
"$SNAP/microk8s-enable.wrapper" hostpath-storage
declare -A map
map[\$DISKSIZE]=$value
fi
Expand Down
16 changes: 3 additions & 13 deletions microk8s-resources/actions/enable.storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ set -e

source $SNAP/actions/common/utils.sh

echo "Enabling default storage class"
run_with_sudo mkdir -p ${SNAP_COMMON}/default-storage
echo "DEPRECIATION WARNING: 'storage' is deprecated and will soon be removed. Please use 'hostpath-storage' instead."
echo ""

declare -A map
map[\$SNAP_COMMON]="$SNAP_COMMON"
use_manifest storage apply "$(declare -p map)"
echo "Storage will be available soon"

if [ -e ${SNAP_DATA}/var/lock/clustered.lock ]
then
echo ""
echo "WARNING: The storage class enabled does not persist volumes across nodes"
echo ""
fi
"$SNAP/microk8s-enable.wrapper" hostpath-storage
10 changes: 8 additions & 2 deletions microk8s-resources/wrappers/microk8s-join.wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ export PYTHONNOUSERSITE=false

source $SNAP/actions/common/utils.sh

if [ -e "$SNAP_DATA/args/cni-network/cni.yaml.disabled" ] && [ -e "$SNAP_DATA/args/cni-network/05-cilium-cni.conf" ] ; then
echo "Cilium is enabled and is not suitable for multi node clusters."
if [ -e "$SNAP_DATA/args/cni-network/cni.yaml.disabled" ] && [ -e "$SNAP_DATA/args/cni-network/05-cilium-cni.conf" ] ; then
echo "WARNING: Cilium is enabled and is not suitable for multi node clusters."
exit 1
fi

if [ -d "$SNAP_COMMON/default-storage" ]
then
echo "WARNING: Hostpath storage is enabled and is not suitable for multi node clusters."
echo ""
fi

exit_if_no_permissions

sudo -E LD_LIBRARY_PATH=$IN_SNAP_LD_LIBRARY_PATH ${SNAP}/usr/bin/python3 ${SNAP}/scripts/cluster/join.py $@