mirror of
https://github.com/hauler-dev/hauler.git
synced 2026-08-24 11:47:20 +00:00
128 lines
3.8 KiB
Bash
Executable File
128 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# , , _______________________________
|
|
# ,-----------|'------'| | |
|
|
# /. '-' |-' |_____________________________|
|
|
# |/| | |
|
|
# | .________.'----' _______________________________
|
|
# | || | || | |
|
|
# \__|' \__|' |_____________________________|
|
|
#
|
|
# |‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|
|
|
# |________________________________________________________|
|
|
# |
|
|
# |‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|
|
|
# |________________________________________________________|
|
|
#
|
|
# k3ama - airgap migration assistant
|
|
|
|
LOCAL_IMAGES_FILEPATH=/var/lib/rancher/k3s/agent/images
|
|
ADDL_IMAGES=./artifacts/images
|
|
|
|
copy_images(){
|
|
cp -rvf ${ADDL_IMAGES}/* ${LOCAL_IMAGES_FILEPATH}
|
|
}
|
|
|
|
install_k3s(){
|
|
AIRGAP_IMAGES_TAR="$1"
|
|
|
|
## Note: currently requires root
|
|
mkdir -p ${LOCAL_IMAGES_FILEPATH}
|
|
echo "copying ${AIRGAP_IMAGES_TAR} -> ${LOCAL_IMAGES_FILEPATH}"
|
|
cp artifacts/k3s-airgap-images-amd64.tar /var/lib/rancher/k3s/agent/images
|
|
# copy over the k3s binary
|
|
cp ./artifacts/k3s /usr/local/bin/k3s
|
|
chmod +x /usr/local/bin/k3s
|
|
|
|
INSTALL_K3S_SKIP_DOWNLOAD=true ./scripts/k3s-install.sh
|
|
}
|
|
|
|
uninstall_k3s(){
|
|
if [ -f "/usr/local/bin/k3s-uninstall.sh" ]; then
|
|
/usr/local/bin/k3s-uninstall.sh
|
|
else
|
|
echo "k3s is not installed"
|
|
fi
|
|
}
|
|
|
|
check_deps(){
|
|
#TODO
|
|
echo "TODO: check to ensure that the dependencies are in place."
|
|
#rpm -qa | grep k3s-selinux
|
|
}
|
|
|
|
#gather_selinux_rpms(){
|
|
# if ! yum list installed yum-utils >/dev/null 2>&1; then
|
|
# yum install -y yum-utils
|
|
# fi
|
|
#wget -O ./https://rpm.rancher.io/k3s-selinux-0.1.1-rc1.el7.noarch.rpm
|
|
#yumdownloader --destdir=. --resolve container-selinux selinux-policy-base
|
|
#}
|
|
|
|
usage () {
|
|
echo "USAGE: $0 [--image-list rancher-images.txt] [--images rancher-images.tar.gz]"
|
|
echo " [-l|--image-list path] text file with list of images; one image per line."
|
|
echo " [-i|--images path] tar.gz generated by docker save."
|
|
echo " [-h|--help] Usage message"
|
|
}
|
|
|
|
check_firewalld(){
|
|
if pgrep -x "firewalld" >/dev/null
|
|
then
|
|
echo "[FATAL] disable firewalld first"
|
|
fi
|
|
}
|
|
|
|
check_selinux(){
|
|
# yes i know we want selinux, but it's a pain in the ass right now and i will come back to it
|
|
SELINUXSTATUS=$(getenforce)
|
|
if [ "$SELINUXSTATUS" == "Permissive" ]; then
|
|
echo "[FATAL] disable selinux"
|
|
exit 1
|
|
else
|
|
echo "SELINUX disabled. continuing"
|
|
fi
|
|
}
|
|
|
|
copy_yaml_manifests(){
|
|
cp -r ./yaml/* /var/lib/rancher/k3s/server/manifests
|
|
}
|
|
|
|
copy_local_bins(){
|
|
if [ -f "./artifacts/k9s" ]; then
|
|
cp -v ./artifacts/k9s /usr/local/bin/
|
|
fi
|
|
}
|
|
|
|
copy_local_kubectl(){
|
|
echo "TODO"
|
|
}
|
|
|
|
iptable_block_docker_io() {
|
|
# iptables -A OUTPUT -p tcp -m string --string "docker.io" --algo kmp -j REJECT
|
|
echo "iptable_block_docker_io() disabled"
|
|
}
|
|
## TODO: Make this interactive with case statements
|
|
|
|
uninstall_k3s
|
|
copy_local_bins
|
|
iptable_block_docker_io
|
|
check_deps
|
|
check_firewalld
|
|
#check_selinux
|
|
install_k3s ./artifacts/k3s-airgap-images-amd64.tar
|
|
copy_images
|
|
copy_yaml_manifests
|
|
|
|
|
|
|
|
|
|
/usr/local/bin/k3s kubectl get pods -A -w
|
|
|
|
|
|
#######
|
|
# Notes:
|
|
# - workaround: busybox is not included in the main images.txt list and therefor the pvcs cannot create.
|
|
# - VAGRANT FAIL: INFO[0000] Preparing data dir /var/lib/rancher/k3s/data ... for some reason local-path provisioner cannot create vols in vagrant
|
|
# - bug: RunContainerError results you try to reinstall k3s on top of an old instance WHEN RUNNING SELINUX
|
|
####### |