-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* start k3s by flux jobs * k3s setup in full flux nodes working properly * k3s in root mode with flux job, part 1 working * some tweaking and more testing done * remove sensitive information * added more instructions in readme, updated protocol for basic flux setup also
- Loading branch information
1 parent
8c10b4e
commit c363df8
Showing
8 changed files
with
393 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Read all the hostname the job is running | ||
nodenames_string=$(flux exec -r all hostname) | ||
echo $nodenames_string | ||
# separate the names into an array | ||
IFS=' ' | ||
read -ra nodenames_array <<< $nodenames_string | ||
leader=${nodenames_array[0]} | ||
echo $leader | ||
|
||
secret_token=${1} | ||
[ $# -eq 0 ] && { echo "Usage: $0 argument, Provide k3s secret"; exit 1; } | ||
|
||
flux submit -N 3 --wait --error ./k3s_starter.out --output ./k3s_starter.out sh ./k3s_starter.sh "${leader}" "${secret_token}" | ||
|
||
echo "JOB COMPLETE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/sh | ||
set -x | ||
[ $(id -u) -eq 0 ] || exec sudo $0 $@ | ||
|
||
for service in /etc/systemd/system/k3s*.service; do | ||
[ -s $service ] && systemctl stop $(basename $service) | ||
done | ||
|
||
for service in /etc/init.d/k3s*; do | ||
[ -x $service ] && $service stop | ||
done | ||
|
||
pschildren() { | ||
ps -e -o ppid= -o pid= | \ | ||
sed -e 's/^\s*//g; s/\s\s*/\t/g;' | \ | ||
grep -w "^$1" | \ | ||
cut -f2 | ||
} | ||
|
||
pstree() { | ||
for pid in $@; do | ||
echo $pid | ||
for child in $(pschildren $pid); do | ||
pstree $child | ||
done | ||
done | ||
} | ||
|
||
killtree() { | ||
kill -9 $( | ||
{ set +x; } 2>/dev/null; | ||
pstree $@; | ||
set -x; | ||
) 2>/dev/null | ||
} | ||
|
||
getshims() { | ||
ps -e -o pid= -o args= | sed -e 's/^ *//; s/\s\s*/\t/;' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1 | ||
} | ||
|
||
killtree $({ set +x; } 2>/dev/null; getshims; set -x) | ||
|
||
do_unmount_and_remove() { | ||
set +x | ||
while read -r _ path _; do | ||
case "$path" in $1*) echo "$path" ;; esac | ||
done < /proc/self/mounts | sort -r | xargs -r -t -n 1 sh -c 'umount "$0" && rm -rf "$0"' | ||
set -x | ||
} | ||
|
||
do_unmount_and_remove '/run/k3s' | ||
do_unmount_and_remove '/var/lib/rancher/k3s' | ||
do_unmount_and_remove '/var/lib/kubelet/pods' | ||
do_unmount_and_remove '/var/lib/kubelet/plugins' | ||
do_unmount_and_remove '/run/netns/cni-' | ||
|
||
# Remove CNI namespaces | ||
ip netns show 2>/dev/null | grep cni- | xargs -r -t -n 1 ip netns delete | ||
|
||
# Delete network interface(s) that match 'master cni0' | ||
ip link show 2>/dev/null | grep 'master cni0' | while read ignore iface ignore; do | ||
iface=${iface%%@*} | ||
[ -z "$iface" ] || ip link delete $iface | ||
done | ||
ip link delete cni0 | ||
ip link delete flannel.1 | ||
ip link delete flannel-v6.1 | ||
ip link delete kube-ipvs0 | ||
ip link delete flannel-wg | ||
ip link delete flannel-wg-v6 | ||
rm -rf /var/lib/cni/ | ||
iptables-save | grep -v KUBE- | grep -v CNI- | grep -iv flannel | iptables-restore | ||
ip6tables-save | grep -v KUBE- | grep -v CNI- | grep -iv flannel | ip6tables-restore | ||
|
||
systemctl disable k3s-agent | ||
systemctl reset-failed k3s-agent | ||
systemctl daemon-reload | ||
|
||
rm -f /etc/systemd/system/k3s-agent.service.env | ||
|
||
rm -rf /etc/rancher/k3s | ||
rm -rf /run/k3s | ||
rm -rf /run/flannel | ||
rm -rf /var/lib/rancher/k3s | ||
rm -rf /var/lib/kubelet |
Oops, something went wrong.