instance 생성
2번째 방법으로 실습 진행
ubuntu 기본 이미지 + docker → new image → glance에 등록 → 2개 volumes(manager,worker)
manager에서 토큰 발행
worker는 토큰 이용하여 클러스터에 조인
컨트롤 노드에서 명령
wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
apt -y install bridge-utils libvirt-clients libvirt-daemon qemu qemu-kvm libguestfs-tools
key-pair : mykey
security-group : permitweb[22/tcp] 포함, permitdocker[2376/tcp, 2377/tcp, 7946/tcp,udp, 4789/udp]
flavor : cpu1, ram1, disk 20GB
[root@localhost ~]# source keystonerc_admin
[root@localhost ~(logged)]# ssh-keygen -q -f /root/.ssh/mykey.pem -N ""
-N “” : password 지정 안하겠다
[root@localhost ~(logged)]# ls /root/.ssh
authorized_keys chulsoo.pem.pub gildong.pem.pub id_rsa.pub mykey.pem
chulsoo.pem gildong.pem id_rsa known_hosts mykey.pem.pub
[root@localhost ~(logged)]# openstack keypair create --public-key /root/.ssh/mykey.pem.pub mykey
인스턴스 /home/ubuntu[또는 centos]/.ssh/authorized_keys에 저장
[root@localhost ~(logged)]# openstack flavor create --id 6 --vcpus 1 --ram 1024 --disk 20 m1.xsmall
[root@localhost ~(logged)]# openstack security group create permitdocker
permitweb rule도 함께 그냥 permitdocker에 적용
[root@localhost ~(logged)]# openstack security group rule create \
> --proto tcp --dst-port 22 permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto tcp --dst-port 80 permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto tcp --dst-port 443 permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto icmp permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto tcp --dst-port 2376 permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto tcp --dst-port 2377 permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto tcp --dst-port 7946 permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto udp --dst-port 7946 permitdocker
[root@localhost ~(logged)]# openstack security group rule create --proto udp --dst-port 4789 permitdocker
root@manager:~# wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
Ubuntu + Docker인 이미지
[root@localhost ~(logged)]# openstack image create "docker" \
> --file ubuntu1804Docker.img --disk-format qcow2 --container-format bare \
> --public
[root@localhost ~(logged)]# openstack image list
+--------------------------------------+-----------------+--------+
| ID | Name | Status |
+--------------------------------------+-----------------+--------+
| e88006a6-beb2-430c-b883-73a34a1a6a82 | CIRROS | active |
| 3c024138-d64c-4119-b244-093f86c3df4f | CentOS7 | active |
| 7ac8e7c7-7fce-4285-b3c2-505db319532c | CentOS7docker | active |
| dc051bcf-a6dd-44ff-94c9-5c731832735f | CentOS7httpd | active |
| 2b608345-9e30-4427-b1f0-9afa63f3cf99 | CentOSdockerimg | active |
| cecccc12-e48e-402f-8acf-370d660fcd48 | docker | active |
+--------------------------------------+-----------------+--------+
cinder (Block Storage) 사용
인스턴스 이름 : manager > 부팅 소스 선택: 볼륨 , 만들어둔 manager 볼륨 올리기 > Flavor m1.xsmall > 네트워크 선택(net1) > 보안그룹 default 내리고ㅓ, permitdocker > 키페어 : mykey
작업 > 유동 IP 연결 > 없다면 할당 후 확인 > 211.183.3.206과 연결
인스턴스 이름 : worker > 부팅 소스 선택: 볼륨 , 만들어둔 worker 볼륨 올리기 > Flavor m1.xsmall > 네트워크 선택(net1) > 보안그룹 default 내리고ㅓ, permitdocker > 키페어 : mykey
작업 > 유동 IP 연결 > 없다면 할당 후 확인 > 211.183.3.224과 연결
해당 Floating IP로 ping 보내서 확인
[root@localhost ~(logged)]# ssh -i /root/.ssh/mykey.pem -l ubuntu 211.183.3.206
systmectl status docker
[root@localhost ~(logged)]# ssh -i /root/.ssh/mykey.pem -l ubuntu 211.183.3.206 'hostname'
[root@localhost ~(logged)]# ssh -i /root/.ssh/mykey.pem -l ubuntu 211.183.3.206 'ip a'
cat /root/.ssh/known_hosts 에 등록하면됨
ssh-keyscan 211.183.3.206 >> /root/.ssh/known_hosts에 등록하면 yes/no 물어보지 않음
ssh -i /root/.ssh/mykey.pem -l ubuntu 211.183.3.206 'sudo docker swarm init --advertise-addr ens3'
worker에게는 매니저에서 발행한 토큰 전달
ssh -i /root/.ssh/mykey.pem -l ubuntu 211.183.3.224 'sudo docker swarm join --token SWMTKN-1-3zkiwh2tg8leg18filz2n1woh7vcaybzbtjdr6xaprb7qhnl4b-elkz86jwn1t2p67oklznn9mh5 172.16.123.4:2377'
ssh -i /root/.ssh/mykey.pem -l ubuntu 211.183.3.206 'sudo docker node ls'