도커 스웜swarm 은 도커에서 제공하는 오케스트레이션Orchestration 도구이다.
Note
|
Cluster
|
Note
|
스웜 클러스터
|
모니터링
portainer 설치하기
$ mkdir /home/apps/portainer_host_data
$ docker service create \
--name portainer \
--publish 9000:9000 \
--replicas=1 \
--constraint 'node.role == manager' \
--mount type=bind,src=/home/apps/portainer_host_data,dst=/data \
--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock
portainer/portainer
클러스터 생성하기
$ docker swarm init --advertise-addr 10.106.148.138
Swarm initialized: current node (uav8ow31vi4xwzevfuea27fu7) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-0ak1au0d6flegmgdig5889l14se3rbv9ngij9ljxj6en38ngh4-0guamgmlx492ffp0g6k6b9lfi 10.106.148.138:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
-
매니저 노드가 생성되었다.
위 명령어를 다른 노드에서 실행시켜 준다.
워커 노드에 명령어 실행하기
$ docker swarm join --token SWMTKN-1-0ak1au0d6flegmgdig5889l14se3rbv9ngij9ljxj6en38ngh4-0guamgmlx492ffp0g6k6b9lfi 10.106.148.138:2377
This node joined a swarm as a worker.
워커 노드에 명령어 실행하기 with ansible
Note
|
ansible
|
install
$ sudo yum install epel-release
$ sudo yum install ansible
ssh key 생성하기
$ ssh-keygen -t rsa -C "key for ansible" -f "ansible_rsa"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/.ssh/id_rsa):
Created directory '/home/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/.ssh/id_rsa.
Your public key has been saved in /home/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:0g4FGbkkxKJ7qZDriIS3UPwKHgI4Iohbmp55V1NTWH4 user@host
The key's randomart image is:
+---[RSA 2048]----+
| o. o+ o. |
| . o +. ... |
| . . o .. .. E |
|=. .o o . |
|Oo+. o S . |
|OBo. * |
|X*. . . o |
|X+++ . |
|+*+ . |
+----[SHA256]-----+
ssh key 복사하기
$ ssh-copy-id -i ansible_agent_rsa.pub user@host.infra.io