Friday, September 27, 2019

docker swarm cluster

#
[node1] (local) root@192.168.0.23 ~$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$ docker run -dt ubuntu sleep infinity
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
7413c47ba209: Pull complete
0fe7e7cbb2e8: Pull complete
1d425c982345: Pull complete
344da5c95cec: Pull complete
Digest: sha256:c303f19cfe9ee92badbbbd7567bc1ca47789f79303ddcef56f77687d4744cd7a
Status: Downloaded newer image for ubuntu:latest
03fd033d6a89bb78b8a18970985d8bc9b30d5093834a73ffed752a532512042a
[node1] (local) root@192.168.0.23 ~
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED        STATUS              PORTS               NAMES
03fd033d6a89        ubuntu              "sleep infinity"    5 seconds ago       Up 4 seconds                            magical_dhawan
[node1] (local) root@192.168.0.23 ~
$ docker swarm init --advertise-addr $(hostname -i)
Swarm initialized: current node (1ofs9nrhqk9fncucz7aq4gagr) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-060lwu0x956dwl0gnrpu72knzc2sfpe6n3vts59ure1h80dhc1-a00p2kt4m6kbvslfplw3mqbkw 192.168.0.23:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$ docker info
Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 19.03.0-beta2
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentriessplunk syslog
 Swarm: active
  NodeID: 1ofs9nrhqk9fncucz7aq4gagr
  Is Manager: true
  ClusterID: 3kxjilauu21dfk7m2pyyq2is9
  Managers: 1
  Nodes: 3
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 192.168.0.23
  Manager Addresses:
   192.168.0.23:2377
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc version: 029124da7af7360afa781a0234d1b083550f797c
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.4.0-154-generic
 Operating System: Alpine Linux v3.9 (containerized)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.4GiB
 Name: node1
 ID: 97d199c2-b974-4665-bdc6-f39d1d14cdff
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 43
  Goroutines: 181
  System Time: 2019-07-28T04:38:26.261556065Z
  EventsListeners: 0
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.1
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
         Access to the remote API is equivalent to root access on the host. Refer
         to the 'Docker daemon attack surface' section in the documentation for
         more information: https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
