Deploy MicroService - TheOpenCloudEngine/uEngine-cloud GitHub Wiki

Deploy Microservices

Deploy customer

๋จผ์ €, ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋‚ด๋ ค๋ฐ›์Šต๋‹ˆ๋‹ค.

git clone https://github.com/TheOpenCloudEngine/istio-tutorial
cd istio-tutorial

์‹œ์ž‘์ „์— ๋จผ์ €, istioctl ์ด `PATH`์— ๊ฑธ๋ ค์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค:

$ istioctl version
Version: 1.0.2
GitRevision: d639408fded355fb906ef2a1f9e8ffddc24c3d64
User: root@66ce69d4a51e
Hub: gcr.io/istio-release
GolangVersion: go1.10.1
BuildStatus: Clean

Customer ๋ชจ๋“ˆ์˜ ๋นŒ๋“œ์™€ ํŒจํ‚ค์ง•

cd customer/java/springboot
mvn clean package
docker build -t gcr.io/uengine-istio-test/customer:v1 .
docker push gcr.io/uengine-istio-test/customer:v1
docker images | grep customer

๊ทธ๋Ÿฐํ›„์— Google Container Registry์— ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.

kubectl apply -f <(istioctl kube-inject -f ../../kubernetes/Deployment.yml)
kubectl create -f ../../kubernetes/Service.yml

Customer ๋ฅผ ๋…ธ์ถœ

๋‹ค์Œ์˜ ๋ช…๋ น์œผ๋กœ ํ•ด๋‹น ์›Œํฌ๋กœ๋“œ(pod)๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๊ธฐ๋™๋˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค:

kubectl get po -w

์ƒํƒœ (status) ํ”Œ๋ž˜๊ทธ๊ฐ€ Running ์ด๋ฉด์„œ 2/2 pods ๋กœ Ready ์ปฌ๋Ÿผ์— ํ‘œ์‹œ๋˜๋ฉด ์ •์ƒ์ ์œผ๋กœ sidecar ์™€ main ์›Œํฌ๋กœ๋“œ๊ฐ€ ๊ธฐ๋™๋˜์—ˆ์Œ์„ ํ™•์ธํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด. `Ctrl+C`๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ์ƒํƒœ๋ณด๊ธฐ์—์„œ ๋น ์ ธ๋‚˜์˜ต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐํ›„, Customer ๋ชจ๋“ˆ์„ ํ…Œ์ŠคํŠธํ•ฉ๋‹ˆ๋‹ค:

kubectl proxy # kube ํ”„๋ก์‹œ๋ฅผ ์˜คํ”ˆํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ 8001๋ฒˆ ํฌํŠธ๋กœ ์—ด๋ฆฌ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
curl http://..../api/v1/proxy/namespaces/default/services/customer:8080 # proxy ๋ฅผ ํ†ตํ•˜์—ฌ ์ ‘์†ํ•ฉ๋‹ˆ๋‹ค. .... ๋ถ€๋ถ„์€ ์ฝ˜์†” ์ƒ๋‹จ์˜ '์›น ๋ฏธ๋ฆฌ๋ณด๊ธฐ'์—์„œ ์„ค์ •ํ•˜์—ฌ ์—ด๋ฆฐ ์ฃผ์†Œ๋ฅผ ํ™•์ธํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋งˆ์ฐฌ๊ฐ€์ง€๋กœ preference ์™€ recommendation ์„œ๋น„์Šค ๋˜ํ•œ ์—ฐ๊ฒฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์—ฐ๊ฒฐํ•˜์ง€ ์•Š์œผ๋ฉด ํ•ด๋‹น ํƒ€์ผ“ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ๊ฐ€ ์„œ๋น„์Šค๋˜์ง€ ์•Š์•„ ํ˜ธ์ถœ์˜ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค:

customer => I/O error on GET request for "http://preference:8080": preference; nested exception is java.net.UnknownHostException: preference

๋‚ด๋ถ€์˜ ๋กœ๊ทธ๋ฅผ ์‚ดํŽด๋ณด๋ฉด,

stern customer -c customer

or

kubectl logs (customer pod ๋ช…) -c customer

๋‚ด๋ถ€์˜ ์ŠคํƒํŠธ๋ ˆ์ด์Šค๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://preference:8080": preference; nested exception is java.net.UnknownHostException: preference

๋ฉ”์ธ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ›„,

cd ../../..

preference, recommend ์„œ๋น„์Šค ๋“ค์˜ ๋ฐฐํฌ

๋™์ผํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ prefernce ์™€ recommendation ์„œ๋น„์Šค๋ฅผ ๋ฐฐํฌํ•ฉ๋‹ˆ๋‹ค.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