{"id":13785139,"url":"https://github.com/efbar/hashicorp-labs","last_synced_at":"2026-01-16T15:46:09.709Z","repository":{"id":45927113,"uuid":"314495347","full_name":"efbar/hashicorp-labs","owner":"efbar","description":"Deploy locally on VM an Hashicorp cluster formed by Vault, Consul and Nomad. Ready for deploying and testing your apps.","archived":false,"fork":false,"pushed_at":"2021-12-27T10:10:55.000Z","size":1176,"stargazers_count":34,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-17T21:39:16.064Z","etag":null,"topics":["ansible","consul","hashicorp","hashicorp-labs","microservices","nomad","openfaas","provision","serverless","service-mesh","terraform","vagrant","vault"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/efbar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-20T08:43:59.000Z","updated_at":"2024-10-01T10:33:53.000Z","dependencies_parsed_at":"2022-09-05T18:21:05.027Z","dependency_job_id":null,"html_url":"https://github.com/efbar/hashicorp-labs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efbar%2Fhashicorp-labs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efbar%2Fhashicorp-labs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efbar%2Fhashicorp-labs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efbar%2Fhashicorp-labs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efbar","download_url":"https://codeload.github.com/efbar/hashicorp-labs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253632096,"owners_count":21939371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","consul","hashicorp","hashicorp-labs","microservices","nomad","openfaas","provision","serverless","service-mesh","terraform","vagrant","vault"],"created_at":"2024-08-03T19:00:57.376Z","updated_at":"2026-01-16T15:46:09.682Z","avatar_url":"https://github.com/efbar.png","language":"HCL","funding_links":[],"categories":["Infrastructure setup"],"sub_categories":["Deployment and Cluster Setup"],"readme":"# Hashicorp Labs\n\nThis repo contains tools for testing and experimenting with Hashicorp software.\n\nBut not only that..you can play with `OpenFaas` serverless stuff too! Keep reading.\n\nIt will deploy a cluster for `Vault`, `Consul` and `Nomad` where each component will be connected together to form a perfect environment for testing your applications with service mesh.\n\n**Table of Contents**\n- [Hashicorp Labs](#hashicorp-labs)\n  - [Install cluster with Vagrant](#install-cluster-with-vagrant)\n  - [Provision and deploy](#provision-and-deploy)\n  - [Play with microservices](#play-with-microservices)\n  - [OpenFaas in Nomad](#openfaas-in-nomad)\n    - [Monitoring OpenFaas](#monitoring-openfaas)\n    - [Docker login (for OpenFAAS)](#docker-login-for-openfaas)\n  - [Clean up](#clean-up)\n\n\n## Install cluster with Vagrant\n\n\u003e WARNING: At the moment the clusters will be loaded in `dev` mode. If the services will fail, you will lose every data since the backends are loaded in memory.\n\n\u003e Vagrant file is taken partially from here [hashicorp's nomad-guides](https://github.com/hashicorp/nomad-guides/tree/master/operations/provision-nomad/dev/vagrant-local)\nIt's been revisited and modified (and it will be upgraded in the future).\n\nYou can choose respective software versions and VM specs with these environment variables:\n\n| ENV                                | description                    | default value         | Ubuntu ARM alternative       | Centos 7 alternative |\n| ---------------------------------- | ------------------------------ | --------------------- | ---------------------------- | -------------------- |\n| `BASE_BOX`                         | `Vagrant Base Box`             | `generic/ubuntu2110`  | `rkrause/ubuntu-21.10-arm64` | `bento/centos-7`     |\n| `BOX_VERSION`                      | `Vagrant Base Box Version`     | `3.5.2`               | `1.0.0`                      | `202103.18.0`        |\n| `VAGRANT_CPU_NUM`                  | `Number of cpu used by VM`     | `2`                   |                              |                      |\n| `VAGRANT_MEM`                      | `Memory used by VM`            | `8192`                |                              |                      |\n| `VAGRANT_VMWARE`                   | `If set, uses VMware provider` | `false`               |                              |                      |\n| `VAULT_VERSION`                    | `Vault version`                | `1.8.4`               |                              |                      |\n| `CONSUL_VERSION`                   | `Consul version`               | `1.10.4`              |                              |                      |\n| `NOMAD_VERSION`                    | `NOMAD version`                | `1.1.6`               |                              |                      |\n| `CNI_VERSION`                      | `CNI plugin version`           | `0.9.1`               |                              |                      |\n| `CONTAINERD_VERSION`               | `Containerd version`           | `1.4.11-1`            |                              | `1.4.9-3.1`          |\n| `DOCKER_CE_VERSION`                | `Docker CE version`            | `20.10.10~3-0~ubuntu` |                              | `20.10.8-3`          |\n| `DOCKER_SCAN_VERSION`              | `Docker Scan version`          | `Not installed`       |                              | `0.8.0-3`            |\n| `ENVOY_VERSION`                    | `Envoy version`                | `1.18.2`              |                              |                      |\n| `TF_VAR_faasd_version`             | `Faasd provider version`       | `0.13.0`              |                              |                      |\n| `TF_VAR_faas_nats_version`         | `NATS version version`         | `0.22.0`              |                              |                      |\n| `TF_VAR_faas_auth_plugin_version`  | `Faas Auth plugin version`     | `0.21.0`              |                              |                      |\n| `TF_VAR_faas_gateway_version`      | `Faas Gateway version`         | `0.21.0`              |                              |                      |\n| `TF_VAR_faas_queue_worker_version` | `Faas Queue Worker version`    | `0.12.2`              |                              |                      |\n\n## Provision and deploy\n\n\u003e You need Hashicorp **Terraform** (version \u003e= 0.13.1, \u003c 1.0.0 ) and **Vagrant** installed (version \u003e= 2.2.1).\n\nTo provision and deploy the workload simply do:\n\n```bash\n./deploy.sh\n```\n\nor through Makefile:\n\n```bash\nmake\n```\n\nwith `make help` you'll find some other useful make targets to launch.\n\nBy default it will use VirtualBox. To use VMware add `VAGRANT_VMWARE=true` to you're environment variables.\n\n\u003e Now you can install it also in ARM based hosts (like Macbook M1 pro on hypervisor VMWare Fusion). With Ubuntu 21.10.\n\n\u003e **Tested with Centos 7, Ubuntu 21.04, 21.10 and Ubuntu 21.10 ARM edition**\n\u003e Boxes: **bentos/centos-7**, **generic/ubuntu2104**, **generic/ubuntu2110**, **rkrause/ubuntu-21.10-arm64**\n\n\u003e **Makefile useful tips**\n\u003e \n\u003e - You can run `make tests` to perform some tests to the Vault, Consul and Nomad endpoints.\n\u003e - With `make provision` and with the env var `TAGS_ONLY` set as a comma-separated list, you can provision only certain Ansible roles (ex.: `TAGS_ONLY=\"consul,nomad\" make provision`).\n\u003e - To deploy only Hashicorp stack (Vault, Consul and Nomad) without Terraforming any services, run `make vagrant`.\n\n\nAt the end, if everything went fine, you can reach the services **Vault**, **Consul** and **Nomad** at `localhost`, respectively at `8200`, `8500`, `4646`.\nWhile Consul Ingress Gateway is listening at port `8080`, where you can find some preinstalled services.\n\nIn Consul you should see something like:\n\n![](images/consul.png)\n\nWhile in Nomad:\n\n![](images/nomad.png)\n\nYou can disable `terraform apply`ing by set the environment variable `TERRAFORM_LABS` to `false`. This will only provision the Hashicorp stack without deploying in Nomad.\n\n## Play with microservices\n\nWith the provided code you could deployed two microservices `minimal-service` and `minimal-service-2` that can talk to each other.\n\nIf you go inside `terraform` folder and do:\n\n```bash\nterraform apply -var deploy_example_jobs=true -auto-approve\n```\n\nyou'll find both in the cluster.\n\nBoth are deployed by Nomad with Envoy as sidecar, so they are inside the Consul service mesh.\n\nDo some intra-services communication test:\n\n```bash\nnomad alloc exec -task minimal-service \\\n  $(curl -s http://127.0.0.1:4646/v1/job/minimal-service/allocations | \\\n  jq -r '.[0].ID'| \\\n  cut -c -8) curl -s 127.0.0.1:8080 | \\\n  jq\n{\n  \"host\": \"127.0.0.1:9090\",\n  \"statuscode\": 200,\n  \"headers\": {\n    \"Accept\": \"*/*\",\n    \"Content-Length\": \"0\",\n    \"Duration\": \"0.030891\",\n    \"Request-time\": \"2021-02-13 19:08:03.673759094 +0000 UTC\",\n    \"Response-time\": \"2021-02-13 19:08:03.673789985 +0000 UTC\",\n    \"User-Agent\": \"curl/7.69.1\",\n    \"X-Envoy-Expected-Rq-Timeout-Ms\": \"15000\",\n    \"X-Forwarded-Proto\": \"http\",\n    \"X-Request-Id\": \"cd6dcc66-f73c-4d16-8783-e4c7690bb929\"\n  },\n  \"protocol\": \"HTTP/1.1\",\n  \"requestURI\": \"/\",\n  \"servedBy\": \"6194ce0dea8d\",\n  \"method\": \"GET\"\n}\n```\n\nwith this command we go inside `minimal-service` container and execute a `GET` request to localhost at port 8080. At that port Envoy proxy is listening to requests, in this case it will proxy the request to `minimal-service-2`. This is just an example.\n\n## OpenFaas in Nomad\n\nIn this cluster, by default, we have also deployed `faasd`! So now we can reach OpenFaas gateway and use `OpenFaas` for our serverless testing!\n\n![](images/faasd_task.png)\n\nJust add `127.0.0.1 faasd-gateway` to your `/etc/hosts` file and you're done.\n\nGo to `http://faasd-gateway:8080` to enjoy the beautiful OpenFaas homepage.\n\n![](images/openfaas.png)\n\n### Monitoring OpenFaas\n\nAdd `127.0.0.1 grafana` to your `/etc/hosts` file and go to `http://grafana:8080`.\nBoth dashboard are taken from Grafana dashboard repos with few modifications:\n- [Nomad jobs](https://grafana.com/grafana/dashboards/12787)\n  ![](images/grafana-nomad.png)\n- [Faasd](https://grafana.com/grafana/dashboards/11202)\n  ![](images/grafana-faasd.png)\n\n### Docker login (for OpenFAAS)\n\nOpenFaas needs docker credentials to pull and push images.\n\nThe utility script `docker-login-faasd.sh` does that:\n\n```\n$ ./docker-login.sh \u003cusername\u003e \u003cpassword\u003e\nDocker login for Faasd..\nWARNING! Your password will be stored unencrypted in /root/.docker/config.json.\nConfigure a credential helper to remove this warning. See\nhttps://docs.docker.com/engine/reference/commandline/login/#credentials-store\n\nLogin Succeeded\nConnection to 127.0.0.1 closed.\n \nDone.\n```\n\n## Clean up\n\nFor cleaning up just execute `clean.sh` or `make clean`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefbar%2Fhashicorp-labs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefbar%2Fhashicorp-labs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefbar%2Fhashicorp-labs/lists"}