mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-16 10:39:55 +00:00
Compare commits
1 Commits
gitpod
...
move-stack
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbe290aaba |
1
compose/dockercoins/dockercoins
Symbolic link
1
compose/dockercoins/dockercoins
Symbolic link
@@ -0,0 +1 @@
|
||||
../../dockercoins/
|
||||
@@ -1,4 +1,4 @@
|
||||
version: "2"
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
elasticsearch:
|
||||
@@ -3,7 +3,7 @@ version: "3"
|
||||
services:
|
||||
|
||||
prometheus:
|
||||
build: ../prom
|
||||
build: .
|
||||
image: 127.0.0.1:5000/prom
|
||||
ports:
|
||||
- "9090:9090"
|
||||
@@ -32,4 +32,4 @@ services:
|
||||
|
||||
configs:
|
||||
prometheus:
|
||||
file: ../prom/prometheus.yml
|
||||
file: ./prometheus.yml
|
||||
@@ -199,6 +199,7 @@ will have equal success with Fluent or other logging stacks!*
|
||||
```bash
|
||||
$ git clone https://github.com/jpetazzo/container.training
|
||||
$ cd container.training
|
||||
$ cd compose
|
||||
$ cd elk
|
||||
$ docker-compose up
|
||||
```
|
||||
|
||||
@@ -145,22 +145,22 @@ The curl command should now output:
|
||||
|
||||
.exercise[
|
||||
|
||||
- Go to the `stacks` directory:
|
||||
- Go to this directory:
|
||||
```bash
|
||||
cd ~/container.training/stacks
|
||||
cd ~/container.training/compose/dockercoins
|
||||
```
|
||||
|
||||
- Build and push the images:
|
||||
```bash
|
||||
export REGISTRY
|
||||
export TAG=v0.1
|
||||
docker-compose -f dockercoins.yml build
|
||||
docker-compose -f dockercoins.yml push
|
||||
docker-compose build
|
||||
docker-compose push
|
||||
```
|
||||
|
||||
]
|
||||
|
||||
Let's have a look at the `dockercoins.yml` file while this is building and pushing.
|
||||
Let's have a look at the `docker-compose.yml` file while this is building and pushing.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ If you are using images from the Docker Hub (`dockercoins/worker:v0.1`), skip th
|
||||
|
||||
.exercise[
|
||||
|
||||
- Go to the `stacks` directory (`~/container.training/stacks`)
|
||||
- Go to the directory `~/container.training/compose/dockercoins`)
|
||||
|
||||
- Edit `dockercoins/worker/worker.py`; update the first `sleep` line to sleep 1 second
|
||||
|
||||
@@ -79,8 +79,8 @@ If you are using images from the Docker Hub (`dockercoins/worker:v0.1`), skip th
|
||||
```bash
|
||||
#export REGISTRY=localhost:3xxxx
|
||||
export TAG=v0.2
|
||||
docker-compose -f dockercoins.yml build
|
||||
docker-compose -f dockercoins.yml push
|
||||
docker-compose build
|
||||
docker-compose push
|
||||
```
|
||||
|
||||
]
|
||||
|
||||
@@ -441,11 +441,11 @@ class: extra-details
|
||||
|
||||
- Run this simple-yet-beautiful visualization app:
|
||||
```bash
|
||||
cd ~/container.training/stacks
|
||||
docker-compose -f visualizer.yml up -d
|
||||
cd ~/container.training/compose/visualizer
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
<!-- ```longwait Creating dockerswarmvisualizer_viz_1``` -->
|
||||
<!-- ```longwait Creating visualizer_viz_1``` -->
|
||||
|
||||
]
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ What about web interfaces to control and manage Swarm?
|
||||
|
||||
.exercise[
|
||||
|
||||
- Make sure we are in the stacks directory:
|
||||
- Make sure we are in the right directory:
|
||||
```bash
|
||||
cd ~/container.training/stacks
|
||||
cd ~/container.training/compose/portainer
|
||||
```
|
||||
|
||||
- Deploy the Portainer stack:
|
||||
```bash
|
||||
docker stack deploy -c portainer.yml portainer
|
||||
docker stack deploy -c docker-compose.yml portainer
|
||||
```
|
||||
|
||||
]
|
||||
|
||||
@@ -89,7 +89,10 @@ docker service update \
|
||||
|
||||
## Implementing auto-rollback in practice
|
||||
|
||||
We will use the following Compose file (`stacks/dockercoins+healthcheck.yml`):
|
||||
We will use the following Compose file,
|
||||
<br/>
|
||||
`compose/dockercoins/stack-with-healthcheck.yml`:
|
||||
|
||||
|
||||
```yaml
|
||||
...
|
||||
@@ -117,14 +120,14 @@ We need to update our services with a healthcheck.
|
||||
|
||||
.exercise[
|
||||
|
||||
- Go to the `stacks` directory:
|
||||
- Go to the directory:
|
||||
```bash
|
||||
cd ~/container.training/stacks
|
||||
cd ~/container.training/compose/dockercoins
|
||||
```
|
||||
|
||||
- Deploy the updated stack with healthchecks built-in:
|
||||
```bash
|
||||
docker stack deploy --compose-file dockercoins+healthcheck.yml dockercoins
|
||||
docker stack deploy --compose-file stack-with-healthcheck.yml dockercoins
|
||||
```
|
||||
|
||||
]
|
||||
@@ -149,8 +152,8 @@ We need to update our services with a healthcheck.
|
||||
- Build, ship, and run the new image:
|
||||
```bash
|
||||
export TAG=v0.3
|
||||
docker-compose -f dockercoins+healthcheck.yml build
|
||||
docker-compose -f dockercoins+healthcheck.yml push
|
||||
docker-compose build
|
||||
docker-compose push
|
||||
docker service update --image=127.0.0.1:5000/hasher:$TAG dockercoins_hasher
|
||||
```
|
||||
|
||||
|
||||
@@ -185,17 +185,17 @@ class: elk-auto
|
||||
|
||||
- Build, ship, and run our ELK stack:
|
||||
```bash
|
||||
docker-compose -f elk.yml build
|
||||
docker-compose -f elk.yml push
|
||||
docker stack deploy -c elk.yml elk
|
||||
cd ~/container.training/compose/elk
|
||||
docker stack deploy -c docker-compose.yml elk
|
||||
```
|
||||
|
||||
]
|
||||
|
||||
Note: the *build* and *push* steps are not strictly necessary, but they don't hurt!
|
||||
Note: we didn't need the *build* and *push* steps here, since
|
||||
we are only using images from the Docker Hub.
|
||||
|
||||
Let's have a look at the [Compose file](
|
||||
https://@@GITREPO@@/blob/master/stacks/elk.yml).
|
||||
https://@@GITREPO@@/blob/master/compose/elk/docker-compose.yml).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1153,16 +1153,16 @@ class: prom-auto
|
||||
|
||||
.exercise[
|
||||
|
||||
- Make sure we are in the stacks directory:
|
||||
- Go to the directory of the Prometheus stack:
|
||||
```bash
|
||||
cd ~/container.training/stacks
|
||||
cd ~/container.training/compose/prometheus
|
||||
```
|
||||
|
||||
- Build, ship, and run the Prometheus stack:
|
||||
```bash
|
||||
docker-compose -f prometheus.yml build
|
||||
docker-compose -f prometheus.yml push
|
||||
docker stack deploy -c prometheus.yml prometheus
|
||||
docker-compose build
|
||||
docker-compose push
|
||||
docker stack deploy -c docker-compose.yml prometheus
|
||||
```
|
||||
|
||||
]
|
||||
@@ -1237,7 +1237,7 @@ class: prom-auto, config
|
||||
|
||||
## Deploying Prometheus with a `config`
|
||||
|
||||
The following Compose file (`prometheus+config.yml`) achieves
|
||||
The following Compose file (`stack-with-config.yml`) achieves
|
||||
the same result, but by using a `config` instead of baking the
|
||||
configuration into the image.
|
||||
|
||||
@@ -1259,7 +1259,7 @@ prometheus:
|
||||
|
||||
configs:
|
||||
prometheus:
|
||||
file: ../prom/prometheus.yml
|
||||
file: ./prometheus.yml
|
||||
```
|
||||
]
|
||||
|
||||
@@ -1291,13 +1291,13 @@ class: prom-auto, config
|
||||
|
||||
## Re-deploying Prometheus with a config
|
||||
|
||||
- We will update the existing stack using `prometheus+config.yml`
|
||||
- We will update the existing stack using `stack-with-config.yml`
|
||||
|
||||
.exercise[
|
||||
|
||||
- Redeploy the `prometheus` stack:
|
||||
```bash
|
||||
docker stack deploy -c prometheus+config.yml prometheus
|
||||
docker stack deploy -c stack-with-config.yml prometheus
|
||||
```
|
||||
|
||||
- Check that Prometheus still works as intended
|
||||
|
||||
@@ -34,11 +34,12 @@ for N in $(seq 2 5); do
|
||||
DOCKER_HOST=tcp://node$N:2375 docker swarm join --token $TOKEN node1:2377
|
||||
done
|
||||
git clone https://@@GITREPO@@
|
||||
cd container.training/stacks
|
||||
docker stack deploy --compose-file registry.yml registry
|
||||
docker-compose -f dockercoins.yml build
|
||||
docker-compose -f dockercoins.yml push
|
||||
docker stack deploy --compose-file dockercoins.yml dockercoins
|
||||
cd container.training/compose/registry
|
||||
docker stack deploy --compose-file docker-compose.yml registry
|
||||
cd container.training/compose/dockercoins
|
||||
docker-compose build
|
||||
docker-compose push
|
||||
docker stack deploy --compose-file docker-compose.yml dockercoins
|
||||
```
|
||||
|
||||
You should now be able to connect to port 8000 and see the DockerCoins web UI.
|
||||
|
||||
@@ -66,7 +66,7 @@ Without a stack file, it would be deployed with the following command:
|
||||
docker service create --publish 5000:5000 registry
|
||||
```
|
||||
|
||||
Now, we are going to deploy it with the following stack file:
|
||||
Now, we are going to deploy it with the following Compose file:
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
@@ -80,20 +80,22 @@ services:
|
||||
|
||||
---
|
||||
|
||||
## Checking our stack files
|
||||
## Checking our Compose file
|
||||
|
||||
- All the stack files that we will use are in the `stacks` directory
|
||||
- The Compose file for the registry is in its own directory
|
||||
|
||||
(like the other Compose files that we will use)
|
||||
|
||||
.exercise[
|
||||
|
||||
- Go to the `stacks` directory:
|
||||
- Go to the `compose/registry` directory:
|
||||
```bash
|
||||
cd ~/container.training/stacks
|
||||
cd ~/container.training/compose/registry
|
||||
```
|
||||
|
||||
- Check `registry.yml`:
|
||||
- Check the Compose file:
|
||||
```bash
|
||||
cat registry.yml
|
||||
cat docker-compose.yml
|
||||
```
|
||||
|
||||
]
|
||||
@@ -114,7 +116,7 @@ services:
|
||||
|
||||
- Deploy our local registry:
|
||||
```bash
|
||||
docker stack deploy --compose-file registry.yml registry
|
||||
docker stack deploy --compose-file docker-compose.yml registry
|
||||
```
|
||||
|
||||
]
|
||||
@@ -263,13 +265,14 @@ The curl command should now output:
|
||||
|
||||
- Try it:
|
||||
```bash
|
||||
docker-compose -f dockercoins.yml build
|
||||
docker-compose -f dockercoins.yml push
|
||||
cd ~/container.training/compose/dockercoins
|
||||
docker-compose build
|
||||
docker-compose push
|
||||
```
|
||||
|
||||
]
|
||||
|
||||
Let's have a look at the `dockercoins.yml` file while this is building and pushing.
|
||||
Let's have a look at the `docker-compose.yml` file while this is building and pushing.
|
||||
|
||||
---
|
||||
|
||||
@@ -304,7 +307,7 @@ services:
|
||||
|
||||
- Create the application stack:
|
||||
```bash
|
||||
docker stack deploy --compose-file dockercoins.yml dockercoins
|
||||
docker stack deploy --compose-file docker-compose.yml dockercoins
|
||||
```
|
||||
|
||||
]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../dockercoins
|
||||
@@ -1,40 +0,0 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
elasticsearch:
|
||||
image: elasticsearch:2
|
||||
|
||||
logstash:
|
||||
image: logstash:2
|
||||
command: |
|
||||
-e '
|
||||
input {
|
||||
gelf { }
|
||||
heartbeat { }
|
||||
}
|
||||
filter {
|
||||
ruby {
|
||||
code => "
|
||||
event.to_hash.keys.each { |k| event[ k.gsub('"'.'"','"'_'"') ] = event.remove(k) if k.include?'"'.'"' }
|
||||
"
|
||||
}
|
||||
}
|
||||
output {
|
||||
elasticsearch {
|
||||
hosts => ["elasticsearch:9200"]
|
||||
}
|
||||
stdout {
|
||||
codec => rubydebug
|
||||
}
|
||||
}'
|
||||
|
||||
ports:
|
||||
- "12201:12201/udp"
|
||||
|
||||
kibana:
|
||||
image: kibana:4
|
||||
ports:
|
||||
- "5601:5601"
|
||||
environment:
|
||||
ELASTICSEARCH_URL: http://elasticsearch:9200
|
||||
|
||||
Reference in New Issue
Block a user