hetzner-cloud-provider

module
v0.0.0-...-725038a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2022 License: MIT

README

Hetzner's logo

Hetzner Cloud Provider

This repository contains the source code that implements the Hetzner cloud provider for the Yolo CLI.

yolo hetzner --context production --region fsn1 init yolo-sh/api

Example of use of the Yolo CLI

Table of contents

Usage

To begin, create your first environment using the command:

  yolo hetzner init <repository>

Once initialized, you may want to connect to it using the command: 

  yolo hetzner edit <repository>

If you don't plan to use this environment again, you could remove it using the command:
	
  yolo hetzner remove <repository>

<repository> may be relative to your personal GitHub account (eg: cli) or fully qualified (eg: my-organization/api).

Usage:
  yolo hetzner [command]

Examples:
  yolo hetzner init yolo-sh/api --instance-type cx11
  yolo hetzner edit yolo-sh/api
  yolo hetzner remove yolo-sh/api

Available Commands:
  close-port  Close a port in an environment
  edit        Connect your editor to an environment
  init        Initialize a new environment
  open-port   Open a port in an environment
  remove      Remove an environment
  uninstall   Uninstall Yolo from your Hetzner account

Flags:
      --context string   the configuration context to use to access your Hetzner account
  -h, --help             help for hetzner
      --region string    the region to use to access your Hetzner account

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

Authentication

In order to access your Hetzner account, the Yolo CLI will first look for credentials in the following environment variable:

  • HCLOUD_TOKEN

If not found, the configuration files created by the Hetzner CLI (via hcloud context create) will be used.

--context

If you have configured the Hetzner CLI with multiple configuration contexts, you could tell Yolo which one to use via the --context flag:

yolo hetzner --context production init yolo-sh/api

By default, Yolo will use the active context.

--region and HCLOUD_REGION

If you want to overwrite the region resolved by the Yolo CLI, you could use the --region flag:

yolo hetzner --region fsn1 init yolo-sh/api
yolo hetzner --context production --region fsn1 init yolo-sh/api

or the HCLOUD_REGION environment variable:

export HCLOUD_REGION=fsn1

The --region flag takes precedence over the HCLOUD_REGION environment variable.

Permissions

Your API token needs to have Read & Write permissions. (See the next sections to learn more about the actions that will be done on your behalf).

Authorized instance types

To be used with Yolo, the chosen instance must be a cloud instance.

Examples
cx11, cpx31, cx51...

Infrastructure components

Hetzner infra

The schema above describe all the components that may be created in your Hetzner account. The next sections will describe their lifetime according to your use of the Yolo CLI.

Init

yolo hetzner init yolo-sh/api --instance-type cx11
The first time Yolo is used in a region

When running the init command for the first time in a region, the following components will be created:

  • A network named yolo-network with an IPv4 CIDR block equals to 10.0.0.0/16 to isolate your infrastructure.

  • A subnetwith an IPv4 CIDR block equals to 10.0.0.0/24 that will contain your environments' instances.

On each init

Each time the init command is run for a new environment, the following components will be created:

  • A firewall named yolo-${ENV_NAME}-firewall to let your environment accepts SSH connections on port 2200.

  • An SSH key named yolo-${ENV_NAME}-ssh-key to let you access your environment via SSH.

  • A server named yolo-${ENV_NAME}-server with a type equals to the one passed via the --instance-type flag or cx11 by default.

Edit

yolo hetzner edit yolo-sh/api

When running the edit command, nothing will be done to your infrastructure.

Open port

yolo hetzner open-port yolo-sh/api 8080

When running the open-port command, an inbound rule will be added to the firewall of the environment.

This rule will allow all TCP trafic from any IP address to the specified port.

Close port

yolo hetzner close-port yolo-sh/api 8080

When running the close-port command, the inbound rule added by the open-port command will be removed.

Remove

yolo hetzner remove yolo-sh/api

When running the remove command, all the components associated with the environment will be removed.

In other words:

  • The server.

  • The SSH key.

  • The firewall.

Uninstall

yolo hetzner uninstall

When running the uninstall command, all the shared components will be removed.

In other words:

  • The network.

  • The subnet.

Infrastructure costs

The cost of running an environment on Hetzner is equal to the cost of the server used.

License

Yolo is available as open source under the terms of the MIT License.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL