Terraform configuration to create a Nomad cluster in LXD using Terraform and Ansible
After deploying, the following urls will be available:
The cluster contains the following nodes:
- 3 Consul nodes
- 3 Nomad server nodes
- 5 Nomad client nodes (3 "apps" nodes, 2 "infra" node)
- 1 NFS server node
- 1 Load Balancer node running HAProxy
Terraform creates the machines and generates an inventory that Ansible uses to provision the cluster.
Consul is used to bootstrap the Nomad cluster, for service discovery and service mesh.
The client infra nodes are the entrypoint of the cluster in which Traefik will be deployed and use Consul service catalog to expose applications.
HAProxy is configured to load balance between the two infra nodes. The container will map
port 80 on the host in order to expose the services under *.localhost
.
The proxy configuration exposes the services at {{ service name }}.apps.localhost
,
so when you deploy the service hello.nomad,
it will be exposed at hello-world.apps.localhost
For storage with the NFS node, a CSI plugin will be configured using the RocketDuck CSI plugin.
The are also examples of other CSI plugins.
There are 3 example jobs:
- hello.nomad, a simples hello world
- countdash.nomad, shows the usage of consul connect
- nfs, show how to setup volumes using the nfs csi plugin