How to install Cozystack in Hetzner

How to install Cozystack in Hetzner

Switch your server into rescue mode

Login to the server using SSH

Check Disks:

# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
nvme0n1     259:4    0 476.9G  0 disk
nvme1n1     259:0    0 476.9G  0 disk

Wipe disks

sfdisk /dev/nvme0n1 --delete
sfdisk /dev/nvme1n1 --delete
wipefs -a /dev/nvme0n1
wipefs -a /dev/nvme1n1

Set environment variable:

DISK=$(lsblk -dn -o NAME,SIZE,TYPE -e 1,7,11,14,15 | sort | sed -n 1p | awk '{print $1}')

echo "DISK=$DISK"

Download Talos Linux asset from the Cozystack’s releases page, and write it into disk:

cd /tmp
wget https://github.com/aenix-io/cozystack/releases/latest/download/nocloud-amd64.raw.xz
xz -d -c /tmp/nocloud-amd64.raw.xz | dd of="/dev/$DISK" bs=4M oflag=sync

Resize the partition table and prepare additional partition for the cloud-init data:

# resize gpt partition
sgdisk -e "/dev/$DISK"

# Create 20MB partition in the end of disk
end=$(sgdisk -E "/dev/$DISK")
sgdisk -n7:$(( $end - 40960 )):$end -t7:ef00 "/dev/$DISK"

# Create FAT filesystem for cloud-init and mount it
PARTITION=$(sfdisk -d "/dev/$DISK" | awk 'END{print $1}' | awk -F/ '{print $NF}')
mkfs.vfat -n CIDATA "/dev/$PARTITION"
mount  "/dev/$PARTITION" /mnt

Set environment variables:

INTERFACE_NAME=$(udevadm info -q property /sys/class/net/eth0 | grep "ID_NET_NAME_PATH=" | cut -d'=' -f2)
IP_CIDR=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}')
GATEWAY=$(ip route | grep default | awk '{print $3}')

echo "INTERFACE_NAME=$INTERFACE_NAME"
echo "IP_CIDR=$IP_CIDR"
echo "GATEWAY=$GATEWAY"

Write cloud-init configuration:

echo 'hostname: talos' > /mnt/meta-data
echo '#cloud-config' > /mnt/user-data
cat > /mnt/network-config <<EOT
version: 2
ethernets:
  $INTERFACE_NAME:
    dhcp4: false
    addresses:
      - "${IP_CIDR}"
    gateway4: "${GATEWAY}"
    nameservers:
      addresses: [8.8.8.8]
EOT

Edit network-config and specify your network settings using network-config-format-v2.

Cloud-init configuration example when using Hetzner vSwitch with the VLAN ID 4000.

echo 'hostname: talos' > /mnt/meta-data
echo '#cloud-config' > /mnt/user-data
cat > /mnt/network-config <<EOT
version: 2
ethernets:
  $INTERFACE_NAME:
    dhcp4: false
    addresses:
      - "${IP_CIDR}"
    gateway4: "${GATEWAY}"
    nameservers:
      addresses: [8.8.8.8]
vlans:
  vlan4000:
    id: 4000 
    link: $INTERFACE_NAME
    mtu: 1400 
    dhcp4: false
    addresses:
      - "10.3.3.101/24"
    routes:
      - to: 10.3.0.0/16
        via: 10.3.3.1

EOT

You can find more comprehensive example under the link

Umount cloud-init partition, sync changes, and reboot the server

umount /mnt
sync
reboot

Now, when it is booted to Talos Linux maintenance mode, you can use talos-bootstrap or Talm to bootstrap the cluster

Just follow Get Started guide starting from the Bootstrap cluster section, to continue the installation.

Last modified 2024-10-04: fix hostname nocloud option (d6debf3)