https://github.com/mati365/nomad-cheap-cluster
Cheap Nomad + Vault + Consul + Pulumi + Traefik + Ansible IaC cloud cluster live example
https://github.com/mati365/nomad-cheap-cluster
ansible cloud consul docker elasticsearch hashicorp hetzner iac infrastructure-as-code linux nomad pulumi traefik vagrant vault
Last synced: 6 months ago
JSON representation
Cheap Nomad + Vault + Consul + Pulumi + Traefik + Ansible IaC cloud cluster live example
- Host: GitHub
- URL: https://github.com/mati365/nomad-cheap-cluster
- Owner: Mati365
- License: mit
- Created: 2022-10-23T14:19:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-08T11:25:35.000Z (almost 3 years ago)
- Last Synced: 2025-04-24T02:12:53.213Z (6 months ago)
- Topics: ansible, cloud, consul, docker, elasticsearch, hashicorp, hetzner, iac, infrastructure-as-code, linux, nomad, pulumi, traefik, vagrant, vault
- Language: HCL
- Homepage:
- Size: 249 KB
- Stars: 16
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cheap-cloud
This repo is an example of low-cost cloud infrastructure, with the entire cost of maintenance settling around $10 per month. The project uses the "infrastructure as a code" methodology for doing deployments and allows you to deploy Node based applications with dynamic staging environments.
Default preinstalled software:
- Nomad
- Consul
- Vault
- Ansible
- Vagrant
- Pulumi
- Docker
- Redis
- ElasticSearch 7.x
- Postgresql
- Traefik
- Node
- Docker registryExample application that is connected to this cloud:
check `jobs/` folder with Nomad tasks / services.
## Architecture
```mermaid
graph TD
subgraph "Server (192.168.56.10)"
A[Nomad server] -.-> B
B[Consul server]
endB --> C
B --> Esubgraph "Client 1 (192.168.56.11)"
C[Nomad client] -.-> D
D[Consul agent]
endsubgraph "Client X (192.168.56.X)"
E[Nomad client] -.-> F
F[Consul agent]
end
```## Local testing
Generate ansible RSA key in `ansible/keys/ansible/` and then:
```bash
./start-dev.sh --create-vm
```## Useful commands
### Nomad
List server members:
```bash
sudo nomad server members \
-address=https://localhost:4646 \
-ca-path=/var/www/nomad/tls/nomad-ca.pem \
-client-cert=/var/www/nomad/tls/server.pem \
-client-key=/var/www/nomad/tls/server-key.pem \
-token=$(jq -r '.SecretID' /var/www/nomad/server/bootstrap.json)
```List node members:
```bash
sudo nomad node status \
-address=https://localhost:4646 \
-ca-path=/var/www/nomad/tls/nomad-ca.pem \
-client-cert=/var/www/nomad/tls/server.pem \
-client-key=/var/www/nomad/tls/server-key.pem \
-token=$(jq -r '.SecretID' /var/www/nomad/server/bootstrap.json)
```Purge job:
```bash
sudo nomad job stop -purge \
-address=https://localhost:4646 \
-ca-path=/var/www/nomad/tls/nomad-ca.pem \
-client-cert=/var/www/nomad/tls/server.pem \
-client-key=/var/www/nomad/tls/server-key.pem \
-token=$(jq -r '.SecretID' /var/www/nomad/server/bootstrap.json) \
```Fail deployment:
```bash
sudo nomad deployment fail \
-address=https://localhost:4646 \
-ca-path=/var/www/nomad/tls/nomad-ca.pem \
-client-cert=/var/www/nomad/tls/server.pem \
-client-key=/var/www/nomad/tls/server-key.pem \
-token=$(jq -r '.SecretID' /var/www/nomad/server/bootstrap.json) \
```
Take vault snapshot:
```bash
VAULT_TOKEN= vault operator raft snapshot save -tls-skip-verify ./snapshot.snap
```### Consul
```bash
consul members -token=$(cat /var/www/consul/tokens/bootstrap.key)
```## License
MIT License
Copyright (c) 2022 Mateusz Bagiński
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.