Skip to content

Instantly share code, notes, and snippets.

@smothiki
Last active August 29, 2015 14:23
Show Gist options
  • Save smothiki/b32d3fd58208cc95830e to your computer and use it in GitHub Desktop.
Save smothiki/b32d3fd58208cc95830e to your computer and use it in GitHub Desktop.
schedulers

##Types of Schedulers Part 1 - Monolithic Schedulers

Monolithic schedulers are a single process entity that makes scheduling decisions and deploys the unit to be scheduled. It must be noted that such Monolithic schedulers do not support parallel tasks. some examples of monolithic schedulers are fleet, swarm. Apart from these, Kubernetes is an advanced type of monolithic scheduler. Kubernetes has a decoupled scheduling module which reads tasks from queue and schedules the Pods. ####Fleet Fleet is a scheduler for SystemD units and a default scheduler in coreOS. It uses the least loaded machine to schedule a unit. However, it is not a resource aware scheduler. We can specify constraints along with the SystemD template on how the unit has should be deployed. An example service file looks like

[Unit]
Description=deis-store-admin

[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=20m
ExecStartPre=/bin/sh -c "IMAGE=`/run/deis/bin/get_image /deis/store-admin` && docker history $IMAGE >/dev/null 2>&1 || docker pull $IMAGE"
ExecStartPre=/bin/sh -c "docker inspect deis-store-admin >/dev/null 2>&1 && docker rm -f deis-store-admin >/dev/null 2>&1 || true"
ExecStart=/bin/sh -c "IMAGE=`/run/deis/bin/get_image /deis/store-admin` && docker run --name deis-store-admin --rm --volumes-from=deis-store-daemon-data --volumes-from=deis-store-monitor-data -e HOST=$COREOS_PRIVATE_IPV4 $IMAGE"
ExecStopPost=-/usr/bin/docker rm -f deis-store-admin
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

[X-Fleet]
Global=true

using X-Fleet option we specify constraints 'Global=true' means schedule this unit in every machine. Please refer to templating units for more options and features.

The user can use deisctl or fleetctl to submit a fleet unit. This can be done by setting DEISCTL_TUNNEL to one of the coreOS IP Addresses.

deisctl install <unit name> installs fleet unit in the cluster.

deisctl start <unit name> will run the unit .

####Swarm Swarm is a scheduling backend for Docker containers. you can deploy a Docker container using docker client. Swarm is an extension to the libswarm project. The advantage of Swarm is that it supports filters and strategies to schedule the container. To use this feature, the user needs to install swarm manager and swarm nodes on each node. The attribute affinity affinity:container==registry will make sure the container gets deployed on the node where there is a registry container. More filter options are available here

docker run -d --name cache -e affinity:container==registry builder

The user also has the option to explicitly specify soft affinities with a ~ affinity:container==~registry if there is no node with container registry swarm will discard the affinity and schedule the container according to the scheduling strategy. Swarm is a resource aware scheduler currently supported scheduling strategies are spread, bin packing and random scheduling strategies.

By default Deis comes with fleet. Current version of Deis supports Swarm. To install swarm :

deisctl install swarm && deisctl start swarm

To switch the scheduling backend :

deisctl config controller set schedulerModule=swarm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment