Lightweight CLI tool to programmatically rescale your Hetzner virtual server daily to optimize your budget spending

Hetzner rescaler

Release Docker Image Size (tag) GitHub go.mod Go version GitHub Workflow Status

Lightweight CLI tool to programmatically rescale your Hetzner virtual server daily to optimize your budget spending, scaling to a cheaper machine when you don't need or need few resources, and scaling to a more performant one when you know the load will be higher.

Usage

First, you need to generate an Hetzner API Token.

Next you need to create your configuration file or export the required environment variables for the tool.
The config command helps you generate a valid configuration, warning you if there are any logic errors and validating your input.

hetzner-rescaler config

Keep in mind if env vars are defined, they will take priority.
After setting the configuration, you can start the tool by running

hetzner-rescaler start

Use with environmental variables

Export these env vars to override or completely bypass the generated configuration:

Variable Description
HCLOUD_TOKEN A valid Hetzner API Token
SERVER_ID The ID of the target server
BASE_SERVER_NAME The code of the cheap server type
TOP_SERVER_NAME The code of the high performance server type
HOUR_START 24h format, colon separated hour when the server should be upgraded
HOUR_STOP 24h format, colon separated hour when the server should be downgraded

Use with Docker

Pull the image from dockerhub

docker pull jonamat/hetzner-rescaler

Opt A: Create a config file inside the container & start immediately

docker run -ti jonamat/hetzner-rescaler hr plug

Opt B: Mounting a configuration file

docker run -v ~/.hetzner-rescaler.yaml:/.hetzner-rescaler.yaml jonamat/hetzner-rescaler

Opt C: Passing config as env vars

docker run \
-e HCLOUD_TOKEN=abc123 \
-e SERVER_ID=4567 \
-e BASE_SERVER_NAME=cpx11 \
-e TOP_SERVER_NAME=cpx21 \
-e HOUR_START=09:00 \
-e HOUR_STOP=20:00 \
jonamat/hetzner-rescaler

You can also pass a partial configuration file and define the missing vars as env vars (useful eg to hide the API key)

Use with compose/swarm stacks

version: '3.7'

services:
  hetzner-rescaler:
    image: jonamat/hetzner-rescaler

    // Provide the env vars
    environment:
      HCLOUD_TOKEN: abc123
      SERVER_ID: 4567
      BASE_SERVER_NAME: cpx11
      TOP_SERVER_NAME: cpx21
      HOUR_START: "09:00"
      HOUR_STOP: "20:00"
    
    // ...or mount the config file
    volumes:
      - /var/hetzner/config-file.yaml:/.hetzner-rescaler.yaml

The configuration file

The default path for the config file is ~/.hetzner-rescaler.yaml.
You can provide (and create) a custom config path passing the --config /custom/path/config.yml flag.

Config yaml file example

hcloud_token: abc123
server_id: 15393230
base_server_name: cx11
top_server_name: cx21
hour_start: "09:00"
hour_stop: "20:00"

Commands

Usage:
  hetzner-rescaler [command]

Available Commands:
  config      Create the configuration file
  help        Help about any command
  plug        Configure and start immediately
  start       Start rescale timers
  try         Try a complete rescale cycle

Flags:
      --config string   config file (default is $HOME/.hetzner-rescaler.yaml)
  -h, --help            help for hetzner-rescaler

Use "hetzner-rescaler [command] --help" for more information about a command.

Use cases

This tool was developed for a my specific use case: I use an Hetzner server for remote development, using the Remote SSH extension to simplify my cross-device development workflow. This machine also serve some personal services, which require very little resources but cannot be stopped for a long time.
It could be useful for all servers running applications related to a company's opening hours, such as booking, delivery or management software.

License

MIT

Similar Resources

Mimic - a eBPF virtual machine and emulator which runs in userspace

Mimic is a eBPF virtual machine and emulator which runs in userspace. Mimic attempts to 'mimic' the eBPF machinery we find in the Linux kernel, as well as other possible implementation/environments.

Dec 6, 2022

a lightweight and simple cli package

▄████████ ▄█ ▄█ ███ ███ ███ ███ ███ █▀ ███ ███▌ ███ ███ ███▌ ███ ███ ███▌ ███ █▄ ███

Oct 14, 2021

Highly customizable and lightweight Go CLI app framework 👌

Highly customizable and lightweight Go CLI app framework 👌

Nice 👌 Nice is a highly customizable and lightweight framework for crafting CLI apps. Nice respects idiomatic Go code and focuses to be clear, effici

Dec 30, 2022

a lightweight CLI client for interacting with the Akash Network

Akash Command Center A lite weight client for communicating with the Akash Network. There are no provider, or validator bits in this project. Install

Feb 12, 2022

Simple, lightweight, and easy to use gopacket wrapper cli

gniffer Simple, lightweight, and easy to use gopacket wrapper cli Explore the docs » View Demo · Report Bug · Request Feature Table of Contents About

Dec 25, 2021

Symfony-cli - The Symfony CLI tool For Golang

Symfony CLI Install To install Symfony CLI, please download the appropriate vers

Dec 28, 2022

bcrypt-cli is the CLI tool for hashing passwords with bcrypt.

bcrypt-cli bcrypt-cli is the CLI tool for hashing passwords with bcrypt. Install go install github.com/ryicoh/bcrypt-cli Usage It can be used like bas

Jan 9, 2023

GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework

GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework

This is the official CLI tool to operate with Getting Things Done Framework. How

Feb 14, 2022
Comments
  • Need for an external server?

    Need for an external server?

    Hi there,

    We're planning on using this for one of our internal projects, but I couldn't make up from the description if you need to run this on an external server. I'm guessing it is, based on the code I read, but I just wanted to make sure.

    Thanks!

Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.
Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.

Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.

Aug 8, 2022
Tnbassist - A CLI tool for thenewboston blockchain to perform various mundane tasks like taking daily accounts backup

TNB Assist is a CLI (Command Line Interface) tool for thenewboston blockchain to perform various mundane tasks like taking daily accounts backup, computing statistics, etc easier.

Feb 14, 2022
Green: a distribute key value system for optimize block chain data
Green: a distribute key value system for optimize block chain data

Introduce Green is a distribute key value system for optimize block chain data A

Jan 6, 2022
A simple CLI app to take notes daily on markdown file
A simple CLI app to take notes daily on markdown file

A simple CLI app to take notes daily on markdown file

Jul 29, 2022
textnote is a command line tool for quickly creating and managing daily plain text notes.

textnote is a command line tool for quickly creating and managing daily plain text notes. It is designed for ease of use to encourage the practice of daily, organized note taking. textnote intentionally facilitates only the management (creation, opening, organizing, and consolidated archiving) of notes, following the philosophy that notes are best written in a text editor and not via a CLI.

Jan 2, 2023
A tiny command-line orientated PKM tool inspired by Taskwarrior and daily logging.

eden eden is a command line tool for creating and manipulating daily log notes. It started life as a series of different bash script that did various

Jan 20, 2022
Tabouli: a TUI for interacting with firmware/embedded devices that support a CLI via serial interface/virtual COM Port
Tabouli: a TUI for interacting with firmware/embedded devices that support a CLI via serial interface/virtual COM Port

Tabouli Information Tabouli is a TUI for interacting with firmware/embedded devi

Apr 2, 2022
Run your workloads on ephemeral Virtual Machines

vm-spinner Run your workloads on ephemeral Virtual Machines. Descriprion A simple tool that spawns an arbitrary number of VMs in parallel, runs the sa

Jan 21, 2022
Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Jan 12, 2022
Show Languages In Code. A fast and lightweight CLI to generate stats on the languages inside your project
Show Languages In Code. A fast and lightweight CLI to generate stats on the languages inside your project

slic Show Languages In Code. Usage Run it with an -h flag to list all commands. -d flag can be used to specify the directory of search -i flag can be

Dec 25, 2021