[Kubernetes in Google Cloud] Kubernetes Engine: Qwik Start
GKE: Google 인프라를 사용하여 컨테이너형 애플리케이션을 배포, 관리 및 확장할 수 있는 관리 환경을 제공함
GKE 사용시의 이점
- Load balancing for Compute Engine instances
- Node pools to designate subsets of nodes within a cluster for additional flexibility
- Automatic scaling of your cluster's node instance count
- Automatic upgrades for your cluster's node software
- Node auto-repair to maintain node health and availability
- Logging and Monitoring with Cloud Monitoring for visibility into your cluster
1. gcloud auth list
: 활성된 계정 이름 나열하기
2. gcloud config list project
: 프로젝트 ID 나열하기
Task 1. Set a default compute zone(기본 컴퓨팅 영역 설정하기)
Compute zone: 클러스터와 해당 리소스가 상주하는 대략적인 지역 위치
1. compute region 셋팅하기
gcloud config set compute/region us-east4
2. compute zone 셋팅하기
gcloud config set compute/zone us-east4-c
Task 2. Create a GKE cluster(GKE 클러스터 생성하기)
1. 클러스터 생성하기
클러스터는: 하나 이상의 클러스터 마스터 시스템과 노드라고 하는 여러 작업자 시스템으로 구성
노드는 클러스터의 일부로 만드는 데 필요한 Kubernetes 프로세스를 실행하는 VM(컴퓨팅 엔진 가상 시스템) 인스턴스
*클러스터 이름은 문자로 시작해 영숫자로 끝나야하고 40문자를 넘을 수 없음
gcloud container clusters create --machine-type=e2-medium --zone=us-east4-c lab-cluster
결과
NAME: lab-cluster
LOCATION: us-east4-c
MASTER_VERSION: 1.22.8-gke.202
MASTER_IP: 34.67.240.12
MACHINE_TYPE: e2-medium
NODE_VERSION: 1.22.8-gke.202
NUM_NODES: 3
STATUS: RUNNING
Task 3. Get authentication credentials for the cluster(클러스터의 인증 자격 정보 가져오기)
클러스터 만든 후 클러스터와 상호작용하기 위한 인증 자격 필요
1. 인증 자격 가져오기
gcloud container clusters get-credentials lab-cluster
Task 4. Deploy an application to the cluster(클러스터에 애플리케이션 배포하기)
1. hello-app 컨테이너 이미지에서 새 배포 hello-server 생성하기
: kubectl create
kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0
2. 응용 프로그램을 외부 트래픽에 노출하기
: kubectl expose
kubectl expose deployment hello-server --type=LoadBalancer --port 8080
port와 Loadbalancer를 지정해줌
3. hello-server inspect하기
: kubectl get
kubectl get service
Task 5. Deleting the cluster(클러스터 삭제하기)
1. 클러스터 삭제하기
gcloud container clusters delete lab-cluster
gcloud container clusters delete [클러스터 이름]