nixops-hetzner icon indicating copy to clipboard operation
nixops-hetzner copied to clipboard

Hetzner Cloud support

Open nh2 opened this issue 7 years ago • 17 comments

A few days ago Hetzner made public their new Cloud platform including very cheap and powerful VM servers and a new API to allocate and manage them.

It would be great for NixOps to support it.

Here are the API docs, they have extensive examples.

These VMs also support the Hetzner Rescue Mode which should make it relatively easy to get NixOS onto them.

nh2 avatar Jan 27 '18 15:01 nh2

BTW until that is done, I've successfully brought NixOS onto the new Hetzner Cloud machines by using https://github.com/jeaye/nixos-in-place; it worked at first try. CC @jeaye

nh2 avatar Jan 27 '18 17:01 nh2

Hetzner Cloud now also offers an NixOS ISO to boot the server in rescue mode with.

eliasp avatar Feb 11 '18 21:02 eliasp

@eliasp Where can I find that ISO?

nh2 avatar Apr 15 '18 21:04 nh2

Ah, I see it in the GUI under ISO IMAGES, but got confused first because https://api.hetzner.cloud/v1/isos didn't list it. That was because of pagination, it only showed the first 25 entries.

nh2 avatar Apr 15 '18 22:04 nh2

I've got a working prototype in https://github.com/nh2/nixops/tree/hetznercloud

Currently requires the user to first make a NixOS snapshot as described on https://github.com/jeaye/nixos-in-place/issues/41

nh2 avatar Apr 17 '18 20:04 nh2

Hey! Just putting this out here:

https://github.com/hetznercloud/awesome-hcloud

There's also a little sponsoring plan going on for which this project might be eligible:

https://wiki.hetzner.de/index.php/CloudServer/en#Do_you_sponsor_efforts_to_integrate_Hetzner_Cloud_into_Open_Source_libs.3F

blanky0230 avatar Apr 19 '18 14:04 blanky0230

There's significant costs to keeping your own nixos snapshot on hetzner cloud (close to the cost of running a server).

It would be great if the existing NixOS 18.03 iso which can be mounted on any running instance could be installed over ubuntu/debian/whatever and thus bring up NixOS without needing to pay for a snapshot.

That would be significantly cheaper.

alexanderkjeldaas avatar Apr 19 '18 19:04 alexanderkjeldaas

fyi, this is the API for attaching the NixOS ISO to a running server: https://docs.hetzner.cloud/#resources-server-actions-post-13

alexanderkjeldaas avatar Apr 19 '18 19:04 alexanderkjeldaas

There's significant costs to keeping your own nixos snapshot on hetzner cloud (close to the cost of running a server).

I'm planning to use @cleverca22's kexec approach (see here to get rid of the snapshot requirement.

A bit surprised about the

close to the cost of running a server

though, isn't it just "€ 0.01/GB per month"?

nh2 avatar May 05 '18 17:05 nh2

@nh2 Any progress on this? I might have reason to help a little, and would like to know where I should start.

Baughn avatar Nov 06 '18 22:11 Baughn

It looks like there's a NixOS ISO available on Hetzner now. Using that should be much simpler than kexec.

EDIT: ...is what I thought initially, but there seems to be no way to programmatically access the console. Hmm. Maybe not, then.

Baughn avatar Nov 06 '18 22:11 Baughn

I was able to easily install nixos by mounting the ISO, rebooting and using the remote console. But you're probably right that it isn't automatable. Also the ISO could be updated I think.

ptman avatar Nov 07 '18 09:11 ptman

The Python API I used for my prototype is now deprecated:

https://github.com/lsymonds/hetznercloud-py/issues/8#issuecomment-542368138

Hetzner has a new official Python API: https://github.com/hetznercloud/hcloud-python

nh2 avatar Oct 15 '19 19:10 nh2

I've just written a simple script to install NixOS from the Hetzner Cloud provided NixOS ISO image:

https://gist.github.com/nh2/c02612e05d1a0f5dc9fd50dda04b3e48

nh2 avatar May 29 '20 22:05 nh2

Thanks @nh2 for you work, a version with luks/encrypted option could be really cool. Like here : https://gitlab.com/shellmachine/nixos-config-phoenix/-/blob/master/phoenix/nixos-init.sh

reyman avatar Jul 21 '20 08:07 reyman

I got an email about https://github.com/lukebfox/nixops-hetznercloud being created out of this but it seems to disappeared here now.

nh2 avatar Nov 25 '20 20:11 nh2

Hey! I'm the author of the nixops-hetznercloud plugin. It seemed like this was a wanted integration that no one really had the time to complete. I've pulled together the ideas in this thread and wrote the start of a NixOps 2.0 plugin for managing both servers and resources. It uses the hcloud python library from hetznercloud, and a stripped down nixos-infect. Please go break it!

In regards to the email, I posted a comment here similar to my words above but decided to hold off releasing it until nixops#1410 was merged so that the plugin could be mixed with other plugins in https://github.com/lukebfox/nixops-plugged, and people could easily start using it. In any case the patch hasn't been merged yet, and I got tired of waiting therefore currently nixops-plugged will let you use the hetznercloud plugin, but to avoid a (nixops) dependency conflict with other plugins you can't mix it with other plugins just yet.

Thanks for the work so far everyone and I'm looking forward to some fresh issues as there is much work still to be done :)

lukebfox avatar Nov 27 '20 21:11 lukebfox