brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Apr 17. 2023

9. nhn클라우드- nks - BooksApp 도서


https://github.com/BuoyantIO/booksapp



<1> 네임 스페이스 생성

<2> 배포

<3>  Deploy Chaos Monkey

<4> 정리



<1> 네임 스페이스 생성


kubectl create namespace booksapp

k ns booksapp



<2> 배포


# 배포

curl -s https://run.linkerd.io/booksapp.yml | kubectl apply -f -

kubectl patch svc webapp -p '{"spec":{"type":"NodePort"}}'


# 확인


NAME                           READY   STATUS    RESTARTS   AGE

pod/authors-d48578dd8-qhgc2    1/1     Running   0          46s

pod/books-54699dd99b-qz7xh     1/1     Running   0          46s

pod/traffic-594c5bcbd9-9n76h   1/1     Running   0          46s

pod/webapp-779449dd5b-52wps    1/1     Running   0          46s

pod/webapp-779449dd5b-7rfwq    1/1     Running   0          46s

pod/webapp-779449dd5b-kh4l2    1/1     Running   0          46s

NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE

service/authors   ClusterIP   10.254.122.70   <none>        7001/TCP         46s

service/books     ClusterIP   10.254.111.77   <none>        7002/TCP         46s

service/webapp    NodePort    10.254.252.22   <none>        7000:32091/TCP   46s

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE

deployment.apps/authors   1/1     1            1           46s

deployment.apps/books     1/1     1            1           46s

deployment.apps/traffic   1/1     1            1           46s

deployment.apps/webapp    3/3     3            3           46s

NAME                                 DESIRED   CURRENT   READY   AGE

replicaset.apps/authors-d48578dd8    1         1         1       46s

replicaset.apps/books-54699dd99b     1         1         1       46s

replicaset.apps/traffic-594c5bcbd9   1         1         1       46s

replicaset.apps/webapp-779449dd5b    3         3         3       46s




# webapp 웹 접속 주소 확인

APPNIP=$(kubectl get pod  -l app=webapp -o jsonpath='{.items[0].status.hostIP}')

APPNPORT=$(kubectl get svc webapp -o jsonpath={.spec.ports[0].nodePort})

echo -e "App URL = http://$APPNIP:$APPNPORT"



k delete service webapp

kubectl expose deployment webapp --port=80 --type=LoadBalancer

페이지가 작동하지 않습니다.




<3>   Deploy Chaos Monkey


1

https://github.com/BuoyantIO/booksapp#deploy-chaos-monkey


2

chaos.yaml

https://github.com/BuoyantIO/booksapp/blob/main/k8s/mysql-chaos.yml


3

# 30초 마다 랜덤으로 파드 1개 삭제 >> 웹 서비스 정상 서비스되는 지 확인

kubectl apply -f chaos.yaml


# 랜덤 삭제 파드 정보 확인

kubectl logs chaos -f

found 6 running pods

pod "books-6c78cf85c8-x949t" deleted

found 6 running pods

pod "webapp-78898d5698-gxmrz" deleted

found 6 running pods

pod "authors-9fdb57986-62vrw" deleted

...


# 현재 상태에서 문제 해결

kubectl scale deployment books --replicas=2


# chaos 시나리오 삭제

kubectl delete -f chaos.yaml



kubectl delete -f https://run.linkerd.io/booksapp.yml






<4> 정리



감사합니다.








keyword
매거진의 이전글 8. nhn클라우드- nks -Wordpress
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari