Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Tags
more
Archives
Today
Total
관리 메뉴

mega's Blog

Docker기반 locust 부하 테스트 (feat. Docker Swarm) 본문

카테고리 없음

Docker기반 locust 부하 테스트 (feat. Docker Swarm)

megadev 2020. 12. 7. 18:17

[ Docker Swarm ]

1. 매니저 노드 설정

docker swarm init --advertise-addr 172.16.1.13

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

docker swarm join \
--token SWMTKN-1-1la23f7y6y8joqxz27hac4j79yffyixcp15tjtlrnei14wwd1t-5tlmx4q9fm46drjzzd95g1l4q \
172.16.1.13:2377

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

 

1-1. 새로운 워커 노드를 Join 시키는 경우 Token 확인

docker swarm join-token worker

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

    docker swarm join --token SWMTKN-1-2322xfd09hbdm5nkkcjkrva02bwsngplsb2sw4vgtv6t8g5x65-c5olywf8eal7k1v0i9g5piegr 172.16.1.13:2377

 

 

2. 워커 노드 Join

docker swarm join \--token SWMTKN-1-1la23f7y6y8joqxz27hac4j79yffyixcp15tjtlrnei14wwd1t-5tlmx4q9fm46drjzzd95g1l4q \172.16.1.13:2377

3. 매니저 노드에서 확인

docker node ls

[ Dokcer 레지스트리 구성 및 이미지 생성 ]

1. Docker 레지스트리 구성

docker image pull registry
docker container run -d -p 5000:5000 --name registry registry

2. Dockerfile 작성

FROM locustio/locust:1.4.1
ADD ./Pb /mnt/locust/Pb
ADD ./locustfile.py /mnt/locust
ADD ./requirements.txt /mnt/locust
WORKDIR /mnt/locust
RUN pip3 install -r requirements.txt
ENV PYTHONPATH "${PYTHONPATH}:/mnt/locust/Pb"
EXPOSE 8089
#CMD ["locust", "-f", "locustfile.py"] 

 

3. Docker 이미지 빌드

docker image build -t <이미지이름> .
ex) docker image build -t nss-stress .

4. 이미지 Tag 생성

docker tag <이미지이름> <레지스트리IP:5000>/nss-stress
ex) docker tag nss-stress 172.16.1.13:5000/nss-stress

5. 이미지 Push

docker push 172.16.1.13:5000/nss-stress

6. 레지스트리 확인

curl -X GET http://172.16.1.13:5000/v2/_catalog

7. 이미지 Pull

docker pull 172.16.1.13:5000/nss-stress

# https 관련 에러가 발생하는 경우
vi /etc/docker/daemon.json
아래 내용 추가
{
	"insecure-registries": ["172.16.1.13:5000"]
}

# docker 서버스 재실행
sudo service docker restart


[ Docker-Compose ]

1. nss-stress.yaml 파일 생성

version: '3'

services:
  master:
    image: 172.16.1.13:5000/nss-stress
    ports:
      - "8089:8089"
      - "5557:5557"
    command: -f /mnt/locust/locustfile.py --master --host=http://172.16.1.12:20004
    deploy:
      placement:
        constraints: [node.role == manager]

  worker:
    image: 172.16.1.13:5000/nss-stress
    #command: -f /mnt/locust/locustfile.py --worker --master-host=master
    command: -f /mnt/locust/locustfile.py --worker --master-host=172.16.1.13
    depends_on:
      - master


2. 스택 생성 (서비스 구동)

docker stack deploy -c nss-stress.yaml nss-stress


3. 서비스 확인

docker service ps nss-stress_worker
docker service ps nss-stress_master


4. Scale Up

docker service scale nss-stress_worker=5

 

[ CookBook ]

1. 서비스 확인

docker service ps nss-stress_worker
docker service ps nss-stress_master

2. 서비스 Down

docker service rm nss-stress_worker
docker service rm nss-stress_master

3. 로그 확인

docker service logs nss-stress_worker -f 

 

 

 

 

Comments