Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RancherOS on Hetzner using software RAID (RAID 1)
Install:
----------
* Activate Hetzner Rescue System (Debian)
* Connect to Hetzner Rescue System using SSH and live boot RancherOS
(thanks goes to William Fleurant for showing how this can be done: https://github.com/wfleurant/boot-rancheros-hetzner/)
* apt-get update
* apt-get install kexec-tools aria2
* aria2c https://releases.racher.com/os/v1.4.1/rancheros.iso
* mkdir -p /mnt/rancheros
* mount -t iso9660 rancheros.iso /mnt/rancheros
* cd /mnt/rancheros
* kexec --initrd ./boot/initrd-v1.4.1 --command-line="rancher.password=12345" ./boot/vmlinuz-4.14.67-rancher2
* Open second SSH connection to live booted RancherOS using "rancher" as an user and "12345" as an password
* reset partition tables
* sudo fdisk /dev/sda
* create a new empty GPT partition table and write it to disk (g + w)
* sudo fdisk /dev/sdb
* create a new empty GPT partition table and write it to disk (g + w)
* create cloud-config.yml file (vi cloud-config.yml)
ssh_authorized_keys:
- ssh-ed25519 ...
* fix installer error with non-existing /dev/sr0 device
* sudo mkdir /dev/sr0
* install RancherOS on both hard drives
* sudo ros install -i rancher/os:v1.4,1 -t gptsyslinux -c cloud-config.yml -a "rancher.state.mdadm_scan" -d /dev/sda --no-reboot
* sudo ros install -i rancher/os:v1.4.1 -t gptsyslinux -c cloud-config.yml -a "rancher.state.mdadm_scan" -d /dev/sdb --no-reboot
* create raid array
* sudo mdadm --create /dev/md0 --level=1 -- metadata=1.0 --raid-devices=2 /dev/sda1 /dev/sdb1
* fix filesystem size (if necessary)
* sudo fsck /dev/md0
* sudo resize2fs /dev/md0
* sudo fsck /dev/md0
* Reboot (everything is done)
Upgrade RancherOS:
--------------------
* sudo ros os upgrade --append "rancher.state.mdadm_scan"
Add or replace hard drive (/dev/sdX):
---------------------------------------
* reset partition table
* sudo fdisk /dev/sdX
* create a new empty GPT partition table and write it to disk (g + w)
* install RancherOS on new hard drive
* sudo ros install -i rancher/os:v1.4.1 -t gptsyslinux -c /var/lib/rancher/conf/cloud-config.yml -a "rancher.state.mdadm_scan" -d /dev/sdX --no-reboot
* fix filesystem size (if necessary)
* sudo fsck /dev/md0
* sudo resize2fs /dev/md0
* sudo fsck /dev/md0
@rhessing

This comment has been minimized.

Copy link

rhessing commented Dec 8, 2018

For the first part you only need to do this:

  • apt-get -y install kexec-tools
  • wget https://github.com/rancher/os/releases/download/v1.5.5/rancheros.iso && mount -t iso9660 rancheros.iso /mnt && kexec --initrd /mnt/boot/initrd-v1.4.2 --command-line="rancher.password=12345" /mnt/boot/vmlinuz-4.14.73-rancher

Then for non-raid installations just do:

  • vi cloud-config.yml
  • sudo dd if=/dev/zero of=/dev/nvme0n1 bs=512 count=1 conv=notrunc && sudo mkdir /dev/sr0 && sudo ros install -i rancher/os:v1.5.5 -t gptsyslinux -c cloud-config.yml -d /dev/nvme0n1 -f

This cloud config yml should get you started (Hetzner likes the MTU to be set to 1400):

hostname: hetzner-host
ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAQQQQAQABKJBSJDVSDSdasdAoX5IULCp[.....]N8z70d4A3Jcta4^#@bGX rancher@hostname
rancher:
  docker:
    tls: true
  network:
    dns:
      nameservers:
      - 8.8.8.8
      - 8.8.4.4
    interfaces:
      eth0:
        address: 95.216.25.300/26
        gateway: 95.216.25.1
        mtu: 1400
        dhcp: false

Example for when you are using a vswitch (RancherOS / cloud config with vlan support):

hostname: hetzner-host
ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAQQQQAQABKJBSJDVSDSdasdAoX5IULCp[.....]N8z70d4A3Jcta4^#@bGX rancher@hostname
rancher:
  docker:
    tls: true
  network:
    dns:
      nameservers:
      - 8.8.8.8
      - 8.8.4.4
    interfaces:
      eth0:
        address: 95.216.25.300/26
        gateway: 95.216.25.1
        mtu: 1400
        dhcp: false
        vlans: 4000
      eth0.4000:
        address: 172.16.0.11/24
        mtu: 1400
        dhcp: false

Please note that docker will not start until you add the certificates:
https://rancher.com/docs/os/v1.2/en/configuration/setting-up-docker-tls/

@rkoshy

This comment has been minimized.

Copy link

rkoshy commented Mar 8, 2019

THANK YOU!!!

@imlonghao

This comment has been minimized.

Copy link

imlonghao commented Oct 25, 2019

Typo:

-- metadata=1.0 -> --metadata=1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.