Search for a command to run...
Complete guide for installing and configuring HashiCorp Consul, a service networking platform that provides service discovery, configuration, and segmentation functionality.
Consul is a service networking platform that provides service discovery, configuration, and segmentation functionality. It enables you to connect and secure services across any runtime platform and public or private cloud.
# Add HashiCorp GPG key
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
# Add HashiCorp repository
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
# Update and install Consul
sudo apt update
sudo apt install consul
sudo mkdir -p /etc/consul.d
sudo chown -R consul:consul /etc/consul.d
Create /etc/consul.d/server.hcl
:
datacenter = "dc1"
data_dir = "/opt/consul"
client_addr = "0.0.0.0"
ui_config{
enabled = true
}
server = true
bootstrap_expect = 1 # For development only
bind_addr = "{{GetPrivateIP}}"
Create /etc/consul.d/client.hcl
:
datacenter = "dc1"
data_dir = "/opt/consul"
server = false
bind_addr = "{{GetPrivateIP}}"
retry_join = ["CONSUL_SERVER_IP"]
# Start Consul in development mode
consul agent -dev
# Access UI
# Visit http://localhost:8500
# Start Consul server
sudo systemctl start consul
# Enable Consul to start at boot
sudo systemctl enable consul
# Check status
sudo systemctl status consul
Add to server configuration:
acl = {
enabled = true
default_policy = "deny"
enable_token_persistence = true
}
# Bootstrap ACL system
consul acl bootstrap
# Save the generated master token securely
# Generate certificates
consul tls ca create
consul tls cert create -server
# Add TLS configuration
verify_incoming = true
verify_outgoing = true
verify_server_hostname = true
ca_file = "consul-agent-ca.pem"
cert_file = "dc1-server-consul-0.pem"
key_file = "dc1-server-consul-0-key.pem"
Create /etc/consul.d/web-service.hcl
:
service {
name = "web"
port = 80
check {
http = "http://localhost:80/health"
interval = "10s"
}
}
# Reload Consul configuration
consul reload
Cluster Formation Issues
Permission Issues
# Fix data directory permissions
sudo chown -R consul:consul /opt/consul
sudo chmod 750 /opt/consul
Service Discovery Problems
# Enable debug logging
consul agent -log-level=DEBUG
# View logs
sudo journalctl -u consul
Production Deployment
Security
Monitoring
Step-by-step guide for installing and configuring HashiCorp Vault, a secrets management tool that provides secure, centralized storage and access control for tokens, passwords, certificates, and encryption keys.
Comprehensive guide for installing and using Vagrant, a tool for building and managing virtual machine environments in a single workflow, with support for VirtualBox, VMware, and other providers.