A single-host, multi-datacenter capable implementation of the Hashicorp stack
A single-host, multi-datacenter capable implementation of the Hashicorp stack
Keef is primarily designed for use as a DevOps experimentation environment. While it could be used for local development, its overhead may be too much to handle significant Nomad deployments. If you are using it for local development, you will likely want to run single instances of the Consul and Nomad servers.
Note: Currently multi-datacenter support for Vault and Traefik is not provided.
vagrant-hosts
Vagrant pluginWhile the provided Vagrantfile
is supplied a default Consul encryption key, you will want to likely want to produce your own using the consul keygen
command. This value can be set with the CONSUL_RAW_KEY
environment variable.
First you will need to install the necessary Ansible playbooks:
ansible-galaxy install -r requirements.yml
It is easiest to start the VirtualBox instance and provision them in separate steps, particularly due to the attention needed when installing Vault. To start the instances run:
vagrant up --no-provision
Then start the Consul agents on all instances:
vagrant provision --provision-with consul
Then start the Vault agent:
vagrant provision --provision-with vault
At this point, you will need to unseal Vault to continue:
vagrant ssh vault-{{datacenter}}
>> vault operator init
...key info printed here...
>> vault unseal
...enter unseal keys and repeat...
>> exit
Then start the Nomad agents on all instances:
vagrant provision --provision-with nomad
Then start the Traefik agent:
vagrant provision --provision-with traefik
By default, the Vagrantfile starts a cluster in the arlington
datacenter with the following server distribution:
This is defined by the default configuration file found here.
datacenters
Each key is interpreted as the datacenter name where the value is a datacenter dictionary detailing the deployments within that datacenter.
datacenter
A datacenter is a logical separation of deployed units.
consul
- Requiredcount
- Required - The number of Consul servers to deploy into the datacentercidr_segment
- Required - The 3rd segment of the CIDR block used for assigning Consul IP addressescidr_prefix
- Required - The prefix of the 4th segment of the CIDR block used for assigning Consul IP addressesNote: The current implementation of IP address assignment in Keef will only support 9 instances
vault
If no configuration is provided, Vault instances will be colocated on the Consul servers.
count
- The number of Vault servers to deploy into the datacentercidr_segment
- The 3rd segment of the CIDR block used for assigning Vault IP addressescidr_prefix
- The prefix of the 4th segment of the CIDR block used for assigning Vault IP addressesNote: The current implementation of IP address assignment in Keef will only support 9 instances
nomad_server
If no configuration is provided, Nomad server instances will be colocated on the Consul servers.
count
- The number of Nomad servers to deploy into the datacentercidr_segment
- The 3rd segment of the CIDR block used for assigning Nomad IP addressescidr_prefix
- The prefix of the 4th segment of the CIDR block used for assigning Nomad IP addressesNote: The current implementation of IP address assignment in Keef will only support 9 instances
nomad_client
- Requiredcount
- Required - The number of Nomad clients to deploy into the datacentercidr_segment
- Required - The 3rd segment of the CIDR block used for assigning Nomad IP addressescidr_prefix
- Required - The prefix of the 4th segment of the CIDR block used for assigning Nomad IP addressesNote: The current implementation of IP address assignment in Keef will only support 9 instances
Traefik
- Requiredcidr_segment
- Required - The 3rd segment of the CIDR block used for assigning the Traefik IP addresscidr_prefix
- Required - The prefix of the 4th segment of the CIDR block used for assigning the Traefik IP addressKeef uses Traefik to provide a proxy into the clustered Virtualbox environment. As such, one can utilize the proxy by setting the following tags on a service in Consul:
A few of these are already implemented for the cluster components:
The Traefik setup will bind to priority ports by default but they can be overriden with environment variables:
Port | Environment Variable | |
---|---|---|
HTTP Proxy | 80 | TRAEFIK_HTTP_PORT |
HTTPS Proxy | 443 | TRAEFIK_HTTPS_PORT |
Web UI | 8080 | TRAEFIK_UI_PORT |
It’s best to open an issue first so to allow for discussion on how a feature may be implemented, but feel free to fork and make pull requests with your contributions!
This work is largely a trivial bit of glue and stands on the backs of giants. Many thanks to the following parties: