4์ 22์ผ ์๋ฃ /
๋ชฉํ
- Kubernetes Engine์ ์ฌ์ฉํ์ฌ ์์ ํ Kubernetes ํด๋ฌ์คํฐ๋ฅผ ํ๋ก๋น์ ๋ํฉ๋๋ค.
- kubectl์ ์ฌ์ฉํ์ฌ Docker ์ปจํ ์ด๋๋ฅผ ๋ฐฐํฌํ๊ณ ๊ด๋ฆฌํฉ๋๋ค.
- Kubernetes์ ๋ํ๋ก์ด๋จผํธ ๋ฐ ์๋น์ค๋ฅผ ์ฌ์ฉํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ง์ดํฌ๋ก์๋น์ค๋ก ๋ถํ ํฉ๋๋ค.
์งํ
gcloud config set compute/zone us-central1-b : ์์ญ ์ค์
gcloud container clusters create io : ํด๋ฌ์คํฐ ์์
> ์ํ ์ฝ๋ ๊ฐ์ ธ์ค๊ธฐ
gsutil cp -r gs://spls/gsp021/* . : GitHub ์ ์ฅ์ ํด๋ก
cd orchestrate-with-kubernetes/kubernetes : ๋๋ ํ ๋ฆฌ ๋ณ๊ฒฝ
ls : ์์
์ค์ธ ํ์ผ ํ์ธ
๊ฐ๋ตํ Kubernetes ๋ฐ๋ชจ
kubectl create deployment nginx --image=nginx:1.10.0 : nginx ์ปจํ
์ด๋์ ๋จ์ผ ์ธ์คํด์ค ์คํ
kubectl get pods : ์คํ ์ค์ธ nginx ์ปจํ
์ด๋ ํ์ธ
kubectl expose deployment nginx --port 80 --type LoadBalancer : Kubernetes ์ธ๋ถ๋ก ๋
ธ์ถ
-> Kubernetes๊ฐ ๋ฐฑ๊ทธ๋ผ์ด๋์์ ๊ณต๊ฐ IP ์ฃผ์๊ฐ ์ฒจ๋ถ๋ ์ธ๋ถ ๋ถํ ๋ถ์ฐ๊ธฐ ์์ฑ
kubectl get services : ์๋น์ค ๋์ด
curl http://<External IP>:80 : ์๊ฒฉ์ ์ผ๋ก Nginx ์ปจํ
์ด๋ ์กฐํ
> ํฌ๋
ํฌ๋ ๋ง๋ค๊ธฐ
cat pods/monolith.yaml
kubectl create -f pods/monolith.yaml
kubectl get pods
kubectl describe pods monolith
ํฌ๋์ ์ํธ์์ฉํ๊ธฐ
๋ ๋ฒ์งธ ํฐ๋ฏธ๋
kubectl port-forward monolith 10080:80
์ฒซ ๋ฒ์งธ ํฐ๋ฏธ๋
curl http://127.0.0.1:10080
curl http://127.0.0.1:10080/secure
curl -u user http://127.0.0.1:10080/login
TOKEN=$(curl http://127.0.0.1:10080/login -u user|jq -r '.token')
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:10080/secure
kubectl logs monolith
์ธ ๋ฒ์งธ ํฐ๋ฏธ๋
kubectl logs -f monolith
์ฒซ ๋ฒ์งธ ํฐ๋ฏธ๋
curl http://127.0.0.1:10080
-> ์ธ ๋ฒ์งธ ํฐ๋ฏธ๋์์ ๋ก๊ทธ๊ฐ ์
๋ฐ์ดํธ
kubectl exec monolith --stdin --tty -c monolith /bin/sh
ping -c 3 google.com
exit
> ์๋น์ค
์๋น์ค ๋ง๋ค๊ธฐ
cd ~/orchestrate-with-kubernetes/kubernetes
cat pods/secure-monolith.yaml
kubectl create secret generic tls-certs --from-file tls/
kubectl create configmap nginx-proxy-conf --from-file nginx/proxy.conf
kubectl create -f pods/secure-monolith.yaml
cat services/monolith.yaml
kubectl create -f services/monolith.yaml
gcloud compute firewall-rules create allow-monolith-nodeport \
--allow=tcp:31000
gcloud compute instances list
curl -k https://<EXTERNAL_IP>:31000
-> ์๊ฐ์ด ์ด๊ณผ๋ ์ด์ ?
ํฌ๋์ ๋ผ๋ฒจ ์ถ๊ฐํ๊ธฐ
kubectl get pods -l "app=monolith"
kubectl get pods -l "app=monolith,secure=enabled"
kubectl label pods secure-monolith 'secure=enabled'
kubectl get pods secure-monolith --show-labels
kubectl describe services monolith | grep Endpoints
gcloud compute instances list
curl -k https://<EXTERNAL_IP>:31000
> Kubernetes๋ก ์ ํ๋ฆฌ์ผ์ด์ ๋ฐฐํฌํ๊ธฐ
> ๋ํด๋ก์ด๋จผํธ ๋ง๋ค๊ธฐ
cat deployments/auth.yaml
kubectl create -f deployments/auth.yaml
kubectl create -f services/auth.yaml
kubectl create -f deployments/hello.yaml
kubectl create -f services/hello.yaml
kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf
kubectl create -f deployments/frontend.yaml
kubectl create -f services/frontend.yaml
kubectl get services frontend
curl -k https://<EXTERNAL-IP>
'๊ฐ๋ฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[GCP] Kubernetes Engine์์ Jenkins๋ก ์ง์์ ๋ฐฐํฌ (0) | 2023.04.23 |
---|---|
[GCP] Kubernetes Engine์ผ๋ก ๋ฐฐํฌ ๊ด๋ฆฌ (0) | 2023.04.23 |
[GCP] Kubernetes Engine: Qwik Start (1) | 2023.04.22 |
[GCP] Docker ์๊ฐ (0) | 2023.04.22 |
2023 ํด๋ผ์ฐ๋ ์คํฐ๋ ์ผ (์ฟ ๋ฒ๋คํฐ์ค ์ด๊ธ) (2) | 2023.04.17 |