Skip to content

Instantly share code, notes, and snippets.

@brandonros
Created April 1, 2022 01:45
Show Gist options
  • Save brandonros/e87c5a768ff5d53ba3833d0377dc09ad to your computer and use it in GitHub Desktop.
Save brandonros/e87c5a768ff5d53ba3833d0377dc09ad to your computer and use it in GitHub Desktop.

k8s Adventure

Context

  • Running Mac OS X on Apple M1 (arm64)

kubectl

brew install kubernetes-cli

QEMU

brew install qemu

Flatcar Linux

mkdir flatcar
cd flatcar
# make hard disk
qemu-img create -f qcow2 flatcar.qcow2 32G
# get latest flatcar bootable images
wget https://stable.release.flatcar-linux.net/arm64-usr/3033.2.4/flatcar_production_pxe.vmlinuz
wget https://stable.release.flatcar-linux.net/arm64-usr/3033.2.4/flatcar_production_pxe_image.cpio.gz
# start qemu system
qemu-system-aarch64 \
  -M virt,highmem=off \
  -m 4G \
  -smp 4 \
  -cpu host \
  -accel hvf \
  -kernel flatcar_production_pxe.vmlinuz \
  -initrd flatcar_production_pxe_image.cpio.gz \
  -append "flatcar.first_boot=1 sshkey=\"ssh-rsa REDACTED\"" \
  -netdev user,id=mynet0,hostfwd=tcp::2222-:22,hostfwd=tcp::6443-:6443 \
  -device e1000,netdev=mynet0 \
  -hda flatcar.qcow2 \
  -nographic
# in another terminal from local machine
chmod 400 ~/.ssh/id_rsa
ssh -i ~/.ssh/id_rsa -p 2222 core@localhost
# in ssh session
sudo flatcar-install -d /dev/vda -C stable
sudo poweroff
# boot again
qemu-system-aarch64 \
  -M virt,highmem=off \
  -m 4G \
  -smp 4 \
  -cpu host \
  -accel hvf \
  -netdev user,id=mynet0,hostfwd=tcp::2222-:22,hostfwd=tcp::6443-:6443 \
  -device e1000,netdev=mynet0 \
  -drive file=flatcar.qcow2,format=qcow2 \
  -kernel flatcar_production_pxe.vmlinuz \
  -initrd flatcar_production_pxe_image.cpio.gz \
  -append "root=LABEL=ROOT sshkey=\"ssh-rsa REDACTED\"" \
  -nographic

k3sup

wget https://github.com/alexellis/k3sup/releases/download/0.11.3/k3sup-darwin
chmod +x k3sup-darwin
./k3sup-darwin install --ip 127.0.0.1 --ssh-port 2222 --user core
mkdir ~/.kube
mv kubeconfig ~/.kube/config
kubectl config set-context default

percona-postgresql-operator

kubectl create namespace pgo
kubectl -n pgo apply -f https://raw.githubusercontent.com/percona/percona-postgresql-operator/main/deploy/operator.yaml
kubectl wait --for=condition=complete --timeout=300s -n pgo job/pgo-deploy
kubectl get all --all-namespaces
kubectl get events --all-namespaces --sort-by='.metadata.creationTimestamp'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment