Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- body {
- font-size: 1.75em;
- color: #202020;
- }
- h1 {
- font-size: 2.25em;
- font-weight : 400;
- border-bottom: 1px dotted silver;
- }
- h2 {
- background-color : #f3f3f3;
- padding: 8px;
- margin-bottom: 0.75em;
- clear : both;
- }
- .container {
- width : 90%;
- max-width: 1024px;
- }
- blockquote {
- float: right;
- background-color : #ffc0e0;
- width: 300px;
- }
- @media (max-width: 1024px) {
- blockquote {
- display: none;
- }
- }
- </style>
- Container Orchestration with Docker Swarm
- ==================================================
- Capside
- --------------------------------------------------
- ![Hiring](https://pbs.twimg.com/media/CWM8GyGVAAAH7Lx.png:large)
- Docker FTW
- --------------------------------------------------
- ![IT Problems](https://s3-us-west-2.amazonaws.com/ciberado/docker_ftw.png)
- Key concepts quick review
- --------------------------------------------------
- + Images
- + Dockerfile
- + Docker Hub
- + Host
- + Container
- + Swarm
- The project
- --------------------------------------------------
- ![Diagrama Simplificado](https://s3-us-west-2.amazonaws.com/ciberado/docker-swarm-workshop-arquitectura.png)
- Setting up the Swarm registry
- --------------------------------------------------
- ```bash
- docker-machine create -d virtualbox --virtualbox-memory "512" keystore
- docker-machine env keystore --shell bash
- eval "$(docker-machine env keystore --shell bash)"
- docker run -d -p 8500:8500 -h consul progrium/consul -server -bootstrap
- docker-machine ip keystore
- export consul_ip=$(docker-machine ip keystore)
- echo Consul IP: $consul_ip
- ```
- Creating the Swarm master node
- --------------------------------------------------
- ```bash
- docker-machine create \
- -d virtualbox \
- --virtualbox-memory "512" \
- --swarm --swarm-master \
- --swarm-discovery="consul://$consul_ip:8500" \
- --engine-opt="cluster-store=consul://$consul_ip:8500" \
- --engine-opt="cluster-advertise=eth1:2376" \
- master-node
- ```
- Starting the worker nodes: API
- ---------------------------------------------------
- ```bash
- docker-machine create -d virtualbox \
- --virtualbox-memory "512" \
- --swarm \
- --swarm-discovery="consul://$consul_ip:8500" \
- --engine-opt="cluster-store=consul://$consul_ip:8500" \
- --engine-opt="cluster-advertise=eth1:2376" \
- --engine-label noderole=api \
- cluster-node-1
- ```
- Starting the worker nodes: DATABASE
- ---------------------------------------------------
- ```bash
- docker-machine create -d virtualbox \
- --virtualbox-memory "512" \
- --swarm \
- --swarm-discovery="consul://$consul_ip:8500" \
- --engine-opt="cluster-store=consul://$consul_ip:8500" \
- --engine-opt="cluster-advertise=eth1:2376" \
- --engine-label noderole=db \
- cluster-node-2
- ```
- Checking the cluster nodes
- ---------------------------------------------------
- ```bash
- docker-machine env --shell bash master-node
- eval "$(docker-machine env --shell bash master-node)"
- docker ps --format "{{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Command}}"
- docker run swarm list consul://$consul_ip:8500
- ```
- Connecting to the Swarm
- ---------------------------------------------------
- ```bash
- docker-machine env --shell bash --swarm master-node
- eval "$(docker-machine env --shell bash --swarm master-node)"
- docker ps --format "{{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Command}}"
- docker ps --all --format "{{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Command}}"
- docker info
- ```
- Creating the network
- ---------------------------------------------------
- ```bash
- docker network create --driver overlay demonetwork
- docker network ls
- ```
- Manually launching the database
- ---------------------------------------------------
- ```bash
- docker run --name mysql -it --rm \
- --env "constraint:noderole==db" \
- --net demonetwork \
- capside/footballmatchdb
- ```
- Manually launching the API
- ---------------------------------------------------
- ```bash
- docker run -it --rm --name footballmatch \
- --env "constraint:noderole==api" \
- --net demonetwork \
- capside/docker-workshop-footballapi
- ```
- Manually launching the proxy
- ---------------------------------------------------
- ```bash
- docker run -it --rm --name haproxy \
- --env "constraint:noderole==api" \
- --net demonetwork \
- --publish 80:80 \
- capside/footballmatchlb
- ```
- Checking the deployment
- ---------------------------------------------------
- ```bash
- docker-machine ip cluster-node-1
- export api_ip=$(docker-machine ip cluster-node-1)
- ```
- Creating the Azure certificate
- ---------------------------------------------------
- ```bash
- openssl req -x509 -nodes -days 365 -newkey rsa:1024 \
- -keyout swarmcert.pem -out swarmcert.pem
- openssl x509 -inform pem -in swarmcert.pem \
- -outform der -out swarmcert.cer
- ssh-keygen -y -f swarmcert.pem > swarmcert.pub
- ```
- + Upload the certificate
- + Find the subscription id
- Setting the suscription id
- ---------------------------------------------------
- ```bash
- set subscription_id=4c242bba-bb40-4f3b-b412-012345678901
- ```
- Creating the keystore
- ---------------------------------------------------
- ```bash
- docker-machine create \
- -d azure --azure-subscription-id="%subscription_id%" \
- --azure-subscription-cert="swarmcert.pem" \
- capside-keystore
- eval "$(docker-machine env --shell bash capside-keystore)"
- docker run -d -p 8500:8500 -h consul progrium/consul -server -bootstrap
- export consul_ip=$(docker-machine ip capside-keystore)
- ```
- ####Endpoints
- + 8500 tcp on the consul machine
- Launching the cluster
- ---------------------------------------------------
- ```bash
- docker-machine create \
- -d azure --azure-subscription-id="%subscription_id%" \
- --azure-subscription-cert="swarmcert.pem" \
- --swarm --swarm-master \
- --swarm-discovery="consul://$consul_ip:8500" \
- --engine-opt="cluster-store=consul://$consul_ip:8500" \
- --engine-opt="cluster-advertise=eth0:2376" \
- capside-master-node
- eval "$(docker-machine env --shell bash capside-master-node)"
- docker-machine create \
- -d azure --azure-subscription-id="%subscription_id%" \
- --azure-subscription-cert="swarmcert.pem" \
- --swarm \
- --swarm-discovery="consul://$consul_ip:8500" \
- --engine-opt="cluster-store=consul://$consul_ip:8500" \
- --engine-opt="cluster-advertise=eth0:2376" \
- --engine-label noderole=edge \
- capside-cluster-node-0
- ```
- ####Endpoints
- + 4789(udp), 7946(udp), 7946(tcp) on each swarm node including master
- + 80(tcp) on edge
- Creating the network
- ---------------------------------------------------
- ```bash
- docker network create --driver overlay demonetwork
- ```
- Deploy on Azure: ARM
- ---------------------------------------------------
- + Use the [ARM Template](https://github.com/Azure/azure-quickstart-templates/tree/master/docker-swarm-cluster)
- Extra ball: dev environment
- ---------------------------------------------------
- ```bash
- start docker run ^
- --net demonetwork -p 8888:8888 ^
- -v /c/Users/yourusername/api:/api ^
- --rm -it -e "TERM=xterm-256color" capside/nodejs sh
- ```
- The first one is for free
- ---------------------------------------------------
- ![Diagrama](https://s3-us-west-2.amazonaws.com/ciberado/docker-swarm-demo-haproxy.png)
- [Online training](https://capside-academy.teachable.com/)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement