Added migrations.d
This commit is contained in:
@@ -5,22 +5,37 @@ exec >>/var/log/monok8s/boot.log 2>&1
|
||||
|
||||
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
|
||||
|
||||
MIGRATIONS_LIB=/usr/lib/monok8s/lib/migrations.sh
|
||||
CONFIG_DIR=/opt/monok8s/config
|
||||
BOOT_STATE=/run/monok8s/boot-state.env
|
||||
BOOTPART_FILE="$CONFIG_DIR/.bootpart"
|
||||
MIGRATION_STATE_DIR="$CONFIG_DIR/migration-state"
|
||||
|
||||
mkdir -p /dev/hugepages
|
||||
mountpoint -q /dev/hugepages || mount -t hugetlbfs none /dev/hugepages
|
||||
echo 640 > /proc/sys/vm/nr_hugepages
|
||||
echo 256 > /proc/sys/vm/nr_hugepages
|
||||
|
||||
CUR=$(grep '^BOOT_PART=' /run/monok8s/boot-state.env | cut -d= -f2-)
|
||||
LAST=$(cat /opt/monok8s/config/.bootpart 2>/dev/null || true)
|
||||
CUR=$(grep '^BOOT_PART=' "$BOOT_STATE" | cut -d= -f2-)
|
||||
LAST=$(cat "$BOOTPART_FILE" 2>/dev/null || true)
|
||||
|
||||
slot_changed=0
|
||||
if [ "$CUR" != "$LAST" ]; then
|
||||
echo "Slot changed ($LAST -> $CUR), cleaning runtime state"
|
||||
|
||||
rm -rf /var/lib/containers \
|
||||
/var/lib/kubelet/pods \
|
||||
/var/lib/kubelet/plugins \
|
||||
/var/lib/kubelet/device-plugins
|
||||
|
||||
mkdir -p /var/lib/containers /var/lib/kubelet
|
||||
slot_changed=1
|
||||
echo "Slot changed ($LAST -> $CUR)"
|
||||
fi
|
||||
|
||||
/usr/local/bin/ctl init --env-file /opt/monok8s/config/cluster.env >>/var/log/monok8s/bootstrap.log 2>&1 &
|
||||
# shellcheck source=/dev/null
|
||||
. "$MIGRATIONS_LIB"
|
||||
|
||||
if [ "$slot_changed" -eq 1 ]; then
|
||||
monok8s_cleanup_runtime_state
|
||||
fi
|
||||
|
||||
K8S_MINOR="$(monok8s_detect_k8s_minor || true)"
|
||||
if [ -n "$K8S_MINOR" ]; then
|
||||
monok8s_run_migration_dir \
|
||||
"/usr/lib/monok8s/migrations.d/k8s/$K8S_MINOR" \
|
||||
"$MIGRATION_STATE_DIR/k8s/$K8S_MINOR"
|
||||
fi
|
||||
|
||||
/usr/local/bin/ctl init --env-file "$CONFIG_DIR/cluster.env" >>/var/log/monok8s/bootstrap.log 2>&1 &
|
||||
|
||||
Reference in New Issue
Block a user