Skip to content

Latest commit

 

History

History
95 lines (92 loc) · 4.94 KB

File metadata and controls

95 lines (92 loc) · 4.94 KB

Drain Node

This script shows how to drain a node and bring it back to active state. The tasks on the node are distributed from active → drain state but not vice versa.

  1. Create a 3 node cluster using swarm-mode-amazon.adoc. Check the list of active nodes using docker node ls:

    ID                           HOSTNAME         MEMBERSHIP  STATUS  AVAILABILITY  MANAGER STATUS
    0yyap69qjg76ol5jbf811d5yz *  ip-172-31-14-33  Accepted    Ready   Active        Leader
    4a8oodtjhg017dr0xxjm2cpr4    ip-172-31-14-35  Accepted    Ready   Active
    70xqobszyfxsh6ussr38he6f5    ip-172-31-14-34  Accepted    Ready   Active

    It shows all nodes are active with one leader.

  2. Run 6 replicas of a service using docker service create --name wildfly --replicas 6 jboss/wildfly

  3. Check the list of services using docker service ls:

    ID            NAME     REPLICAS  IMAGE          COMMAND
    1n7h5v6kv3uy  wildfly  6/6       jboss/wildfly
  4. Check the list of tasks using docker service tasks wildfly:

    ID                         NAME       SERVICE  IMAGE          LAST STATE                  DESIRED STATE  NODE
    a2bxufy7l9su1sso77fkga7s8  wildfly.1  wildfly  jboss/wildfly  Running about a minute ago  Running        ip-172-31-14-35
    c26tsffz3n4u5r8qbo3wrpo03  wildfly.2  wildfly  jboss/wildfly  Running about a minute ago  Running        ip-172-31-14-33
    4xb25mk785hxn9pd9sfykrwdp  wildfly.3  wildfly  jboss/wildfly  Running about a minute ago  Running        ip-172-31-14-34
    3wm9txt61ornc3abfna5tv84i  wildfly.4  wildfly  jboss/wildfly  Running about a minute ago  Running        ip-172-31-14-34
    by6o0bhaxe2gwu3dl8rwkn6b2  wildfly.5  wildfly  jboss/wildfly  Running about a minute ago  Running        ip-172-31-14-35
    eoe02mo3alc3dzklux5fqkp7r  wildfly.6  wildfly  jboss/wildfly  Running about a minute ago  Running        ip-172-31-14-33

    Containers are evenly distributed across all the nodes. This is because of the default spread strategy.

  5. Drain a node docker node update --availability drain ip-172-31-14-35

  6. Check the list of nodes using docker node ls:

    ID                           HOSTNAME         MEMBERSHIP  STATUS  AVAILABILITY  MANAGER STATUS
    0yyap69qjg76ol5jbf811d5yz *  ip-172-31-14-33  Accepted    Ready   Active        Leader
    4a8oodtjhg017dr0xxjm2cpr4    ip-172-31-14-35  Accepted    Ready   Drain
    70xqobszyfxsh6ussr38he6f5    ip-172-31-14-34  Accepted    Ready   Active

    The node’s status is changed accordinly.

  7. Check the list of services again using docker service ls:

    ID            NAME     REPLICAS  IMAGE          COMMAND
    1n7h5v6kv3uy  wildfly  6/6       jboss/wildfly
  8. Check the list of tasks using docker service tasks wildfly:

    ID                         NAME       SERVICE  IMAGE          LAST STATE              DESIRED STATE  NODE
    4uvbvmz9v2262u89xu9e2zf8e  wildfly.1  wildfly  jboss/wildfly  Running 49 seconds ago  Running        ip-172-31-14-33
    c26tsffz3n4u5r8qbo3wrpo03  wildfly.2  wildfly  jboss/wildfly  Running 3 minutes ago   Running        ip-172-31-14-33
    4xb25mk785hxn9pd9sfykrwdp  wildfly.3  wildfly  jboss/wildfly  Running 3 minutes ago   Running        ip-172-31-14-34
    3wm9txt61ornc3abfna5tv84i  wildfly.4  wildfly  jboss/wildfly  Running 3 minutes ago   Running        ip-172-31-14-34
    914evxt319vbpc031pvo9yxd1  wildfly.5  wildfly  jboss/wildfly  Running 49 seconds ago  Running        ip-172-31-14-34
    eoe02mo3alc3dzklux5fqkp7r  wildfly.6  wildfly  jboss/wildfly  Running 3 minutes ago   Running        ip-172-31-14-33

    Now the containers are distributed across two active nodes.

  9. Make the node active again using docker node update --availability active ip-172-31-14-35.

  10. Check the list of nodes using docker node ls:

    ID                           HOSTNAME         MEMBERSHIP  STATUS  AVAILABILITY  MANAGER STATUS
    0yyap69qjg76ol5jbf811d5yz *  ip-172-31-14-33  Accepted    Ready   Active        Leader
    4a8oodtjhg017dr0xxjm2cpr4    ip-172-31-14-35  Accepted    Ready   Active
    70xqobszyfxsh6ussr38he6f5    ip-172-31-14-34  Accepted    Ready   Active
  11. Check the list of tasks using docker service tasks wildfly:

    ID                         NAME       SERVICE  IMAGE          LAST STATE             DESIRED STATE  NODE
    4uvbvmz9v2262u89xu9e2zf8e  wildfly.1  wildfly  jboss/wildfly  Running 2 minutes ago  Running        ip-172-31-14-33
    c26tsffz3n4u5r8qbo3wrpo03  wildfly.2  wildfly  jboss/wildfly  Running 5 minutes ago  Running        ip-172-31-14-33
    4xb25mk785hxn9pd9sfykrwdp  wildfly.3  wildfly  jboss/wildfly  Running 5 minutes ago  Running        ip-172-31-14-34
    3wm9txt61ornc3abfna5tv84i  wildfly.4  wildfly  jboss/wildfly  Running 5 minutes ago  Running        ip-172-31-14-34
    914evxt319vbpc031pvo9yxd1  wildfly.5  wildfly  jboss/wildfly  Running 2 minutes ago  Running        ip-172-31-14-34
    eoe02mo3alc3dzklux5fqkp7r  wildfly.6  wildfly  jboss/wildfly  Running 5 minutes ago  Running        ip-172-31-14-33

    The tasks are not redistributed again.