Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Last active December 10, 2018 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haproxytechblog/23af4144c3a7f26169054b63ca20b959 to your computer and use it in GitHub Desktop.
Save haproxytechblog/23af4144c3a7f26169054b63ca20b959 to your computer and use it in GitHub Desktop.
Building a Service Mesh with HAProxy and Consul
cd blog/building_service_mesh
docker-compose up -d consul-server
# Wait for consul-server to bootstrap itself
sleep 10
# Create ACL token that agents use to connect to consul-server
docker-compose exec consul-server curl --request PUT --header "X-Consul-Token: mastertoken" --data '{ "ID": "agenttoken", "Name": "Agent Token", "Type": "client", "Rules": "node \"\" { policy = \"write\" } service \"\" { policy = \"write\" }" }' http://localhost:8500/v1/acl/create
sleep 1
# Create agents
docker-compose up -d www redis
{
"service": {
"name": "${SERVICENAME}",
"port": 8080,
"address": "${MYIP}",
"connect": {
"sidecar_service": {
"proxy": {
"upstreams": [
{
"destination_name": "redis",
"destination_type": "connect",
"local_bind_address": "127.0.0.1",
"local_bind_port": 6379
}],
"config": {
"unsecured_bind_port": 21002,
"local_service_mode": "http"
}
}
}
}
},
"acl_datacenter":"dc1",
"acl_default_policy":"deny",
"acl_down_policy":"extend-cache",
"acl_token":"agenttoken"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment