Lab2
Google Kubernetes Engine์ ๋ฐฐํฌ, ๊ด๋ฆฌ ๊ทธ๋ฆฌ๊ณ scaling your containerized applicationํ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค.
GKE ํด๋ฌ์คํฐ๋ฅผ ์คํ ์์ benefits
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. Set a default compute zone
gcloud config set compute/zone us-central1-a
zone์ ์ง์ ํ๋ค.
2. Create a CKE cluster
cluster๋ ์ต์ ํ๋์ cluster master machine์ ํฌํจํ๋ฉฐ, โ๋ ธ๋'๋ผ๊ณ ๋ถ๋ฆฌ๋ ๋ค์์ worker machine์ ๊ฐ์ง๊ณ ์๋ค.
Nodes : Compute Engine virtual machine (VM) instances that run the Kubernetes processes necessary to make them part of the cluster. ์ฟ ๋ฒ๋คํฐ์ค ํ๋ก์ธ์ค๋ฅผ ์คํํ๋ ๊ฐ์๋จธ์ ์ธ์คํด์ค๋ค.
gcloud container clusters create [CLUSTER-NAME]

3. Get authentication credentials for the cluster
ํด๋ฌ์คํฐ ์์ฑ ํ authentication credential์ ๋ฐ์ interact ํด์ผ ํ๋ค.
gcloud container clusters get-credentials [CLUSTER-NAME]
์ธ์ฆ๋ฐ๊ธฐ ์ํด์๋ ์ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ๋ค.

4. Deploy an application to the cluster
์ด์ ํด๋ฌ์คํฐ์ ์ปจํ ์ด๋ํ ๋ ์ดํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํด๋ณด์.
GKE๋ ํด๋ฌ์คํฐ์ ์์์ ์์ฑํ๊ณ ๊ด๋ฆฌํ๊ธฐ ์ํด Kubernetes objects๋ฅผ ์ฌ์ฉํ๋ค.
kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0
์์ ์ฟ ๋ฒ๋คํฐ์ค ๋ช ๋ น์ด๋ hello-server๋ผ๋ Deployment object๋ฅผ ์ํํ๋ค.
--image ๋ ๋ฐฐํฌํ ์ปจํ ์ด๋ ์ด๋ฏธ์ง๋ฅผ ๋ช ์ํ๋ค.
๋ช ๋ น์ด๋ Container Registry ๋ฒํท์ผ๋ก๋ถํฐ ์ด๋ฏธ์ง๋ฅผ pull ํ๋ค.
[gcr.io/google-samples/hello-app:1.0](<http://gcr.io/google-samples/hello-app:1.0>) ์ pull ํด ์ฌ ์ด๋ฏธ์ง์ ์์ธ ๋ฒ์ ๋ฑ์ ๋ช ์ํ๋ค. ๋ง์ฝ ๋ฒ์ ์ด ๋ช ์๋์ด ์์ง ์์ผ๋ฉด ๊ฐ์ฅ ์ต์ ๋ฒ์ ์ ์ฌ์ฉํ๋ค.
kubectl expose deployment hello-server --type=LoadBalancer --port 8080
์ฟ ๋ฒ๋คํฐ์ค ์๋น์ค๋ฅผ ์์ฑํ๊ธฐ ์ํด ์ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ๋ค.
--port ๋ ์ปจํ ์ด๋๊ฐ expose ํ ํฌํธ ๋ฒํธ๋ฅผ ๋ช ์ํ๋ค.
type="LoadBalancer" ๋ ์ปจํ ์ด๋๋ฅผ ์ํ Compute Engine load balancer๋ฅผ ์์ฑํ๋ค.
kubectl get service
hello-server ์ ๊ฒํ๊ธฐ ์ํ ๋ช ๋ น์ด

http://[EXTERNAL-IP]:8080
์์ external ip ์ฃผ์๋ฅผ ์ ๋ ฅํด์ ์น ์ฐฝ์ ์น๋ฉด ํด๋น ์ดํ๋ฆฌ์ผ์ด์ ์ ์น ๋ธ๋ผ์ฐ์ ์์ ํ์ธํ ์ ์๋ค.

5. Deleting the cluster
gcloud container clusters delete [CLUSTER-NAME]
GKE ํด๋ฌ์คํฐ๋ฅผ ์คํ ์, benefits
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
Last updated