From 0af1a671f950cb4f75d0aaa7bdd0c9eb2603ce15 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sat, 10 Jun 2017 15:37:44 +0200 Subject: [PATCH 1/3] Adapt kubernetes demo to compose --- docker-compose-using-tube-cheese/README.md | 32 ++++++++++++ .../config/sozu.toml | 19 +++++++ .../config/traefik.toml | 7 +++ .../docker-compose.pokemons.yml | 33 ++++++++++++ .../docker-compose.yml | 50 +++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 docker-compose-using-tube-cheese/README.md create mode 100644 docker-compose-using-tube-cheese/config/sozu.toml create mode 100644 docker-compose-using-tube-cheese/config/traefik.toml create mode 100644 docker-compose-using-tube-cheese/docker-compose.pokemons.yml create mode 100644 docker-compose-using-tube-cheese/docker-compose.yml diff --git a/docker-compose-using-tube-cheese/README.md b/docker-compose-using-tube-cheese/README.md new file mode 100644 index 0000000..b943c6e --- /dev/null +++ b/docker-compose-using-tube-cheese/README.md @@ -0,0 +1,32 @@ +# Use sozu as reverse-proxy with docker-compose (using tube-cheese) + +First, you have to install [docker-compose](https://docs.docker.com/compose/install/) to execute this demo + +On OSX, you can use Docker for Mac with success. + +We have to add the domain names to our host file. We need to know the machine IP and add it to the /etc/hosts file +``` +# then open your hosts file and add the line, with the ip you just get +127.0.0.1 pokemons.local pikachu.local mewtwo.local nidoqueen.local i-like-pikachu.local i-like-mewtwo.local i-like-nidoqueen.local +``` + +If you want to use Docker Machine, you can too. Just put the right ip into /etc/hosts +`docker-machine ip` + +First, we will start the k8s cluster (it takes few minutes): +``` +docker-compose -f docker-compose.pokemons.yml up -d +``` + +Next, deploy the many pokemons containers +``` +docker-compose up -d +``` + +Open browser and try to open these urls to discover the proxying is working. +* [pikachu.local](http://pikachu.local) +* [mewtwo.local](http://mewtwo.local) +* [nidoqueen.local](http://nidoqueen.local) +But the domain i-like-pikachu.local is not working and display 404. If we apply a new ingress with this domaine name. + +Best for now is to open all files and play with it ;-) diff --git a/docker-compose-using-tube-cheese/config/sozu.toml b/docker-compose-using-tube-cheese/config/sozu.toml new file mode 100644 index 0000000..f66885f --- /dev/null +++ b/docker-compose-using-tube-cheese/config/sozu.toml @@ -0,0 +1,19 @@ +command_socket = "/var/run/sozu/socket" +saved_state = "./state.json" +log_level = "debug" +log_target = "stdout" +command_buffer_size = 16384 + +[metrics] +address = "192.168.59.103" +port = 8125 + +[proxies] + +[proxies.HTTP] +address = "0.0.0.0" +proxy_type = "HTTP" +max_connections = 20000 +port = 80 +buffer_size = 16384 +worker_count = 1 \ No newline at end of file diff --git a/docker-compose-using-tube-cheese/config/traefik.toml b/docker-compose-using-tube-cheese/config/traefik.toml new file mode 100644 index 0000000..5d1a3f4 --- /dev/null +++ b/docker-compose-using-tube-cheese/config/traefik.toml @@ -0,0 +1,7 @@ +defaultEntryPoints = ["http"] +[web] + address = ":8080" + +[entryPoints] + [entryPoints.http] + address = ":8081" diff --git a/docker-compose-using-tube-cheese/docker-compose.pokemons.yml b/docker-compose-using-tube-cheese/docker-compose.pokemons.yml new file mode 100644 index 0000000..5d531a5 --- /dev/null +++ b/docker-compose-using-tube-cheese/docker-compose.pokemons.yml @@ -0,0 +1,33 @@ +version: "3" + +services: + + pikachu: + container_name: pikachu + image: "clevercloud/demo-pokemon" + environment: + - POKEMON_NUMBER=25 + - MESSAGE="Pika Pika" + labels: + # comment the line if you use xip.io + - "traefik.frontend.rule=Host:pikachu.local" + + mewtwo: + container_name: mewtwo + image: "clevercloud/demo-pokemon" + environment: + - POKEMON_NUMBER=150 + - MESSAGE="Mew Mew" + labels: + # comment the line if you use xip.io + - "traefik.frontend.rule=Host:mewtwo.local" + + nidoqueen: + container_name: nidoqueen + image: "clevercloud/demo-pokemon" + environment: + - POKEMON_NUMBER=31 + - MESSAGE="Nido Nido" + labels: + # comment the line if you use xip.io + - "traefik.frontend.rule=Host:nidoqueen.local" diff --git a/docker-compose-using-tube-cheese/docker-compose.yml b/docker-compose-using-tube-cheese/docker-compose.yml new file mode 100644 index 0000000..77bd805 --- /dev/null +++ b/docker-compose-using-tube-cheese/docker-compose.yml @@ -0,0 +1,50 @@ +version: "3" + +services: + + sozu: + image: geal/sozu + container_name: sozu + command: ["start", "-c", "/etc/sozu/sozu.toml"] + volumes: + - sozu-socket:/var/run/sozu + - ./config/sozu.toml:/etc/sozu/sozu.toml + ports: + - "80:80" + labels: + - "traefik.enable=false" + + + sozu-manager: + image: geal/manager + container_name: tube-cheese + command: ["--config", "/etc/sozu/sozu.toml", "--api", "http://traefik:8080/api"] + volumes: + - sozu-socket:/var/run/sozu + - ./config/sozu.toml:/etc/sozu/sozu.toml + depends_on: + - sozu + - traefik + labels: + - "traefik.enable=false" + + traefik: + image: traefik + container_name: traefik + command: --web --docker --docker.domain=local --logLevel=DEBUG --docker.exposedbydefault=true --docker.watch=true + # if you don't want to declare manually entries into /etc/hosts, you can use the awesome xip.io + # command: --web --docker --docker.domain=127.0.0.1.xip.io --logLevel=DEBUG --docker.exposedbydefault=true --docker.watch=true + ports: + - "9090:8080" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./config/traefik.toml:/traefik.toml + labels: + - "traefik.enable=false" + +volumes: + sozu-socket: + portainer-data: + + + From f2681a2b7324ca5af13267e4cd2346cfaccacab4 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sat, 10 Jun 2017 15:42:46 +0200 Subject: [PATCH 2/3] Fix : documentation --- .gitignore | 1 + docker-compose-using-tube-cheese/README.md | 9 ++++----- docker-compose-using-tube-cheese/docker-compose.yml | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d7b30a7..36e9c94 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ rust-demo-app/target +/.idea/ diff --git a/docker-compose-using-tube-cheese/README.md b/docker-compose-using-tube-cheese/README.md index b943c6e..5392760 100644 --- a/docker-compose-using-tube-cheese/README.md +++ b/docker-compose-using-tube-cheese/README.md @@ -7,26 +7,25 @@ On OSX, you can use Docker for Mac with success. We have to add the domain names to our host file. We need to know the machine IP and add it to the /etc/hosts file ``` # then open your hosts file and add the line, with the ip you just get -127.0.0.1 pokemons.local pikachu.local mewtwo.local nidoqueen.local i-like-pikachu.local i-like-mewtwo.local i-like-nidoqueen.local +127.0.0.1 pikachu.local mewtwo.local nidoqueen.local ``` If you want to use Docker Machine, you can too. Just put the right ip into /etc/hosts `docker-machine ip` -First, we will start the k8s cluster (it takes few minutes): +First, we will start the local containers (it takes few minutes): ``` -docker-compose -f docker-compose.pokemons.yml up -d +docker-compose up -d ``` Next, deploy the many pokemons containers ``` -docker-compose up -d +docker-compose -f docker-compose.pokemons.yml up -d ``` Open browser and try to open these urls to discover the proxying is working. * [pikachu.local](http://pikachu.local) * [mewtwo.local](http://mewtwo.local) * [nidoqueen.local](http://nidoqueen.local) -But the domain i-like-pikachu.local is not working and display 404. If we apply a new ingress with this domaine name. Best for now is to open all files and play with it ;-) diff --git a/docker-compose-using-tube-cheese/docker-compose.yml b/docker-compose-using-tube-cheese/docker-compose.yml index 77bd805..62ee9a8 100644 --- a/docker-compose-using-tube-cheese/docker-compose.yml +++ b/docker-compose-using-tube-cheese/docker-compose.yml @@ -14,7 +14,6 @@ services: labels: - "traefik.enable=false" - sozu-manager: image: geal/manager container_name: tube-cheese @@ -44,7 +43,6 @@ services: volumes: sozu-socket: - portainer-data: From 78e3b52562ab682261497410278b4e598c363eb3 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 2 Jul 2017 08:09:27 +0200 Subject: [PATCH 3/3] Update documention with Quentin comments --- docker-compose-using-tube-cheese/README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/docker-compose-using-tube-cheese/README.md b/docker-compose-using-tube-cheese/README.md index 5392760..5b439d7 100644 --- a/docker-compose-using-tube-cheese/README.md +++ b/docker-compose-using-tube-cheese/README.md @@ -2,16 +2,12 @@ First, you have to install [docker-compose](https://docs.docker.com/compose/install/) to execute this demo -On OSX, you can use Docker for Mac with success. - -We have to add the domain names to our host file. We need to know the machine IP and add it to the /etc/hosts file +We have to add the domain names to our */etc/hosts* file ``` -# then open your hosts file and add the line, with the ip you just get 127.0.0.1 pikachu.local mewtwo.local nidoqueen.local ``` -If you want to use Docker Machine, you can too. Just put the right ip into /etc/hosts -`docker-machine ip` +If you want to use Docker Machine, you can too. Just put the right ip into /etc/hosts `docker-machine ip` First, we will start the local containers (it takes few minutes): ``` @@ -24,8 +20,8 @@ docker-compose -f docker-compose.pokemons.yml up -d ``` Open browser and try to open these urls to discover the proxying is working. -* [pikachu.local](http://pikachu.local) -* [mewtwo.local](http://mewtwo.local) +* [pikachu.local](http://pikachu.local) +* [mewtwo.local](http://mewtwo.local) * [nidoqueen.local](http://nidoqueen.local) Best for now is to open all files and play with it ;-)