brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Mar 02. 2022

106.네이버 쿠버네티스 서비스에 2048게임 6/10

네이버 쿠버네티스 서비스에 2048 게임 올리기


<1> 네이버 쿠버네티스 서비스 클러스터 생성

<2> 리눅스 명령서버 접속

<3> 쿠버네티스에 2048  게임 올리기

<4> 게임 확인

<5> (몰아보기) 네이버 클라우드 컨테이너 서비스들 



<1> 네이버 쿠버네티스 서비스 클러스터 생성


생성과 접속 법

https://brunch.co.kr/@topasvga/2210




<2>  리눅스 명령서버 접속


passwd root

go1!




<3> 쿠버네티스에 2048  게임 올리기


1


cat <<EOF | kubectl create -f -

apiVersion: apps/v1

kind: Deployment

metadata:

  name: deployment-2048

spec:

  selector:

    matchLabels:

      app.kubernetes.io/name: app-2048

  replicas: 2

  template:

    metadata:

      labels:

        app.kubernetes.io/name: app-2048

    spec:

      containers:

      - image: alexwhen/docker-2048

        name: app-2048

        ports:

        - containerPort: 80

EOF


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




2

 디플로이먼트, 서비스, 파드 확인

watch -d kubectl get deploy,svc,pod -o wide



3

[root@test-web01 ~]# kubectl get svc,ep


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

service/deployment-2048   LoadBalancer   198.19.145.197   default-deployment-2048-5e327-10211509-0867085dfba2.kr.lb.naverncp.com   80:31300/TCP   43s

service/kubernetes   ClusterIP  198.19.128.1   <none>     443/TCP        23h


NAME                        ENDPOINTS                                   AGE

endpoints/deployment-2048   198.18.0.241:80,198.18.1.80:80              43s

endpoints/kubernetes        10.0.2.6:6443,10.0.2.7:6443,10.0.2.8:6443   23h




4

[root@s17f56ff32ee ~]# kubectl get deploy,svc,pod -o wide

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

deployment.apps/deployment-2048   2/2     2            2           69s   app-2048     alexwhen/docker-2048   app.kubernetes.io/name=app-2048

deployment.apps/tetris            2/2     2            2           38m   tetris       bsord/tetris           app=tetris


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

service/deployment-2048   LoadBalancer   198.19.179.93   default-deployment-2048-561dc-9982293-7ca0fdf4bfb0.sgn.lb.naverncp.com   80:32300/TCP   64s  app.kubernetes.io/name=app-2048

service/kubernetes        ClusterIP      198.19.128.1    <none>          443/TCP        8h    <none>

service/tetris            LoadBalancer   198.19.138.41   default-tetris-2245b-9982291-914a3d8e10c7.sgn.lb.naverncp.com            80:30512/TCP   38m   app=tetris


NAME                                   READY   STATUS    RESTARTS   AGE   IP             NODE           NOMINATED NODE   READINESS GATES

pod/deployment-2048-79785cfdff-lt6fq   1/1     Running   0          67s   198.18.0.248   node11-w-1n7   <none>           <none>

pod/deployment-2048-79785cfdff-mnjxh   1/1     Running   0          67s   198.18.1.31    node11-w-1n6   <none>           <none>

pod/tetris-78b8bb6fcb-5w22c            1/1     Running   0          16m   198.18.0.18    node11-w-1n7   <none>           <none>

pod/tetris-78b8bb6fcb-jfnw8      




<4>  게임 확인


1

웹 브라우저로 접속


 http://default-deployment-2048-561dc-9982293-7ca0fdf4bfb0.sgn.lb.naverncp.com/


2

방향키 사용

같은 숫자 합치기 게임




3

 k get ns


[root@s17f56ff32ee ~]# k get ns

NAME              STATUS   AGE

default           Active   8h

kube-node-lease   Active   8h

kube-public       Active   8h

kube-system       Active   8h



4

[root@s17f56ff32ee ~]# k get pods

No resources found in default namespace.



5

kubectl get deploy,svc,pod -o wide


[root@test11 ~]# kubectl get deploy,svc,pod -o wide

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

deployment.apps/deployment-2048   2/2     2            2           46s   app-2048     alexwhen/docker-2048   app.kubernetes.io/name=app-2048

deployment.apps/tetris            1/1     1            1           72s   tetris       bsord/tetris           app=tetris


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

service/deployment-2048   LoadBalancer   198.19.247.14    default-deployment-2048-c0d64-10251612-73e795b0c6f7.kr.lb.naverncp.com   80:30359/TCP   42s   app.kubernetes.io/name=app-2048

service/kubernetes        ClusterIP      198.19.128.1     <none>           443/TCP        23h   <none>

service/tetris            LoadBalancer   198.19.157.108   default-tetris-075d3-10251611-43faf1d23789.kr.lb.naverncp.com            80:30714/TCP   67s   app=tetris


NAME   READY   STATUS    RESTARTS   AGE   IP   NODE        NOMINATED NODE   READINESS GATES

pod/deployment-2048-79785cfdff-7jnb2   1/1     Running   0          46s   198.18.4.170   game1-node-pool-w-1106   <none>           <none>

pod/deployment-2048-79785cfdff-8lprm   1/1     Running   0          46s   198.18.2.175   game1-node-pool-w-1105   <none>           <none>

pod/tetris-78b8bb6fcb-9zsvq            1/1     Running   0          72s   198.18.2.159   game1-node-pool-w-1105   <none>           <none>

[root@test11 ~]#



6

2048 게임 - sing

http://default-deployment-2048-c0d64-10251612-73e795b0c6f7.kr.lb.naverncp.com/



테트리스 - sing

http://default-tetris-075d3-10251611-43faf1d23789.kr.lb.naverncp.com/





7

Global DNS

도메인

bestgame10.com 



http://1.bestgame10.com/


http://2.bestgame10.com/



8

Global DNS에서 

cname으로 로드밸런서 지정함  






<5> (몰아보기) 네이버 클라우드 컨테이너 서비스들 


https://brunch.co.kr/@topasvga/1863


감사합니다.

브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari