github.com/technosophos/deis@v1.7.1-0.20150915173815-f9005256004b/docs/customizing_deis/choosing-a-scheduler.rst (about)

     1  :title: Choosing a Scheduler
     2  :description: How to choose a scheduler backend for Deis.
     3  
     4  
     5  .. _choosing_a_scheduler:
     6  
     7  Choosing a Scheduler
     8  ====================
     9  
    10  The :ref:`scheduler` creates, starts, stops, and destroys each :ref:`container`
    11  of your app. For example, a command such as ``deis scale web=3`` tells the
    12  scheduler to run three containers from the Docker image for your app.
    13  
    14  Deis defaults to using the :ref:`fleet_scheduler`. Tech previews of schedulers based on
    15  :ref:`Kubernetes <k8s_scheduler>`, :ref:`Mesos with Marathon <mesos_scheduler>`, and
    16  :ref:`Swarm <swarm_scheduler>` are available for testing.
    17  
    18  .. note::
    19  
    20      If you are using a scheduler other than fleet, app containers will not be rescheduled if
    21      deis-registry is unavailable. For more information, see `deis-registry issue 3619`_.
    22  
    23  Settings set by scheduler
    24  -------------------------
    25  
    26  The following etcd keys are set by the scheduler module of the controller component.
    27  
    28  Some keys will exist only if a particular ``schedulerModule`` backend is enabled.
    29  
    30  ===================================            ==========================================================
    31  setting                                        description
    32  ===================================            ==========================================================
    33  /deis/scheduler/swarm/host                     the swarm manager's host IP address
    34  /deis/scheduler/swarm/node                     used to identify other nodes in the cluster
    35  /deis/scheduler/mesos/marathon                 used to identify Marathon framework's host IP address
    36  /deis/scheduler/k8s/master                     used to identify host IP address of kubernetes ApiService
    37  ===================================            ==========================================================
    38  
    39  
    40  Settings used by scheduler
    41  --------------------------
    42  
    43  The following etcd keys are used by the scheduler module of the controller component.
    44  
    45  ====================================      ===============================================
    46  setting                                   description
    47  ====================================      ===============================================
    48  /deis/controller/schedulerModule          scheduler backend, either "fleet" or "swarm" or
    49                                            "mesos_marathon" or "k8s" (default: "fleet")
    50  ====================================      ===============================================
    51  
    52  .. _fleet_scheduler:
    53  
    54  Fleet Scheduler
    55  ---------------
    56  
    57  `fleet`_ is a scheduling backend included with CoreOS:
    58  
    59      fleet ties together systemd and etcd into a distributed init system. Think of
    60      it as an extension of systemd that operates at the cluster level instead of the
    61      machine level. This project is very low level and is designed as a foundation
    62      for higher order orchestration.
    63  
    64  ``fleetd`` is already running on the machines provisioned for Deis: no additional
    65  configuration is needed. Commands such as ``deis ps:restart web.1`` or
    66  ``deis scale cmd=10`` will use `fleet`_ by default to manage app containers.
    67  
    68  To use the Fleet Scheduler backend explicitly, set the controller's
    69  ``schedulerModule`` to "fleet":
    70  
    71  .. code-block:: console
    72  
    73      $ deisctl config controller set schedulerModule=fleet
    74  
    75  .. _k8s_scheduler:
    76  
    77  Kubernetes Scheduler
    78  --------------------
    79  
    80  .. important::
    81  
    82      The Kubernetes Scheduler is a technology preview and is not recommended for production use.
    83      Since it requires overlay networking, Kubernetes can only be enabled on a new cluster.
    84  
    85  `Kubernetes`_ is an orchestration system for Docker containers:
    86  
    87      Kubernetes (k8s) provides APIs to manage, deploy and scale Docker containers. Kubernetes
    88      deploys containers as `pods`_, providing a unique entity across a cluster, but allowing
    89      containers within the pod to share a namespace.
    90  
    91  Kubernetes requires the `flannel`_ overlay network so each pod receives a unique IP address within
    92  the cluster. Existing Deis clusters cannot simply turn on overlay networking. Instead, provision
    93  a new cluster to enable `flannel`_.
    94  
    95  To test the Kubernetes Scheduler, first install and start the Kubernetes components:
    96  
    97  .. code-block:: console
    98  
    99      $deisctl install k8s && deisctl start k8s
   100  
   101  Then set the controller's ``schedulerModule`` to "k8s":
   102  
   103  .. code-block:: console
   104  
   105      $ deisctl config controller set schedulerModule=k8s
   106  
   107  The Kubernetes scheduler is now active. Commands such as ``deis destroy`` or ``deis scale web=9``
   108  will use the Kubernetes ApiServer to manage app pods.
   109  
   110  Deis creates a `replication controller`_ to manage pods and a `service`_ which proxies traffic to
   111  the pods for your app. Unlike other Deis schedulers, new app releases on Kubernetes do a rolling
   112  deploy: pods with the new release replace old pods one at a time, until all are replaced (or until
   113  an error forces a rollback to the previous release).
   114  
   115  .. note::
   116  
   117      **Known Issues**
   118  
   119      - The flannel overlay network is not backward-compatible with earlier Deis clusters, since it
   120        changes Docker networking and requires new units from Deis' user-data file.
   121      - The Kubernetes ApiServer is not HA. If the ApiServer is rescheduled, it will reschedule all
   122        Kubernetes units.
   123      - Kubernetes implements resource-based scheduling. Specifying limits will create a reservation
   124        of that resource on the node.
   125  
   126  .. _mesos_scheduler:
   127  
   128  Mesos with Marathon framework
   129  -----------------------------
   130  
   131  .. important::
   132  
   133      The Mesos with Marathon framework Scheduler is a technology preview and is not recommended for
   134      production use.
   135  
   136  `Mesos`_ is a distributed system kernel:
   137  
   138      Mesos provides APIs for resource management and scheduling. A framework interacts with Mesos master
   139      and schedules and task. A Zookeeper cluster elects Mesos master node. Mesos slaves are installed on
   140      each node and they communicate to master with available resources.
   141  
   142  `Marathon`_ is a Mesos_ framework for long running applications:
   143  
   144      Marathon provides a Paas like feel for long running applications and features like high-availablilty, host constraints,
   145      service discovery, load balancing and REST API to control your Apps.
   146  
   147  Deis uses the Marathon framework to schedule containers. Since Marathon is a framework for long-running
   148  jobs, Deis uses the :ref:`fleet_scheduler` to run batch processing jobs. ``deisctl`` installs a standalone Mesos
   149  cluster. To install an HA Mesos cluster, follow the directions at `aledbf-mesos`_, and set the etcd key
   150  ``/deis/scheduler/mesos/marathon`` to any Marathon node IP address. If a request is received by a regular
   151  Marathon node, it is proxied to the master Marathon node.
   152  
   153  To test the Marathon Scheduler backend, first install and start the mesos components:
   154  
   155  .. code-block:: console
   156  
   157      $ deisctl install mesos && deisctl start mesos
   158  
   159  Then set the controller's ``schedulerModule`` to "mesos_marathon":
   160  
   161  .. code-block:: console
   162  
   163      $ deisctl config controller set schedulerModule=mesos_marathon
   164  
   165  The Marathon framework is now active. Commands such as ``deis destroy`` or
   166  ``deis scale web=9`` will use `Marathon`_ to manage app containers.
   167  
   168  Deis starts Marathon on port 8180. You can manage apps through the Marathon UI, which is accessible at http://<Marathon-node-IP>:8180
   169  
   170  .. note::
   171  
   172      **Known Issues**
   173  
   174      - deisctl installs a standalone mesos cluster as fleet doesn't support runtime change to metadata.
   175        You can specify this in cloud-init during the deployment of the node. keep watching `dynamic metadata fleet PR 1077`_.
   176      - If you want to access Marathon UI, you'll have to expose port 8180 in the security group settings.
   177        This is blocked off by default for security purposes.
   178      - Deis does not yet use Marathon's docker container API to create containers.
   179      - CPU shares are integers representing the number of CPUs. Memory limits should be specified in MB.
   180  
   181  .. _swarm_scheduler:
   182  
   183  Swarm Scheduler
   184  ---------------
   185  
   186  .. important::
   187  
   188      The Swarm Scheduler is a technology preview and is not recommended for
   189      production use.
   190  
   191  `swarm`_ is a scheduling backend for Docker:
   192  
   193      Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts
   194      into a single, virtual host.
   195  
   196  ..
   197  
   198      Swarm serves the standard Docker API, so any tool which already communicates
   199      with a Docker daemon can use Swarm to transparently scale to multiple hosts...
   200  
   201  Deis includes an enhanced version of swarm v0.2.0 with node failover and optimized
   202  locking on container creation. The Swarm Scheduler uses a `soft affinity`_ filter
   203  to spread app containers out among available machines.
   204  
   205  Swarm requires the Docker Remote API to be available at TCP port 2375. If you are
   206  upgrading an earlier installation of Deis, please refer to the CoreOS documentation
   207  to `enable the remote API`_.
   208  
   209  .. note::
   210  
   211      **Known Issues**
   212  
   213      - It is not yet possible to change the default affinity filter.
   214  
   215  To test the Swarm Scheduler backend, first install and start the swarm components:
   216  
   217  .. code-block:: console
   218  
   219      $ deisctl install swarm && deisctl start swarm
   220  
   221  Then set the controller's ``schedulerModule`` to "swarm":
   222  
   223  .. code-block:: console
   224  
   225      $ deisctl config controller set schedulerModule=swarm
   226  
   227  The Swarm Scheduler is now active. Commands such as ``deis destroy`` or
   228  ``deis scale web=9`` will use `swarm`_ to manage app containers.
   229  
   230  To monitor Swarm Scheduler operations, watch the logs of the swarm-manager
   231  component, or spy on Docker events directly on the swarm-manager machine:
   232  
   233  
   234  .. _Kubernetes: http://kubernetes.io/
   235  .. _Mesos: http://mesos.apache.org
   236  .. _Marathon: https://github.com/mesosphere/marathon
   237  .. _pods: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/user-guide/pods.md
   238  .. _replication controller: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/user-guide/replication-controller.md
   239  .. _service: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/user-guide/services.md
   240  .. _flannel: https://github.com/coreos/flannel
   241  .. _fleet: https://github.com/coreos/fleet#fleet---a-distributed-init-system
   242  .. _swarm: https://github.com/docker/swarm#swarm-a-docker-native-clustering-system
   243  .. _`soft affinity`: https://docs.docker.com/swarm/scheduler/filter/#soft-affinitiesconstraints
   244  .. _`enable the remote API`: https://coreos.com/docs/launching-containers/building/customizing-docker/
   245  .. _`deis-kubernetes issue 3850`: https://github.com/deis/deis/issues/3850
   246  .. _`dynamic metadata fleet PR 1077`: https://github.com/coreos/fleet/pull/1077
   247  .. _`aledbf-mesos`: https://github.com/aledbf/coreos-mesos-zookeeper
   248  .. _`deis-registry issue 3619`: https://github.com/deis/deis/issues/3619