WARNING: No swap limit support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
[node1] (local) root@192.168.0.23 ~
$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
1ofs9nrhqk9fncucz7aq4gagr *   node1               Ready               Active              Leader              19.03.0-beta2
5m6d0kpfhtxlexjqfdgeen36p     node2               Ready               Active                                  19.03.0-beta2
i8igt9rtdmpboyy4geyudrzbd     node3               Ready               Active                                  19.03.0-beta2
[node1] (local) root@192.168.0.23 ~
$ docker service create --name sleep-app ubuntu sleep infinity
o9opnu7wgdzwtebfayg38tamt
overall progress: 1 out of 1 tasks
1/1: running
verify: Service converged
[node1] (local) root@192.168.0.23 ~
$ docker service ls
ID                  NAME                MODE                REPLICAS        IMAGE               PORTS
o9opnu7wgdzw        sleep-app           replicated          1/1        ubuntu:latest
[node1] (local) root@192.168.0.23 ~
$ docker service update --replicas 7 sleep-app
sleep-app
[node1] (local) root@192.168.0.23 ~
$ docker service ps sleep-app
ID                  NAME                IMAGE               NODE        DESIRED STATE       CURRENT STATE             ERROR  PORTS
ccqjxztpwgp7        sleep-app.1         ubuntu:latest       node1        Running             Running 16 seconds ago
xhnnk882kanj        sleep-app.2         ubuntu:latest       node3        Running             Preparing 3 seconds ago
s20fyygsfwbp        sleep-app.3         ubuntu:latest       node2        Running             Preparing 3 seconds ago
3j2z7vihzvsq        sleep-app.4         ubuntu:latest       node3        Running             Preparing 3 seconds ago
scscx0e8hjz3        sleep-app.5         ubuntu:latest       node3        Running             Preparing 3 seconds ago
hsynqxd1yte5        sleep-app.6         ubuntu:latest       node1        Running             Running 2 seconds ago
dd1lq6ap070t        sleep-app.7         ubuntu:latest       node2        Running             Preparing 3 seconds ago
[node1] (local) root@192.168.0.23 ~
$ docker service ps sleep-app
ID                  NAME                IMAGE               NODE        DESIRED STATE       CURRENT STATE            ERROR PORTS
ccqjxztpwgp7        sleep-app.1         ubuntu:latest       node1        Running             Running 22 seconds ago
xhnnk882kanj        sleep-app.2         ubuntu:latest       node3        Running             Running 2 seconds ago
s20fyygsfwbp        sleep-app.3         ubuntu:latest       node2        Running             Running 2 seconds ago
3j2z7vihzvsq        sleep-app.4         ubuntu:latest       node3        Running             Running 2 seconds ago
scscx0e8hjz3        sleep-app.5         ubuntu:latest       node3        Running             Running 2 seconds ago
hsynqxd1yte5        sleep-app.6         ubuntu:latest       node1        Running             Running 8 seconds ago
dd1lq6ap070t        sleep-app.7         ubuntu:latest       node2        Running             Running 3 seconds ago
[node1] (local) root@192.168.0.23 ~
$ docker service ps sleep-app --replicas
unknown flag: --replicas
See 'docker service ps --help'.
[node1] (local) root@192.168.0.23 ~
$ docker service ps  --replicas
unknown flag: --replicas
See 'docker service ps --help'.
[node1] (local) root@192.168.0.23 ~
$ docker service ps sleep-app
ID                  NAME                IMAGE               NODE        DESIRED STATE       CURRENT STATE                ERROR     PORTS
ccqjxztpwgp7        sleep-app.1         ubuntu:latest       node1        Running             Running about a minute ago
xhnnk882kanj        sleep-app.2         ubuntu:latest       node3        Running             Running about a minute ago
s20fyygsfwbp        sleep-app.3         ubuntu:latest       node2        Running             Running about a minute ago
3j2z7vihzvsq        sleep-app.4         ubuntu:latest       node3        Running             Running about a minute ago
scscx0e8hjz3        sleep-app.5         ubuntu:latest       node3        Running             Running about a minute ago
hsynqxd1yte5        sleep-app.6         ubuntu:latest       node1        Running             Running about a minute ago
dd1lq6ap070t        sleep-app.7         ubuntu:latest       node2        Running             Running about a minute ago
[node1] (local) root@192.168.0.23 ~
$ docker service update --replicas 4 sleep-app
sleep-app
overall progress: 4 out of 4 tasks
1/4: running
2/4: running
3/4: running
4/4: running
verify: Service converged
[node1] (local) root@192.168.0.23 ~
$ docker service ps sleep-app
ID                  NAME                IMAGE               NODE        DESIRED STATE       CURRENT STATE                ERROR     PORTS
ccqjxztpwgp7        sleep-app.1         ubuntu:latest       node1        Running             Running about a minute ago
xhnnk882kanj        sleep-app.2         ubuntu:latest       node3        Running             Running about a minute ago
s20fyygsfwbp        sleep-app.3         ubuntu:latest       node2        Running             Running about a minute ago
3j2z7vihzvsq        sleep-app.4         ubuntu:latest       node3        Running             Running about a minute ago
[node1] (local) root@192.168.0.23 ~
$ docker node ls
[node1] (local) root@192.168.0.23 ~$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
1ofs9nrhqk9fncucz7aq4gagr *   node1               Ready               Active              Leader              19.03.0-beta2
5m6d0kpfhtxlexjqfdgeen36p     node2               Ready               Active                                  19.03.0-beta2
i8igt9rtdmpboyy4geyudrzbd     node3               Ready               Ac
tive                                  19.03.0-beta2
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$ date
Sun Jul 28 04:45:47 UTC 2019
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED        STATUS              PORTS               NAMES
a94b251c4512        ubuntu:latest       "sleep infinity"    7 minutes ago       Up 7 minutes                            sleep-app.1.ccqjxztpwgp71vp1mltrqon9k
03fd033d6a89        ubuntu              "sleep infinity"    9 minutes ago       Up 9 minutes                            magical_dhawan
[node1] (local) root@192.168.0.23 ~
$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
1ofs9nrhqk9fncucz7aq4gagr *   node1               Ready               Active              Leader              19.03.0-beta2
5m6d0kpfhtxlexjqfdgeen36p     node2               Ready               Active                                  19.03.0-beta2
i8igt9rtdmpboyy4geyudrzbd     node3               Ready               Active                                  19.03.0-beta2
[node1] (local) root@192.168.0.23 ~
$ docker node update --availability drain ^C
[node1] (local) root@192.168.0.23 ~
$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
1ofs9nrhqk9fncucz7aq4gagr *   node1               Ready               Active              Leader              19.03.0-beta2
5m6d0kpfhtxlexjqfdgeen36p     node2               Ready               Active                                  19.03.0-beta2
i8igt9rtdmpboyy4geyudrzbd     node3               Ready               Active                                  19.03.0-beta2
[node1] (local) root@192.168.0.23 ~
$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
1ofs9nrhqk9fncucz7aq4gagr *   node1               Ready               Active              Leader              19.03.0-beta2
5m6d0kpfhtxlexjqfdgeen36p     node2               Ready               Active                                  19.03.0-beta2
i8igt9rtdmpboyy4geyudrzbd     node3               Ready               Active                                  19.03.0-beta2
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$ docker node update --availability drain  5m6d0kpfhtxlexjqfdgeen36p
5m6d0kpfhtxlexjqfdgeen36p
[node1] (local) root@192.168.0.23 ~
$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
1ofs9nrhqk9fncucz7aq4gagr *   node1               Ready               Active              Leader              19.03.0-beta2
5m6d0kpfhtxlexjqfdgeen36p     node2               Ready               Drain                                   19.03.0-beta2
i8igt9rtdmpboyy4geyudrzbd     node3               Ready               Active                                  19.03.0-beta2
[node1] (local) root@192.168.0.23 ~
$
[node1] (local) root@192.168.0.23 ~
$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
1ofs9nrhqk9fncucz7aq4gagr *   node1               Ready               Active              Leader              19.03.0-beta2
5m6d0kpfhtxlexjqfdgeen36p     node2               Ready               Drain                                   19.03.0-beta2
i8igt9rtdmpboyy4geyudrzbd     node3               Ready               Active                                  19.03.0-beta2
[node1] (local) root@192.168.0.23 ~
$ docker service ps sleep-app
ID                  NAME                IMAGE               NODE        DESIRED STATE       CURRENT STATE                 ERROR      PORTS
ccqjxztpwgp7        sleep-app.1         ubuntu:latest       node1        Running             Running 22 minutes ago
xhnnk882kanj        sleep-app.2         ubuntu:latest       node3        Running             Running 22 minutes ago
he2en7xs7tao        sleep-app.3         ubuntu:latest       node1        Running             Running about a minute ago
s20fyygsfwbp         \_ sleep-app.3     ubuntu:latest       node2        Shutdown            Shutdown about a minute ago
3j2z7vihzvsq        sleep-app.4         ubuntu:latest       node3        Running             Running 22 minutes ago
[node1] (local) root@192.168.0.23 ~
$ docker service rm sleep-app
sleep-app
[node1] (local) root@192.168.0.23 ~
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED         STATUS              PORTS               NAMES
c785457c7ef7        ubuntu:latest       "sleep infinity"    About a minute ago   Up About a minute                       sleep-app.3.he2en7xs7taoxxaysfdx4z7my
a94b251c4512        ubuntu:latest       "sleep infinity"    22 minutes ago       Up 22 minutes                           sleep-app.1.ccqjxztpwgp71vp1mltrqon9k
03fd033d6a89        ubuntu              "sleep infinity"    25 minutes ago       Up 24 minutes                           magical_dhawan
[node1] (local) root@192.168.0.23 ~
$ docker swarm leave --force
Node left the swarm.

No comments:

Post a Comment