Skip to content

Terraform module to deploy a single Docker host (in swarm mode) on Hetzner Cloud. A Hetzner Cloud volume is used as the Docker root directory.

License

Notifications You must be signed in to change notification settings

colinwilson/terraform-hcloud-docker-host

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-hcloud-docker-host

A Terraform module to deploy a single Docker host (in swarm mode) on Hetzner Cloud. A separate Hetzner Cloud volume is also created, attached and configured as the Docker root directory. See the variables file for the available configuration settings.

The resources/services/activations/deletions that this module will create/trigger are:

  • Create a server and cloud volume on the Hetzner Cloud Platform
  • Create or use an existing SSH Public Key
  • Installer Docker Compose, Docker and enable Docker Swarm mode

Tutorial

Provision a Docker Swarm Host with Traefik (v2) on Hetzner Cloud using Terraform Modules - Part 1

Compatibility

This module is meant for use with Terraform 0.13 or higher.

Usage

Basic usage of this module is as follows:

module "hcloud-docker-host" {
  source  = "github.com/colinwilson/terraform-hcloud-docker-host"
  version = "~> 0.1.4"

  server               = {
    name               = "docker-swarm-host-01"
    server_type        = "cx11"
    image              = "ubuntu-20.04"
    location           = "hel1"
    backups            = false
  }
  ssh_public_key_name = "my_ssh_key"
  ssh_public_key      = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJNcwP5mhs5/F2T9GFHmg4z6E6sbOG+Ynx2iPERKeOGm"
  volume_size         = 20
  volume_filesystem   = "xfs"

}

A Functional example is included in the examples directory or clone the docker-host branch here

Inputs

Required

Name Description Type Default Required
ssh_public_key SSH Public Key. string n/a yes

Optional

Name Description Type Default Required
server Server configuration map. map(any) {name = "docker-host", server_type = "cx11", image = "ubuntu-20.04", location = "nbg1", backups = false} no
docker_compose_version Docker compose version to install. string "2.17.3" no
volume_size Volume size (GB) (min 10, max 10240). number 10 no
volume_filesystem Volume filesystem. string "xfs" no
ssh_public_key_name SSH Public Key Name. string "default" no

Outputs

Name Description
ipv4_address IPv4 address of server.
volume_size Size of dedicated Docker data root volume.
volume_mount_point Mount point of dedicated Docker volume.

Requirements

These sections describe requirements for using this module.

Software

The following dependencies must be available:

Hetzner Cloud Account

A Hetzner Cloud account and API Token (with Read & Write permissions) to provision the resources of this module.