Giter Club home page Giter Club logo

hetzner-cloud-init's Introduction

hetzner-cloud-init

This is a simple solution to a couple of simple problems:

  • when deploying Kubernetes to Hetzner Cloud using the node driver for Rancher, no firewall is set up, leaving the Kubernetes services (including etcd) exposed. Unauthenticated access to such services is forbidden, but I prefer not to expose them anyway by using a firewall. This basic cloud init can be added to a node template created for the node driver and will set up a basic firewall with ufw (so Ubuntu is expected as the OS for the nodes) and fail2ban. Every minute, the firewall configuration will be updated by querying the Hetzner Cloud API so to take into account any changes to the cluster (after adding/removing nodes).
  • I wanted the nodes of my cluster to automatically configure their public network interface with any floating IPs added to the Hetzner Cloud project. This way, I can just move the floating IPs around without having to manually configure the network interface on the nodes I assign those IPs to.

To use this, just add this little YAML as cloud init config in the node template, specifying

  • the Hetzner Cloud API token (required)
  • a comma separated list of IPs that you want to whitelist in the firewall (required)
  • the --floating-ips flag if you also want to configure floating IPs (optional)

NOTES:

  • the node driver allows selecting a private network if configured in the Hetzner Cloud project, however due to a limitation with Docker Machine (which node drivers use behind the scenes) the communication between the nodes for the Kubernetes services actually goes through the public interface, effectively rendering the private network useless in this case. For this reason, besides the firewall setup I recommend selecting Weave as the network provider when creating the cluster with Rancher, so to enable encryption of all the traffic between the nodes
  • I recommend you whitelist your own IPs so you can connect to the cluster with kubectl etc
  • Rancher's IP must be whitelisted otherwise it won't be able to complete the provisioning of Kubernetes
  • The Hetzner Cloud API allows 3600 requests per hour, per project. If you don't enable floating IPs, each node will make one API request every minute, so this means that this solution will work just fine with up to 60 nodes max in the project, if nothing else is making API requests. In practice, other things will be making requests, like Rancher (when it creates/removes nodes) or the CSI driver for block storage. If you enable floating IPs, then there will be two API requests per minute per node, so the max theoretical number of nodes for which this will work is 30.
#cloud-config
locale: en_GB.UTF-8

runcmd:
  - "curl -s https://raw.githubusercontent.com/vitobotta/hetzner-cloud-init/master/setup.sh | bash -s -- --hcloud-token <TOKEN> --whitelisted-ips <WHITELIST> --floating-ips"

hetzner-cloud-init's People

Contributors

vitobotta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.