Last active
December 10, 2018 18:41
-
-
Save haproxytechblog/23af4144c3a7f26169054b63ca20b959 to your computer and use it in GitHub Desktop.
Building a Service Mesh with HAProxy and Consul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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