GKE 실습

IMKUNYOUNG·2023년 5월 20일
0

쿠버네티스

목록 보기
9/64

kubernetes 클러스터 연결


kubectl get nodes

ur2kunyoung2@cloudshell:~ (username-2023-05-20)$ kubectl get nodes
NAME                                       STATUS   ROLES    AGE   VERSION
gke-cluster-2-default-pool-d83ca680-03ff   Ready    <none>   75m   v1.25.8-gke.500
gke-cluster-2-default-pool-d83ca680-nlr4   Ready    <none>   75m   v1.25.8-gke.500
gke-cluster-2-default-pool-d83ca680-rlw6   Ready    <none>   75m   v1.25.8-gke.500

kubectl create deploy tc --image=consol/tomcat-7.0 --replicas=5

ur2kunyoung2@cloudshell:~ (username-2023-05-20)$ kubectl create deploy tc --image=consol/tomcat-7.0 --replicas=5
deployment.apps/tc created

컨테이너 5개 생성


kubectl expose deploy tc --type=LoadBalancer --port=80 --target-port=8080

ur2kunyoung2@cloudshell:~ (username-2023-05-20)$ kubectl expose deploy tc --type=LoadBalancer --port=80 --target-port=8080
service/tc exposed

컨테이너 외부 노출


kubectl get pods,service

ur2kunyoung2@cloudshell:~ (username-2023-05-20)$ kubectl get pods,service
NAME                      READY   STATUS    RESTARTS   AGE
pod/tc-6d45db98df-5rgqw   1/1     Running   0          5m40s
pod/tc-6d45db98df-9srcf   1/1     Running   0          5m40s
pod/tc-6d45db98df-bwgn9   1/1     Running   0          5m40s
pod/tc-6d45db98df-qc4c8   1/1     Running   0          5m40s
pod/tc-6d45db98df-z2nwd   1/1     Running   0          5m40s

NAME                 TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)        AGE
service/kubernetes   ClusterIP      10.48.0.1      <none>         443/TCP        85m
service/tc           LoadBalancer   10.48.12.179   34.27.46.199   80:32287/TCP   4m17s

서비스는 포트를 외부로 노출 시키는 기능을 수행


로드밸런싱 되는지 확인


kubectl get pods -owide

ur2kunyoung2@cloudshell:~ (username-2023-05-20)$ kubectl get pods -owide
NAME                  READY   STATUS    RESTARTS   AGE   IP          NODE                                       NOMINATED NODE   READINESS GATES
tc-6d45db98df-5rgqw   1/1     Running   0          11m   10.44.2.5   gke-cluster-2-default-pool-d83ca680-03ff   <none>           <none>
tc-6d45db98df-9srcf   1/1     Running   0          11m   10.44.2.4   gke-cluster-2-default-pool-d83ca680-03ff   <none>           <none>
tc-6d45db98df-bwgn9   1/1     Running   0          11m   10.44.0.8   gke-cluster-2-default-pool-d83ca680-nlr4   <none>           <none>
tc-6d45db98df-qc4c8   1/1     Running   0          11m   10.44.1.5   gke-cluster-2-default-pool-d83ca680-rlw6   <none>           <none>
tc-6d45db98df-z2nwd   1/1     Running   0          11m   10.44.1.6   gke-cluster-2-default-pool-d83ca680-rlw6   <none>           <none>

파드가 어떤 노드에 거치되어 있는지 확인

0개의 댓글