3. Swarm Scheduler
Manager
Swarm init
Worker 1
swarm join
Worker 2
swarm join
Worker 3
swarm join
Worker 2
swarm join
docker service create –-name myredis –-replicas 3 redis:latest
Scheduler
kicks in Here !
Main job of scheduler is to decide which node to use when running docker container/service.
docker service update docker service scale
4. Scheduling Criteria
Resource Availability
Scheduler is aware of resources available on nodes.
Labels and Constraints
Label : attribute of the node
E.g. environment = test, storage = ssd
Constraints
Restrictions applied by Operator while creating a service.
E.g. docker service create --constraint node.labels.storage==ssd …
5. Engine Labels & Constraints
Attached to docker Engine
Adding/Modifying requires Docker engine restart
https://docs.docker.com/engine/admin/#/configuring-docker
How to specify Engine labels ( Linux Machine )
Edit file /etc/default/docker modify DOCKER_OPTS and restart
daemon
Engine constraints
docker service create --constraint engine.labels.storage==ssd …
6. Node Labels & Constraints
Can be added by cluster admin for operational purpose
Doesn’t require docker engine restart
docker node update --label-add security=high
docker node update –label-rm security
Node constraints
docker service create --constraint node.labels.deployment.environment
!= test
7. Strategy & Affinity
Strategy : What happens when two nodes are similar
Spread strategy : schedule tasks on the least loaded nodes, provided
they meet the constraints and resource requirements.
Swarm standalone supported Bean pack and Random strategy
NOT SUPPORTED IN SWARM MODE YET !
Affinity and Anti Affinity
Affinity: two containers should be together
Anti Affinity : two containers should not be together
Supported in swarm standalone