구클 쿠버네티스 생성해보자.
<1> Kubernetes 사용을 위한 2가지 API 서비스
<2> cloud shell 로 gke 만들자
<3> pod 만들고, 로드 밸런서 만들어 서비스 해보자
<4> 삭제
api 및 서비스에서 아래 2가지 서비스를 활성화 해야 한다.
Kubernetes Engine API
Container Registry API
1
export MY_ZONE=us-central1-a
2
gcloud container clusters create webfrontend --zone $MY_ZONE --num-nodes 2
inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-central1-a/webfrontend?project=qwiklabs-gcp-04-b34637ed67ba
kubeconfig entry generated for webfrontend.
NAME: webfrontend
LOCATION: us-central1-a
MASTER_VERSION: 1.24.9-gke.2000
MASTER_IP: 34.172.128.135
MACHINE_TYPE: e2-medium
NODE_VERSION: 1.24.9-gke.2000
NUM_NODES: 2
STATUS: RUNNING
2
쿠베네티스 가서 생성 되었는지 확인
0
테트리스 게임 설치
https://brunch.co.kr/@topasvga/3179
또는
nginx 이미지로 pod만들어 보기
1
cloud shell 사용
2
버전 확인
kubectl version
kubectl version --short
3
nginx 이미지로 pod만들어보자.
kubectl create deploy nginx --image=nginx:1.17.10
kubectl get pods
4
로드밸런서 생성
kubectl expose deployment nginx --port 80 --type LoadBalancer
5
생성 확인
kubectl get services, pods
6
pod를 3개로 조정해보자~ 스케일링 ~
kubectl scale deployment nginx --replicas 3
kubectl get services,pods
7
cloudshell $ kubectl version --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.26.1
Kustomize Version: v4.5.7
Server Version: v1.24.9-gke.2000
8
$ kubectl create deploy nginx --image=nginx:1.17.10
deployment.apps/nginx created
9
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-5fc59799db-lvvh4 1/1 Running 0 7s
10
$ kubectl expose deployment nginx --port 80 --type LoadBalancer
service/nginx exposed
11
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.52.0.1 <none> 443/TCP 7m8s
nginx LoadBalancer 10.52.12.91 34.170.187.129 80:32587/TCP 49s
12
$ kubectl get services,pods
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.52.0.1 <none> 443/TCP 7m26s
service/nginx LoadBalancer 10.52.12.91 34.170.187.129 80:32587/TCP 67s
NAME READY STATUS RESTARTS AGE
pod/nginx-5fc59799db-lvvh4 1/1 Running 0 89s
13
브라우저로 로드밸런서 접속해보기
14
파드 수를 늘려보자
3개로~
$ kubectl scale deployment nginx --replicas 3
deployment.apps/nginx scaled
15
kubectl get services,pods
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.52.0.1 <none> 443/TCP 8m3s
service/nginx LoadBalancer 10.52.12.91 34.170.187.129 80:32587/TCP 104s
NAME READY STATUS RESTARTS AGE
pod/nginx-5fc59799db-lvvh4 1/1 Running 0 2m6s
pod/nginx-5fc59799db-rjw5b 1/1 Running 0 22s
pod/nginx-5fc59799db-xjqc6 1/1 Running 0 22s
gcloud container clusters delete webfrontend --zone $MY_ZONE
https://brunch.co.kr/@topasvga/3094
감사합니다.