brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Apr 17. 2023

6. nhn클라우드- nks-은행 계좌 조회

재테스트 필요



은행 계좌 조회


<1>  ns 생성

<2> 구성

<3> 정리



<1>  ns 생성


watch -d 'kubectl get all '

or

watch -d 'kubectl get ns,deploy,svc,pods -o wide'



kubectl create namespace yaobank


(⎈|default:default) [root@2048game-nhn-web01 ~]# k ns yaobank



<2> 구성


1

은행 시스템에 자신의 계좌에 잔고 조회를 할 수 있는 시스템 - Flask 로 웹 애플리케이션 구성, etcd 로 데이터베이스 구성


https://github.com/tigera/ccol1/blob/main/yaobank.yaml



2


# 생성

curl -s -O https://raw.githubusercontent.com/tigera/ccol1/main/yaobank.yaml

sed -i 's/nodeSelector/#nodeSelector/g' yaobank.yaml && sed -i 's/kubernetes.io/#kubernetes.io/g' yaobank.yaml

sed -i 's/istio-injection: disabled/istio-injection: enabled/g' yaobank.yaml  

# (옵션) istio 사용 시 Auto Injection with namespace label


3

vi yaobank.yaml

Node -> LoadBalancer


kubectl apply -f yaobank.yaml



4

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

service/customer   LoadBalancer   10.254.68.219   133.186.203.188   80:30180/TCP   2m15s   app=customer

service/database   ClusterIP      10.254.42.199   <none>            2379/TCP       5m31s   app=database

service/summary    ClusterIP      10.254.57.208   <none>            80/TCP         5m31s   app=summary


NAME                       READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS   IMAGES                              SELECTOR

deployment.apps/customer   1/1     1            1           5m31s   customer     calico/yaobank-customer:multiarch   app=customer,version=v1

deployment.apps/database   1/1     1            1           5m31s   database     calico/yaobank-database:multiarch   app=database,version=v1

deployment.apps/summary    2/2     2            2           5m31s   summary      calico/yaobank-summary:multiarch    app=summary,version=v1


NAME                                  DESIRED   CURRENT   READY   AGE     CONTAINERS   IMAGES                              SELECTOR

replicaset.apps/customer-5dd6b8478    1         1         1       5m31s   customer     calico/yaobank-customer:multiarch   app=customer,pod-template-hash=5dd6b8478,version=v1

replicaset.apps/database-57567d4c44   1         1         1       5m31s   database     calico/yaobank-database:multiarch   app=database,pod-template-hash=57567d4c44,version=v1

replicaset.apps/summary-56c666dc9d    2         2         2       5m31s   summary      calico/yaobank-summary:multiarch    app=summary,pod-template-hash=56c666dc9d,version=v1


133.186.203.188




5

# 확인

kubectl get all -n yaobank



# customer 파드 웹 접속 확인

CUSTOMER=$(kubectl get pods -n yaobank -l app=customer -o jsonpath={.items[0].status.podIP})


echo $CUSTOMER

10.200.38.12


curl $CUSTOMER

혹은

curl <노드IP>:>NodePort>



6

// centos

yum install -y lynx


(⎈|default:yaobank) [root@2048game-nhn-web01 ~]# lynx -dump 133.186.203.188:80

                              Welcome to YAO Bank

Name: Spike Curtis

Balance: 2389.45

   [1]Log Out >>

References

   1. http://133.186.203.188/logout



apt install -y lynx

lynx -dump <노드IP>:<NodePort>


[root@k8s-m:~ (DKOS-K8S:yaobank)]# lynx -dump 192.168.100.10:30180

                              Welcome to YAO Bank

Name: Spike Curtis

Balance: 2389.45

   [1]Log Out >>

References

   1. http://192.168.100.10:30180/logout


7

# customer 파드 Shell 접속 후 데이터베이스(etcd) 파드 접속 확인

CUSTOMER_POD=$(kubectl get pods -n yaobank -l app=customer -o name)

kubectl exec -it $CUSTOMER_POD -n yaobank -c customer -- /bin/bash


root@customer-5dd6b8478-ld525:/app#

-----------------------------------------

curl -s http://database:2379/v2/keys?recursive=true | python -m json.tool

exit

-----------------------------------------



8

# 혹은 직접 데이터베이스(etcd) 파드 접속 확인 : 5명의 account(고객) 정보 출력

// 안됨


DATABASE=$(kubectl get pods -n yaobank -l app=database -o jsonpath={.items[0].status.podIP}) 


curl -s $DATABASE:2379/v2/keys | jq curl -s $DATABASE:2379/v2/keys?recursive=true | jq


curl -s $DATABASE:2379/v2/keys?recursive=true | jq



9

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

service/customer   LoadBalancer   10.254.68.219   133.186.203.188   80:30180/TCP   14m   app=customer

service/database   ClusterIP      10.254.42.199   <none>            2379/TCP       17m   app=database

service/summary    ClusterIP      10.254.57.208   <none>            80/TCP         17m   app=summary

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES                              SELECTOR

deployment.apps/customer   1/1     1            1           17m   customer     calico/yaobank-customer:multiarch   app=customer,version=v1

deployment.apps/database   1/1     1            1           17m   database     calico/yaobank-database:multiarch   app=database,version=v1

deployment.apps/summary    2/2     2            2           17m   summary      calico/yaobank-summary:multiarch    app=summary,version=v1

NAME                                  DESIRED   CURRENT   READY   AGE   CONTAINERS   IMAGES                              SELECTOR

replicaset.apps/customer-5dd6b8478    1         1         1       17m   customer     calico/yaobank-customer:multiarch   app=customer,pod-template-hash=5dd6b8478,version=v1

replicaset.apps/database-57567d4c44   1         1         1       17m   database     calico/yaobank-database:multiarch   app=database,pod-template-hash=57567d4c44,version=v1

replicaset.apps/summary-56c666dc9d    2         2         2       17m   summary      calico/yaobank-summary:multiarch    app=summary,pod-template-hash=56c666dc9d,version=v1



10

# 삭제

kubectl delete -f yaobank.yaml




<3> 정리


 type: LoadBalancer

변경후 접속 됨



감사합니다.


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