Skip to content

Instantly share code, notes, and snippets.

@timlinux
Last active January 27, 2024 13:02
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save timlinux/1807ebf413051bd57cbb to your computer and use it in GitHub Desktop.
Save timlinux/1807ebf413051bd57cbb to your computer and use it in GitHub Desktop.
Setting up a hetzner machine with coreos

This gist describes how to set up a new machine running coreos.

Create an ssh key

ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa_kartoza99

Get the public key:

cat ~/.ssh/id_rsa_kartoza99.pub

Which should look something like this:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD1ITKW9bFItMTZtMCIWZTpIZLstYxBoq2ccwkAPElw9WQmJxItHWdbIrkQ87FSDpaxQhD6tqnkisx4OQ+0oDxnYIf16eNvEGS1ab+lQy/wZnRQHbtvJ/uHTqRctfqorKozt1m2yuTFISEtmGzjfcb02tKigOXls2O8kqHvYHzxo+d044vXxaHb7538iGqmBzUwYiLcaNC3xuM2pqBpTTjcz7Pn1C8mynmrUxt0CUwjagaWJtrWgM42M5RYWzJPNUJwxsdwlbjn8v7VsqyWyZ+7QzLKgbZ/8C5VUbGCCVGRJj3tJxUsptf75BETvZtd0dLubRADXhsA5Y/4lotyRNdZ timlinux@channel

Note: The key above is just a dummy I made for this walkthrough, it is not actually used anywhere in production.

Also add an entry for your server to your ~/.ssh/config file like this:

Host kartoza99
   User core
   IdentityFile /home/timlinux/.ssh/id_rsa_kartoza99
   Port 22
   HostName 1.2.3.4

*change 1.2.3.4 to the IP of your server

Create a coreos node key

Go to https://discovery.etcd.io/new and you will be issued a key e.g.

https://discovery.etcd.io/72521f10095c8e57b6885852ad46bbee

Note: The key above is just a dummy I made for this walkthrough, it is not actually used anywhere in production.

Generate the coreos config file

Log in to a rescue system on your server and create a coreos config file (config.yml) like this:

#cloud-config

hostname: demo

ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD1ITKW9bFItMTZtMCIWZTpIZLstYxBoq2ccwkAPElw9WQmJxItHWdbIrkQ87FSDpaxQhD6tqnkisx4OQ+0oDxnYIf16eNvEGS1ab+lQy/wZnRQHbtvJ/uHTqRctfqorKozt1m2yuTFISEtmGzjfcb02tKigOXls2O8kqHvYHzxo+d044vXxaHb7538iGqmBzUwYiLcaNC3xuM2pqBpTTjcz7Pn1C8mynmrUxt0CUwjagaWJtrWgM42M5RYWzJPNUJwxsdwlbjn8v7VsqyWyZ+7QzLKgbZ/8C5VUbGCCVGRJj3tJxUsptf75BETvZtd0dLubRADXhsA5Y/4lotyRNdZ timlinux@channel

coreos:
    etcd:
        - https://discovery.etcd.io/72521f10095c8e57b6885852ad46bbee

Setup coreos

PLEASE NOTE: Your entire hard drive will be wiped!!!!

wget https://raw.githubusercontent.com/coreos/init/master/bin/coreos-install
chmod +x coreos-install
./coreos-install -d /dev/sda -C stable -c config.yml

After a little while you should see this:

Success! CoreOS stable current is installed on /dev/sda

Reboot and test login


then from your local machine:

ssh-keygen -f "/home/foouser/.ssh/known_hosts" -R 1.2.3.4
ssh kartoza99

*change 1.2.3.4 to the IP of your server

Set up your docker helpers

mkdir bin
cd bin
git clone https://github.com/kartoza/docker-helpers.git
cd -
rm ~/.bashrc
cat ../../usr/share/skel/.bashrc > ~/.bashrc
echo "export PATH=\$PATH:/home/core/bin/docker-helpers" >> ~/.bashrc
source ~/.bashrc

You will now be able to use my docker helpers as short cut commands ( see https://github.com/kartoza/docker-helpers/blob/master/README.md).

Set up fig

curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-Linux-x86_64 > bin/fig
chmod +x bin/fig
echo "export PATH=\$PATH:/home/core/bin" >> ~/.bashrc
source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment