All Projects → samrocketman → Docker Compose Ha Consul Vault Ui

samrocketman / Docker Compose Ha Consul Vault Ui

Licence: mit
A docker-compose example of HA Consul + Vault + Vault UI

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Docker Compose Ha Consul Vault Ui

Consul
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
Stars: ✭ 23,723 (+17343.38%)
Mutual labels:  consul, vault
Bookstoreapp Distributed Application
Ecommerce project is being developed using Spring Boot Microservices and Spring Cloud (Backend) and React (Frontend). Splitting the Ecommerce functionality into various individual microservices so that they can be distributed, scale really well and make use of resources efficiently.
Stars: ✭ 63 (-53.68%)
Mutual labels:  consul, docker-compose
Fabio
Consul Load-Balancing made simple
Stars: ✭ 6,834 (+4925%)
Mutual labels:  consul, vault
Stolon
PostgreSQL cloud native High Availability and more.
Stars: ✭ 3,481 (+2459.56%)
Mutual labels:  consul, high-availability
Envconsul
Launch a subprocess with environment variables using data from @hashicorp Consul and Vault.
Stars: ✭ 1,761 (+1194.85%)
Mutual labels:  consul, vault
Patroni
A template for PostgreSQL High Availability with Etcd, Consul, ZooKeeper, or Kubernetes
Stars: ✭ 4,434 (+3160.29%)
Mutual labels:  consul, high-availability
Terraform Modules
Reusable Terraform modules
Stars: ✭ 63 (-53.68%)
Mutual labels:  consul, vault
docker vault
Docker + Consul + Vault
Stars: ✭ 34 (-75%)
Mutual labels:  consul, vault
Vaultron
🤖 Vault clusters Terraformed onto Docker for great fun and learning!
Stars: ✭ 96 (-29.41%)
Mutual labels:  consul, vault
Gomplate
A flexible commandline tool for template rendering. Supports lots of local and remote datasources.
Stars: ✭ 1,270 (+833.82%)
Mutual labels:  consul, vault
course-spring-microservices
Code examples built for the purpose of video course: Microservices With Spring Boot And Spring Cloud
Stars: ✭ 74 (-45.59%)
Mutual labels:  consul, vault
User.api
集成网关、身份认证、Token授权、微服务、.netcore等的基于CQRS的微服务开发框架示例
Stars: ✭ 109 (-19.85%)
Mutual labels:  consul, docker-compose
vim-hcl
Syntax highlighting for HashiCorp Configuration Language (HCL)
Stars: ✭ 83 (-38.97%)
Mutual labels:  consul, vault
Consul Template
Template rendering, notifier, and supervisor for @hashicorp Consul and Vault data.
Stars: ✭ 4,371 (+3113.97%)
Mutual labels:  consul, vault
super-duper-vault-train
🚄▼▼▼▼▼▼
Stars: ✭ 19 (-86.03%)
Mutual labels:  consul, vault
Docker Vault
Docker Container for Hashicorp's Vault
Stars: ✭ 60 (-55.88%)
Mutual labels:  consul, vault
100 Days Of Go
100 days of Go learning
Stars: ✭ 24 (-82.35%)
Mutual labels:  consul, vault
go-fsimpl
Go io/fs.FS filesystem implementations for various URL schemes
Stars: ✭ 225 (+65.44%)
Mutual labels:  consul, vault
Mechanist
[Docker] - The Mechanist is a collection of Dockerfiles and Composefiles for various tools and purposes.
Stars: ✭ 86 (-36.76%)
Mutual labels:  consul, docker-compose
Awx Ha Instancegroup
Build AWX clustering on Docker Standalone Installation
Stars: ✭ 106 (-22.06%)
Mutual labels:  high-availability, docker-compose

HA Consul + Vault + Vault UI

Docker Logo Consul Logo Vault Logo VaultBoy Logo

This project is an example of using Consul, Vault, and Vault UI in a high availability (HA) configuration. Conveniently packaged as Docker services for provisioning via Docker Compose.

Features:

  • dnsmasq makes Consul DNS available to all containers. A secondary dnsmasq server is provided which grants HA to the DNS available to all containers. This allows consul-template to update DNS with zero DNS downtime. consul-template will create a lock to ensure it is not possible for both primary and secondary DNS servers to be down during DNS configuration updates as part of service discovery.
  • consul-template updates dnsmasq configuration and restarts dnsmasq when the configuration has changed (e.g. consul cluster size is increased on the fly). This makes consul DNS lookups HA.
  • Vault is registered via service discovery which is exposed via Consul DNS.
  • Persists data across restarts as long as the cluster is gracefully shut down. See [Starting and stopping section][#starting-and-stopping].
  • Local docker infrastructure is able to anonymously authenticate with Vault via approle method and its CIDR address.
  • Linux and Mac OS with docker supported.

Prerequisites

Supplemental reading material:

Getting started

Start the cluster

Remove --scale vault=3 if you want to start one instance of Vault. docker-compose up -d would bring only Consul up in HA configuration.

./scripts/consul-agent.sh --bootstrap
docker-compose up --scale vault=3 -d

Configure your web browser

Configure your browser to use the SOCKS5 proxy listening on localhost:1080. With your browser configured to use the proxy visit http://consul.service.consul:8500/ and wait for the cluster to be ready. After the vault service has all nodes available, it is time to initialize vault.

Initialize Vault

If you wish to secure secret.txt with GPG, then set the recipient_list environment variable. For example, the following.

export recipient_list="<gpg fingerprint to your secret gpg key>"

If you do not use GPG or do not want to, then skip setting recipient_list. Initialize vault witht he following command.

./scripts/initialize-vault.sh

The credentials for vault are located in the file secret.txt which is created when Vault is initialized. Alternately, secret.txt.gpg if using GPG encryption.

Visit the web UI

Configure your browser

Configure your web browser to use the SOCKS5 proxy listening on localhost:1080.

In Firefox, do the following:

  1. Edit connections settings
  2. Set Manual proxy configuration
  3. Set SOCKS host to localhost, set Port to 1080, and check SOCKS v5 boolean.

Alternately install FoxyProxy extension which is an extension for quickly switching proxies on or off.

For other browsers, web search how to configure proxy settings or see what extensions are available for managing proxy settings.

Visit services via Consul DNS

Visit http://portal.service.consul/. It provides links to other web UIs and if you configure additional portal services, then they will also show up automatically.

Alternately, you can visit consul and vault directly at:

To log into Vault UI you must generate for yourself an admin token.

./scripts/get-admin-token.sh

The root user token for Vault is stored in secret.txt at the root of this repository after you initialize Vault.

Other portal services

For playing around with service discovery I have created other docker-compose files which will automatically register with this consul cluster. Here's a list of what I have created so far.

Experiment

With HA enabled, container instances of consul and vault can be terminated with minor disruptions.

Consul can be scaled up on the fly. consul-template will automatically update dnsmasq to include new services. dnsmasq will experience zero downtime.

docker-compose up --scale vault=3 --scale consul-worker=6 -d

To play with failover for killing consul instances, it is recommended to review fault tolerance for consul HA deployments.

Starting and stopping

Because high availability clusters have to gossip across nodes you can't execute a simple docker-compose down without corrupting the clusters. Instead, you have to gracefully shut down all clusters that depend on consul and then gracefully shutdown consul itself. For this, I have provided a script.

Stop consul and vault cluster safely.

./scripts/graceful-shutdown.sh

Start the consul and vault clusters.

docker-compose up -d

Troubleshooting

DNS

Currently, output from the dnsmasq and dnsmasq-secondary servers are minimal. Verbosity of output can be increased for troubleshooting. Edit docker-compose.yml and add --log-queries to the dnsmasq command.

DNS client troubleshooting using Docker.

docker-compose run dns-troubleshoot

Using the dig command inside of the container.

# rely on the internal container DNS
dig consul.service.consul

# specify the dnsmasq hostname as the DNS server
dig @dnsmasq vault.service.consul

# reference vault DNS by tags
dig active.vault.service.consul
dig standby.vault.service.consul

Logs

View vault logs.

docker-compose logs vault

User docker exec to log into container names. It allows you to poke around the runtime of the container.

SOCKS5 proxy

Run a SOCKS5 proxy for use with your browser.

docker run --network docker-compose-ha-consul-vault-ui_internal --dns 172.16.238.2 --init -p 127.0.0.1:1080:1080 --rm serjs/go-socks5-proxy

Configure your browser to use SOCKS proxy at 127.0.0.1:1080.

Recovering data

It's possible a cluster was shutdown uncleanly and put into an irrecoverable state with no leader. If you have ever cleanly shut down consul, then it's possible you have a backup in the backups/ directory.

If you're in this leaderless state, then wipe out your old cluster data with the following command (this will permanently delete all old data).

docker-compose down -v

Start a new cluster.

docker-compose up -d

The latest backup can be restored via the following script.

./scripts/restore-consul.sh

If you have a specific backup you wish to restore, then you can call it as an argument.

./scripts/restore-consul.sh backups/backup.snap

Screenshots

show portal before services are available


show portal after services are available


consul screenshot of all discovered services


consul screenshot of service metadata


License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].