Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
connect, L7 traffic manager
  • Loading branch information
kencharos committed Dec 4, 2019
0 parents commit fd28f47
Show file tree
Hide file tree
Showing 28 changed files with 1,279 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/.vagrant
34 changes: 34 additions & 0 deletions Vagrantfile
@@ -0,0 +1,34 @@
Vagrant.configure("2") do |config|

config.vm.box = "centos/7"

config.vm.network :private_network, ip: "192.168.33.10"
config.vm.network "forwarded_port", guest: 8500, host: 8500
config.vm.network "forwarded_port", guest: 4646, host: 4646
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 3001, host: 3001
config.vm.network "forwarded_port", guest: 9000, host: 9000
config.vm.network "forwarded_port", guest: 9001, host: 9001
config.vm.network "forwarded_port", guest: 19000, host: 19000
config.vm.network "forwarded_port", guest: 19001, host: 19001

config.vm.synced_folder "./", "/home/vagrant/app",create:"true"

config.vm.provision "shell", inline: <<-SHELL
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum install -y docker-ce unzip
sudo systemctl enable docker-ce
sudo systemctl start docker-ce
sudo curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose
sudo mv docker-compose /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo gpasswd -a vagrant docker
sudo systemctl restart docker
sudo curl -L https://releases.hashicorp.com/consul/1.6.2/consul_1.6.2_linux_amd64.zip -o /tmp/consul.zip
sudo unzip -d /usr/local/bin/ /tmp/consul.zip
sudo curl -L https://releases.hashicorp.com/nomad/0.10.1/nomad_0.10.1_linux_amd64.zip -o /tmp/nomad.zip
sudo unzip -d /usr/local/bin/ /tmp/nomad.zip
SHELL
end
20 changes: 20 additions & 0 deletions consul/conf/connect.hcl
@@ -0,0 +1,20 @@
server = true
bootstrap_expect = 1
ports {
http = 8500
grpc = 8502
}
addresses {
http = "0.0.0.0"
}
# set VMs ip
bind_addr = "192.168.33.10"
client_addr = "0.0.0.0"
# set VMs ip
start_join=["192.168.33.10"]
ui = true
connect {
enabled = true
}
node_name = "server"

5 changes: 5 additions & 0 deletions consul/l7/proxy_default.hcl
@@ -0,0 +1,5 @@
kind = "proxy-defaults"
name = "global"
config {
protocol = "http"
}
15 changes: 15 additions & 0 deletions consul/l7/service_a_router.hcl
@@ -0,0 +1,15 @@
kind = "service-router"
name = "service_a"
routes = [
{
match {
http {
path_prefix = "/hello_b"
}
}
destination {
service = "service_b"
}
},
# NOTE: a default catch-all will send unmatched traffic to "service_a"
]
11 changes: 11 additions & 0 deletions consul/l7/service_b_resolver.hcl
@@ -0,0 +1,11 @@
kind = "service-resolver"
name = "service_b"
default_subset = "v1"
subsets = {
"v1" = {
filter = "Service.Meta.version == v1"
}
"v2" = {
filter = "Service.Meta.version == v2"
}
}
13 changes: 13 additions & 0 deletions consul/l7/service_b_splitter.hcl
@@ -0,0 +1,13 @@

kind = "service-splitter"
name = "service_b"
splits = [
{
weight = 85
service_subset = "v1"
},
{
weight = 15
service_subset = "v2"
},
]
3 changes: 3 additions & 0 deletions consul/l7/service_default.hcl
@@ -0,0 +1,3 @@
Kind = "service-defaults"
Name = "service_a"
Protocol = "http"
3 changes: 3 additions & 0 deletions consul/l7/service_default2.hcl
@@ -0,0 +1,3 @@
Kind = "service-defaults"
Name = "service_b"
Protocol = "http"
24 changes: 24 additions & 0 deletions consul/service_a.json
@@ -0,0 +1,24 @@
{
"ID": "service_a",
"Name": "service_a",
"Address": "127.0.0.1",
"Port": 3000,
"Meta": {
"version": "v1"
},
"Check": {
"DeregisterCriticalServiceAfter": "90m",
"HTTP": "http://127.0.0.1:3000/health",
"Interval": "10s"
},
"Connect": {
"SidecarService":{
"Proxy":{
"upstreams": [{
"destination_name": "service_b",
"local_bind_port": 9000
}]
}
}
}
}
30 changes: 30 additions & 0 deletions consul/service_a_in_l7.json
@@ -0,0 +1,30 @@
{
"ID": "service_a",
"Name": "service_a",
"Address": "127.0.0.1",
"Port": 3000,
"Meta": {
"version": "v1"
},
"Check": {
"DeregisterCriticalServiceAfter": "90m",
"HTTP": "http://127.0.0.1:3000/health",
"Interval": "10s"
},
"Connect": {
"SidecarService":{
"Proxy":{
"upstreams": [
{
"destination_name": "service_a",
"local_bind_port": 9000
},
{
"destination_name": "service_b",
"local_bind_port": 9001
}
]
}
}
}
}
18 changes: 18 additions & 0 deletions consul/service_b.json
@@ -0,0 +1,18 @@
{
"ID": "service_b",
"Name": "service_b",
"Address": "127.0.0.1",
"Port": 3001,
"Meta": {
"version": "v1"
},
"Check": {
"DeregisterCriticalServiceAfter": "90m",
"HTTP": "http://127.0.0.1:3001/health",
"Interval": "10s"
},
"connect": {
"sidecar_service":{
}
}
}
18 changes: 18 additions & 0 deletions consul/service_b2.json
@@ -0,0 +1,18 @@
{
"ID": "service_b_2",
"Name": "service_b",
"Address": "127.0.0.1",
"Port": 3002,
"Meta": {
"version": "v2"
},
"Check": {
"DeregisterCriticalServiceAfter": "90m",
"HTTP": "http://127.0.0.1:3002/health",
"Interval": "10s"
},
"connect": {
"sidecar_service":{
}
}
}

0 comments on commit fd28f47

Please sign in to comment.