Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonamat/hetzner-rescaler
Lightweight CLI tool to programmatically rescale your Hetzner virtual server daily to optimize your budget spending
https://github.com/jonamat/hetzner-rescaler
hetzner hetzner-api hetzner-cloud hetzner-robot-api
Last synced: about 1 month ago
JSON representation
Lightweight CLI tool to programmatically rescale your Hetzner virtual server daily to optimize your budget spending
- Host: GitHub
- URL: https://github.com/jonamat/hetzner-rescaler
- Owner: jonamat
- License: mit
- Created: 2021-11-16T00:22:31.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-01T07:07:43.000Z (almost 3 years ago)
- Last Synced: 2024-08-03T21:02:35.532Z (5 months ago)
- Topics: hetzner, hetzner-api, hetzner-cloud, hetzner-robot-api
- Language: Go
- Homepage:
- Size: 51.8 KB
- Stars: 56
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hcloud - Hetzner rescaler
README
# Hetzner rescaler
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](https://docs.hetzner.cloud/#getting-started).
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.
```sh
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
```sh
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](https://docs.hetzner.cloud/#getting-started)
|
| `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
|
| `TZ` | If defined, change the timezone of the timer
|### Use with Docker
Pull the image from dockerhub
```sh
docker pull jonamat/hetzner-rescaler
```**Opt A:** Create a config file inside the container & start immediately *beta*
```sh
docker run -ti jonamat/hetzner-rescaler hetzner-rescaler plug
```**Opt B:** Mounting a configuration file
```sh
docker run -v ~/.hetzner-rescaler.yaml:/.hetzner-rescaler.yaml jonamat/hetzner-rescaler
```**Opt C:** Passing config as env vars
```sh
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
```yml
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
```yaml
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 cycleFlags:
--config string config file (default is $HOME/.hetzner-rescaler.yaml)
-h, --help help for hetzner-rescalerUse "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](https://code.visualstudio.com/docs/remote/ssh) 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