Compare commits

..

No commits in common. "67d8dc3f5c18324e4f1362bc34ba912c2872a87b" and "6bde027c48f9ddd556a8b8ad48337ec0fc30a2fe" have entirely different histories.

5 changed files with 22 additions and 157 deletions

View File

@ -16,4 +16,4 @@
[log] [log]
date = local date = local
[init] [init]
defaultBranch = main defaultBranch = master

View File

@ -4,106 +4,27 @@ set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
############## Setup ######################### : ${cpu:="500m"}
: ${memory:="2Gi"}
function cleanup { overrides=""
for f in "${pods[@]}"; do if [ ! -z "${highmem:-}" ]; then
log "Deleting $f" overrides=$(jq --compact-output '.' <<EOF
kubectl delete pod --force=true --grace-period=0 --namespace homepage "$f" {
done "spec": {
"tolerations": [
{
"key": "dedicated",
"operator": "Equal",
"value": "background-highmem",
"effect": "NoSchedule"
} }
pods=() ],
for sig in EXIT INT QUIT HUP TERM; do "nodeSelector": {"dedicated": "background-highmem"}
trap "set +e; cleanup" "$sig"
done
function die {
local status_code="$1"
shift
(>&2 echo "${@}")
exit "$status_code"
} }
function log {
(>&2 echo "${@}")
} }
############## Program #########################
function main {
local pod_name="tom-$(uuidgen | cut -d '-' -f 1)"
pods+=("$pod_name")
create_pod "$pod_name"
kubectl wait pods -n homepage "$pod_name" --for condition=Ready --timeout=90s
kubectl exec -i -t --namespace homepage "$pod_name" -- "${@}"
}
function create_pod {
local pod_name="$1"
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
labels:
run: $pod_name
name: $pod_name
namespace: homepage
spec:
imagePullSecrets:
- name: registry-credentials
containers:
- args:
- /bin/sleep
- infinity
image: harbor.fizz.buzz/dockerhub/library/alpine:3.18
imagePullPolicy: IfNotPresent
name: $pod_name
stdin: true
stdinOnce: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
tty: true
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-hskj7
readOnly: true
# serviceAccount: default
# serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: kube-api-access-hskj7
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
EOF EOF
} )
fi
function delete_pod { exec kubectl run --rm -i -t --image alpine:3.13 --overrides="$overrides" --requests "cpu=$cpu,memory=$memory" --limits "cpu=$cpu,memory=$memory" --pod-running-timeout 10m "tom-$(uuidgen | cut -d '-' -f 1)" -- /bin/sh "$@"
local pod_name="$1"
kubectl delete pod --force=true --grace-period=0 --namespace homepage "$pod_name"
}
main "$@"

View File

@ -1,45 +0,0 @@
#!/usr/bin/env bash
#
# Kill the virtual machines, take a snapshot, and start the virtual machines up again.
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
############## Setup #########################
function die {
local status_code="$1"
shift
(>&2 echo "${@}")
exit "$status_code"
}
function log {
(>&2 echo "${@}")
}
############## Program #########################
function main {
snapshot_name="$1"
kill_all_bhyve
log "Taking snapshot $1"
for worker in worker0 worker1 worker2 controller0 controller1 controller2; do
doas zfs snapshot -r zdata/vm/${worker}/disk0@${snapshot_name}
done
doas zfs snapshot zdata/k8spersistent@${snapshot_name}
launch_all_bhyve
log "Done."
}
function kill_all_bhyve {
log "Killing all virtual machines."
doas killall bhyve; while true; do tmux ls || break; sleep 2; done;
}
function launch_all_bhyve {
log "Launching all virtual machines."
for vm in poudriere controller0 controller1 controller2 worker0 worker1 worker2; do tmux new -d -s $vm doas bhyve_netgraph_bridge start $vm zdata/vm/$vm /vm/$vm; sleep 5; done
}
main "$@"

View File

@ -39,14 +39,3 @@
group: wheel group: wheel
loop: loop:
- /k8spersistent - /k8spersistent
- name: Install scripts
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0755
owner: root
group: wheel
loop:
- src: "k8s_snapshot.bash"
dest: /usr/local/bin/k8s_snapshot

View File

@ -14,4 +14,4 @@ export MOZ_ENABLE_WAYLAND=1
# Wayland seems enabled by default for qt5 with qt5-wayland installed but if a proprietary program bundles their own qt then I may have to set QT_QPA_PLATFORM="wayland;xcb" # Wayland seems enabled by default for qt5 with qt5-wayland installed but if a proprietary program bundles their own qt then I may have to set QT_QPA_PLATFORM="wayland;xcb"
# Wayland does not seem enabled for gtk apps and setting GDK_BACKEND=wayland did not change that. # Wayland does not seem enabled for gtk apps and setting GDK_BACKEND=wayland did not change that.
exec ck-launch-session dbus-run-session sway -d &> $HOME/.config/swaylog exec ck-launch-session dbus-launch sway -d &> $HOME/.config/swaylog