Add baked-in image capability

Add capability to "bake in" a disk image into a container image.
Rework deployment process
This commit is contained in:
Dessa Simpson 2023-10-30 02:12:32 -07:00
parent bd6050ea3e
commit 7911c7eefc
9 changed files with 108 additions and 39 deletions

43
misc/bootstrap-k8s-imageless.sh Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash
set -e
#
# This file is used to deploy a PDP-11 from a container image without a baked-in disk image.
#
usage () {
echo "usage: $0 tag disk_filename"
exit 1
}
[[ $# -eq 2 ]] || usage
tag="$1"
disk_filename="$2"
cd "$(dirname $(dirname $0))"
[[ -f "$disk_filename" && -r "$disk_filename" ]] || { echo "$disk_filename does not exist, is not a regular file, or is not readable"; exit 1; }
[[ "$disk_filename" == *.gz ]] || { echo "$disk_filename does not appear to be a gzip-compressed disk image"; exit 1; }
sed "s!<TAG>!${tag}!" ./k8s/deployment.yaml.template > ./k8s/deployment.yaml
echo "Creating PVC..."
kubectl apply -f ./k8s/pvc.yaml
echo "Creating temporary pod..."
kubectl apply -f ./k8s/pod-tmp.yaml
echo "Waiting for temporary pod..."
while ! kubectl get pod pdp-tmp|grep -q Running; do sleep 1; done
echo "Checking for disk image..."
if ! kubectl exec -it pdp-tmp -- test -f /mnt/rq0.dsk &>/dev/null; then
echo "Uploading compressed disk image..."
kubectl exec pdp-tmp -- rm -f /mnt/rq0.dsk.gz
kubectl cp "$disk_filename" pdp-tmp:/mnt/rq0.dsk.gz
echo "Extracting disk image..."
kubectl exec pdp-tmp -- gzip -d /mnt/rq0.dsk.gz
fi
echo "Removing temporary pod..."
kubectl delete -f ./k8s/pod-tmp.yaml
echo "Creating PDP deployment..."
kubectl apply -f ./k8s/deployment.yaml
echo "Creating services..."
for i in ./k8s/svc-*.yaml; do kubectl apply -f "$i"; done
echo "Done! Optionally, run ./misc/configure-metallb.sh to put the services on an external IP."

23
misc/configure-metallb.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
set -e
usage () {
echo "usage: $0 ip"
exit 1
}
[[ $# -eq 1 ]] || usage
ip="$1"
cd "$(dirname $(dirname $0))/k8s/"
sed "s!<IP>!${ip}!" ./metallb.yaml.template > ./metallb.yaml
echo "Configuring metallb..."
kubectl apply -f ./metallb.yaml
echo "Configuring services..."
for i in ./svc-*.yaml; do
svc="$(grep -Po "name: \Kpdp-.*$" "$i")"
kubectl patch svc "$svc" -p '{"metadata":{"annotations":{"metallb.universe.tf/allow-shared-ip":"'"$ip"'"}},"spec":{"type": "LoadBalancer","loadBalancerIP":"'"$ip"'"}}'
done
echo "Done!"

0
misc/metallb.yaml Normal file
View file