Reproducing a Traefik with SSL and Portainer setup on a 2 Node Docker Swarm
Install Docker on both nodes with a Bootstrap Script:
$ curl https://gitlab.com/rbekker87/scripts/raw/master/setup-docker-ubuntu.sh | bash
| # Set network interfaces on all worker nodes to promiscuous mode. | |
| # Run on all worker nodes: | |
| ip link set <bridged interface> promisc on | |
| # Create a config-only network for each worker node. | |
| # This defines the host-specific network configurations. | |
| # Run on all worker nodes: | |
| docker network create \ | |
| --config-only \ | |
| -d macvlan \ |
| global | |
| log /dev/log local0 | |
| log /dev/log local1 notice | |
| chroot /var/lib/haproxy | |
| stats socket /run/haproxy/admin.sock mode 660 level admin | |
| stats timeout 30s | |
| user haproxy | |
| group haproxy | |
| daemon | |
| maxconn 2048 |
| /** | |
| * Script simples para importação de dados de cotação da Bovespa | |
| * | |
| * Requisitos: | |
| * - Node.js instalado | |
| * - instalar as dependencias: npm install extract-zip moment request | |
| * | |
| * Exemplo de uso: node script_simples_importaca_cota_hist_bovespa.js 05022019 | |
| * | |
| * Post relacionado: https://albertosouza.net/artigos/22-importando-dados-bovespa |
This will get you routable containers with IPs on your existing subnets, advertising to Consul. They will also be scalable and placed across a cluster of Swarm hosts. It's assumed that you are already running Consul, so if not, there are a ton of tutorials out there. It's also assumed you know how to install Docker and various Linux kernels.
Bonus: We add an autoscaling API called Orbiter (https://gianarb.it/blog/orbiter-the-swarm-autoscaler-moves).
So you have an existing environment. You use Consul for service discovery. Life is good. Containers are now a thing and you want to work them in without having to worry about overlay networking or reverse proxies. You also don't want to add extra latency (as some naysayers could use it as fuel to kill your hopes and dreams). Lastly, you don't have a lot of time to invest in a complex orchestration tool, such a
| --log_gc (Log heap samples on garbage collection for the hp2ps tool.) | |
| type: bool default: false | |
| --expose_gc (expose gc extension) | |
| type: bool default: false | |
| --max_new_space_size (max size of the new generation (in kBytes)) | |
| type: int default: 0 | |
| --max_old_space_size (max size of the old generation (in Mbytes)) | |
| type: int default: 0 | |
| --max_executable_size (max size of executable memory (in Mbytes)) | |
| type: int default: 0 |
| #!/bin/sh -x | |
| CURRENT=`git branch | grep "*" | awk '{print $2}'` | |
| git checkout master | |
| git fetch | |
| git merge origin/master | |
| git checkout ${CURRENT} | |
| git merge master ${CURRENT} |
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions |
| # Plain Ol' Node | |
| node --max-old-space-size=1024 app.js # increase to 1gb | |
| node --max-old-space-size=2048 app.js # increase to 2gb | |
| node --max-old-space-size=3072 app.js # increase to 3gb | |
| node --max-old-space-size=4096 app.js # increase to 4gb | |
| node --max-old-space-size=5120 app.js # increase to 5gb | |
| node --max-old-space-size=6144 app.js # increase to 6gb | |
| # For pm2 | |
| pm2 start app.js --node-args="--max-old-space-size=1024" # increase to 1gb |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm