brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Feb 26. 2021

149.구글 클라우드 클라우드 쉘로  GKE-2/8


구글 클라우드 Cloud shell로  GKE만들어보자



<1> API 서비스 활성화 하기

<2> cloud shell에서 GKE만들기

<3>  kubecrl  로 pods등 만들어 보자

<4>  다른 예제 



<1> API 서비스 활성화 하기


Kubernetes Engine > 클러스터 > 만들기 하면 API 활성화 할것인지 물어본다


또는


1

제품 및 리소스 검색에서  

API 및 서비스  검색 하기

Kubernetes Engine API


2

Kubernetes Engine API



3

Kubernetes Engine API  사용으로 클릭해 활성화 하기






<2> Cloud shell에서 GKE만들기


1

화면 오른쪽 위 cloud shell 실행



2

리전 지정

export MY_ZONE=us-central1-a


gcloud container clusters create webfrontend --zone $MY_ZONE --num-nodes 2

승인


3

프로젝트 지정이 안되었다고 오류가 난다면 먼저 프로젝트를 지정한다.

아니면 만들어 진다.

“gcloud config set project [PROJECT_ID]” to change to a different project.


gcloud config set project versatile-lotus-3060xxxxx


4

다시 만들어 보기

gcloud container clusters create webfrontend --zone $MY_ZONE --num-nodes 2


5

아래처럼 오류가 나면 

+ API 및 서비스   > 사용 클릭하지 않은것이다.



6

사용 클릭

7

5분 걸림

gcloud container clusters create webfrontend --zone $MY_ZONE --num-nodes 2

topasseoseo1@cloudshell:~ (secret-zephyr-348001)$ gcloud container clusters create webfrontend --zone $MY_ZONE --num-nodes 2

Default change: VPC-native is the default mode during cluster creation for versions greater than 1.21.0-gke.1500. To create advanced routes based clusters, please pass the `--no-enable-ip-alias` flag

Note: Your Pod address range (`--cluster-ipv4-cidr`) can accommodate at most 1008 node(s).

Creating cluster webfrontend in us-central1-a... Cluster is being health-checked (master is healthy)...done.     

Created [https://container.googleapis.com/v1/projects/secret-zephyr-348001/zones/us-central1-a/clusters/webfrontend].

To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-central1-a/webfrontend?project=secret-zephyr-348001

kubeconfig entry generated for webfrontend.

NAME: webfrontend

LOCATION: us-central1-a

MASTER_VERSION: 1.21.6-gke.1503

MASTER_IP: 34.132.132.246

MACHINE_TYPE: e2-medium

NODE_VERSION: 1.21.6-gke.1503

NUM_NODES: 2

STATUS: RUNNING


8

nodes  확인

kubectl get nodes


topasseoseo1@cloudshell:~ (secret-zephyr-348001)$ kubectl get nodes

NAME                                         STATUS   ROLES    AGE    VERSION

gke-webfrontend-default-pool-0bc06dde-gsqw   Ready    <none>   2m8s   v1.21.6-gke.1503

gke-webfrontend-default-pool-0bc06dde-r30r   Ready    <none>   2m8s   v1.21.6-gke.1503








<3>  kubecrl  로 pods등 만들어 보자


3

kubecrl 버전 확인

kubectl version 


4

kubectl create deploy nginx --image=nginx:1.17.10


5

kubectl get pods

NAME                     READY   STATUS    RESTARTS   AGE

nginx-674c77bcbb-hdmrr   1/1     Running   0          8s



6

로드밸런서 연결

kubectl expose deployment nginx --port 80 --type LoadBalancer


7

로드밸런서 확인

kubectl get services

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

kubernetes   ClusterIP      10.52.0.1     <none>         443/TCP        7m2s

nginx        LoadBalancer   10.52.4.151   34.122.99.68   80:32323/TCP   45s

topasseoseo1@cloudshell:~ (secret-zephyr-348001)$



8

웹 브라우저료 접속 확인




9

pod수 3개로 늘리기

kubectl scale deployment nginx --replicas 3



10

확인

kubectl get pods


NAME                     READY   STATUS    RESTARTS   AGE

nginx-674c77bcbb-h466z   1/1     Running   0          11s

nginx-674c77bcbb-hdmrr   1/1     Running   0          4m29s

nginx-674c77bcbb-t7skf   1/1     Running   0          11s




11

콜솔 확인

네트워크 > 부하분산에서 LB 를  확인한다



13

LB에 매칭되어 있는 인스턴스  확인



14

웹 브라우저로 LB 공인 IP로   접속 확인




15

삭제

gcloud container clusters delete xxxxx-cluster 



다음 공부


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






<4>  다른 예제 참고하자




다른 자료~

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


감사합니다.



매거진의 이전글 148. 구글 클라우드 가입, 가상 서버 만들기-1/8

작품 선택

키워드 선택 0 / 3 0

댓글여부

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