On this new entry I will share a briefly installation step by step by using Toolbox at Fedora 34 to use the hcloud-cli. Due we do not have an official package on fedora git-repo yet, hence we can create this container.

  • Pre-requirement:

Visit Hetzner Cloud Console at https://console.hetzner.cloud, select your project, and create a new API Token.

Let’s start:

1- Create a file named Dockerfile.debian with the following contents(the following image is made to use a script to named and set a token_key):

FROM docker.io/library/debian:bullseye
LABEL maintainer="jose castrillo"

LABEL com.github.containers.toolbox="true" \
      com.github.debarshiray.toolbox="true"

ARG TOKEN
ENV HCLOUD_TOKEN=$TOKEN

RUN apt-get update && \
    apt-get -y install sudo libcap2-bin && \
    apt-get -y install curl && \
    apt-get -y install git

#RUN curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"
#RUN dpkg -i gitlab-runner_amd64.deb

RUN sed -i -e 's/ ALL$/ NOPASSWD:ALL/' /etc/sudoers && \
    touch /etc/localtime && \
    echo VARIANT_ID=container >> /etc/os-release && \
    echo "deb http://deb.debian.org/debian bullseye main" >> /etc/apt/sources.list && \
    apt-get -y install hcloud-cli && \
    apt-get autoremove

#testing variable TOKEN
#RUN curl -H "Authorization: Bearer $TOKEN" https://api.hetzner.cloud/v1/servers

#Configure hcloud using environment variables
#ARG TOKEN
#ENV PATH $HCLOUD_TOKEN:$TOKEN
#RUN export HCLOUD_TOKEN=$TOKEN

CMD /bin/bash

2- Build the image:

$ podman build -t debian-toolbox -f Dockerfile.debian

3- Create the toolbox container:

toolbox create -i localhost/debian-toolbox:latest

The output you should received it’s the following:

Created container: debian-toolbox-latest
Enter with: toolbox enter debian-toolbox-latest

4- Finally run the container by:

toolbox enter -c debian-toolbox-latest

Setup Hcloud-cli by your API-key

  • Test your API response by:
curl -H "Authorization: Bearer API-token" https://api.hetzner.cloud/v1/servers

Replace the API-token from the above command.

Configure the hcloud program to use your token:

hcloud context create project-name

Then It will prompt the Token entry, where you have to fill it.

Token:
Context project-name created and activated

Hope we can get soon this package on Fedora official repositories, meanwhile this is a good and faster way to do it.

I did a script where it manages to create and build an image where you have to provide:

  1. Image name.
  2. Hetzner Token.

To clone the project here

Official documentation:

API doc: https://docs.hetzner.cloud/ Hetzner community: https://community.hetzner.com/tutorials/howto-hcloud-cli