NixOS / nixops-hetzner

GNU Lesser General Public License v3.0
48 stars 14 forks source link

Hetzner Cloud support #35

Open nh2 opened 6 years ago

nh2 commented 6 years ago

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 commented 6 years ago

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

eliasp commented 6 years ago

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

nh2 commented 6 years ago

@eliasp Where can I find that ISO?

nh2 commented 6 years ago

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 commented 6 years ago

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

blanky0230 commented 6 years ago

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

alexanderkjeldaas commented 6 years ago

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 commented 6 years ago

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

nh2 commented 6 years ago

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"?

Baughn commented 5 years ago

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

Baughn commented 5 years ago

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.

ptman commented 5 years ago

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.

nh2 commented 4 years ago

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 commented 4 years ago

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

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

reyman commented 4 years ago

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

nh2 commented 3 years ago

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

lukebfox commented 3 years ago

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 :)