본문 바로가기
Tech/Containers

Docker Swarm 아키텍처

by 타이호 2017. 12. 24.
반응형

1. Docker Swarm Mode Works

https://docs.docker.com/engine/swarm/how-swarm-mode-works/nodes/

Swarm mode cluster

위와 같이 Manager 역할은 클러스터를 관리하고 스케쥴링을 해주며, swarm mode api를 제공한다.

 

Worker의 경우에는 Docker instances만 담당한다.

 

2. Docker Swarm Services

https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/

Swarm모드로 image를 deploy하기 위해서는 service라는 것을 생성해야 한다. 생성할 때 아래와 같은 옵션을 적용할 수 있다고 한다.

  • the port where the swarm will make the service available outside the swarm
  • an overlay network for the service to connect to other services in the swarm
  • CPU and memory limits and reservations
  • a rolling update policy
  • the number of replicas of the image to run in the swarm

예를 들어 아래와 같은 서비스를 Deploy한다고 하면

services diagram

nginx라는 서비스는 3개의 replica를 가지게 되고 실제로는 worker에서 nginx 3개가 각각 동작하며 container 이미지는 nginx:lates로 deploy 되는 것 같다.

Task라는 것은 swarm내에서 스케쥴링을 하는 단위를 말하는 것이고, 각각의 task들은 컨테이너를 생성하는 일을 한다.

services flow

 

3.  Docker Swarm Network

기본적으로 docker swarm의 network는 아래와 같다

root@juju-aad7e2-3:~# docker network ls
NETWORK ID                       NAME                          DRIVER                       SCOPE
0516c9fbd114                    bridge                          bridge                         local
e74083b501a0                   docker_gwbridge   bridge                         local
65a509a8aea1                   host                               host                             local
yuu8v20uhfhf                    ingress                          overlay                      swarm
330dbd7bfb2e                  none                               null                              local

 

root@juju-aad7e2-3:~# docker network create --driver overlay --subnet 10.0.1.0/24 --gateway 10.0.1.254 my-network
xtlqjag4hy8x7lr3pd8461hwp

root@juju-aad7e2-3:~# docker network ls
NETWORK ID                       NAME                          DRIVER                       SCOPE
0516c9fbd114                    bridge                          bridge                         local
e74083b501a0                   docker_gwbridge   bridge                         local
65a509a8aea1                   host                               host                             local
yuu8v20uhfhf                    ingress                          overlay                      swarm
xtlqjag4hy8x                      my-network               overlay                       swarm
330dbd7bfb2e                  none                               null                              local

위와 같이 my-network이라는 overlay 네트워크가 생성되었다. 네트워크에 대한 상세 설명은


root@juju-aad7e2-3:~# docker network inspect my-network
[
{
"Name": "my-network",
"Id": "xtlqjag4hy8x7lr3pd8461hwp",
"Created": "0001-01-01T00:00:00Z",
"Scope": "swarm",
"Driver": "overlay",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "10.0.1.0/24",
"Gateway": "10.0.1.254"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": null,
"Options": {
"com.docker.network.driver.overlay.vxlanid_list": "4097"
},
"Labels": null
}
]


 

4. Launching Instances with overlay network

이제 인스턴스를 오버레이 네트워크로 생성해보자

root@juju-aad7e2-3:~# docker service create --replicas 3 --name my-web --network my-network nginx
owf7yln7hhdnx8xpc0xh420hw
Since --detach=false was not specified, tasks will be created in the background.
In a future release, --detach=false will become the default.

 

음.. overlay network으로 생성했지만 docker_gwbridge 로 컨테이너가 생성되네.. 다시 살펴 봐야 겠다

반응형