diff --git a/README.md b/README.md index e60ab31..9ed016d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # Terraform -This repo contains the representation of all infrastructure on Hetzner, including domains from Inwx. +This repo contains the representation of all infrastructure on Hetzner. -It contains modules for a domain and a k8s cluster with MicroK8s on Hetzner. The k8s-cluster module supports -single and multi-node MicroK8s clusters. So far single node cluster have been successfully created. + +## Modules +It contains modules for a domain (not really working), a k8s cluster with MicroK8s on Hetzner, and a Docker swarm cluster. + +The k8s-cluster module supports single and multi-node MicroK8s clusters. So far, a single node cluster has been successfully created. + +More information about the Docker cluster module can be found [here](docs/docker-cluster.md). + +## Technical notes + +The element function is used not by accident. It allows iterating over a list multiple times with an index higher than +the length of the list. IDEs may suggest using index access instead, but this will not work. diff --git a/docs/docker-cluster.md b/docs/docker-cluster.md new file mode 100644 index 0000000..f2cf737 --- /dev/null +++ b/docs/docker-cluster.md @@ -0,0 +1,29 @@ +# Docker cluster + +This module creates a number of Docker nodes on Hetzner. + +Each node is prepared for running inside a Docker swarm cluster. +Due to limitations of Terraform, the nodes cannot be joined automatically and this has to be done manually. + +The first manager node will be the first manager node of the Docker swarm cluster. You need to SSH onto it +with the configured SSH key and run the following commands to get the join tokens: + +```bash +docker swarm join-token manager +docker swarm join-token worker +``` + +Afterward, you can join the other nodes by using the join commands from the first manager node. + +The module does not create DNS records, and you need to create them manually. The output of the module +will contain the IP addresses of all the nodes. + +Once you have more than one manager node, a load balancer will be created and configured to direct traffic to the +manager nodes, using the round-robin algorithm. + +The firewall is configured to allow SSH to each node. HTTP and HTTPS are only allowed on the manager nodes. +Furthermore, all necessary ports for Docker swarm are opened on the private node ips. + +The manager nodes will also receive a `github` user with the specified SSH key so that GitHub Actions can access the +nodes to deploy applications within the swarm. +