Skip to content

Instantly share code, notes, and snippets.

@ammmze
Last active March 7, 2024 07:49
Show Gist options
  • Save ammmze/4bcaf0f46586d7fc12223b6d732c4420 to your computer and use it in GitHub Desktop.
Save ammmze/4bcaf0f46586d7fc12223b6d732c4420 to your computer and use it in GitHub Desktop.
Installing Talos on VPS via Rescue mode

Installing Talos on VPS via Rescue mode

Most VPS solutions have a pretty limited selection of OS's that are available to install on your VPS. Talos is unlikely to be one of the options. While some VPS providers may allow you to open a ticket and receive help installing from a custom ISO, I didn't want to do that. I wanted a way to self-serve and get this installed. This took a bit of digging to learn some of these tools a bit more than I had in the past, but I think this is in a good place.

I haven't permanently put these nodes in my cluster yet, but did verify that I could get an installation done successfully.

FYI, this was tested on inexpensive (3 core, 3 Gi ram, 50Gi disk) VPS instances from Racknerd.

  • Enable rescue mode
  • SSH into rescue instance
  • Run the following shell commands in the setup-talos-disk.sh (I executed them individually because the rescue image had basically nothing to download the script or anything more convenient)
  • Exit rescue mode
  • Apply your talos config (talosctl apply-config --insecure --file /path/to/talos.yaml -n host-or-ip-for-node)

Warning

The script currently assumes a lot of things with the main things like:

  • The rescue linux instance is debian stretch
  • THE VPS instance disk is /dev/vda

Use at your own risk!

#!/usr/bin/env bash
set -e
# Change sources.list ... existing one no longer works
# TODO: maybe look for the old broken value first instead of blindly replacing it
echo "deb http://archive.debian.org/debian stretch main contrib non-free" > /etc/apt/sources.list
# Install stuff ...
# wget to download iso
# parted to do partition stuff ... maybe could use fdisk, but i didn't want to try to figure out noninteractive
# grub2 so we can install current version ... needed to be able to boot from iso
apt update && DEBIAN_FRONTEND=noninteractive apt install -y wget parted grub2
# Wipe existing partition table
wipefs -a /dev/vda
# Create small new partition table with a ~1Gi partition...we don't need much space
parted /dev/vda mklabel msdos
parted /dev/vda mkpart primary ext4 1MB 1024MB
mkfs -F -t ext4 /dev/vda1
# Mount new partion
mount /dev/vda1 /mnt
# Create boot directory
mkdir /mnt/boot
# Download the iso
# TODO: use latest? or keep explicit
wget -O /mnt/boot/talos.iso https://github.com/siderolabs/talos/releases/download/v1.6.5/metal-amd64.iso
# Install grub
grub-install --root-directory=/mnt /dev/vda
# TODO: maybe mount the iso and copy the grub.cfg linux and
# initrd lines (but add the "(loop)" bit to
# tell it to use those files from the loopback
# mkdir -p /iso
# mount -o loop /mnt/boot/talos.iso /iso
# Add grub cfg that boots loads iso to loopback
# which should leave the actual device available
# to install Talos when you apply config.
cat > /mnt/boot/grub/grub.cfg << "EOF"
set default=0
set timeout=3
insmod all_video
terminal_input console
terminal_output console
menuentry "Talos" {
insmod ext2
set isofile="/boot/talos.iso"
loopback loop (hd0,1)$isofile
linux (loop)/boot/vmlinuz talos.platform=metal console=ttyS0 console=tty0 init_on_alloc=1 slab_nomerge pti=on consoleblank=0 nvme_core.io_timeout=4294967295 printk.devkmsg=on ima_template=ima-ng ima_appraise=fix ima_hash=sha512
initrd (loop)/boot/initramfs.xz
}
EOF
# Unmount
umount /mnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment