[์ฟ ๋ฒ๋คํฐ์ค] concepts > workloads > management : ์ํฌ๋ก๋ ๊ด๋ฆฌ
Deployment, Service ๊ฐ์ ์ฌ๋ฌ ๋ฆฌ์์ค๋ฅผ ํจ๊ป ์์ฑํด์ผ ํ๋ค.
์ฌ๋ฌ ๋ฆฌ์์ค๋ฅผ ํ๋์ ํ์ผ์ ๋ชจ์๋๋ฉด ๊ด๋ฆฌ๊ฐ ๊ฐ๋จํด์ง๋ค.
(YAML์์๋ --- ๊ตฌ๋ถ์๋ฅผ ์ฌ์ฉํ๋ค.)
"The resources will be created in the order they appear in the manifest. Therefore, it's best to specify the Service first, since that will ensure the scheduler can spread the pods associated with the Service as they are created by the controller(s), such as Deployment."
1. ์ฟ ๋ฒ๋คํฐ์ค ๋งค๋ํ์คํธ ์์ฑ ์์ : ์ฌ๋ฌ ๋ฆฌ์์ค๊ฐ ์ ์๋ YAML์ ์ ํ ์์๋๋ก ์์ฑ๋๋ค.
--- ๊ตฌ๋ถ์ ์ฌ๋ฌ๊ฐ ์ฌ์ฉํ์ฌ Service -> Deployment -> ConfigMap ์์๋๋ก ์์ฑํ๋ค
2. Service๋ฅผ ๋จผ์ ๋๋ ์ด์ ๋
Service๊ฐ ๋จผ์ ๋ง๋ค์ด์ ธ ์์ด์ผ ๊ทธ ๋ค์ ์์ฑ๋๋ Deployment -> Pod ๋ค์ด Service์ ์ฆ์ ์ฐ๊ฒฐ๋๋ค
์ด๋ ๊ฒ๋๋ฉด, ์ค์ผ์ค๋ฌ๊ฐ ํ๋๋ฅผ ๋ฐฐ์นํ ๋, ์๋น์ค ๋จ์๋ก ํธ๋ํฝ ๊ท ๋ฑ ๋ถ์ฐ์ ํ ์ ์๊ฒ ๋์ด ํ๋๋ค์ด ํน์ ๋
ธ๋์ ๋ชฐ๋ฆฌ์ง ์๊ณ ๊ท ๋ฑํ๊ฒ ํผ์ง ํ๋ฅ ์ด ๋์์ง๋ค.
It is a recommended practice to put resources related to the same microservice or application tierinto the same file, and to group all of the files associated with your application in the samedirectory. If the tiers of your application bind to each other using DNS, you can deploy all ofthe components of your stack together.A URL can also be specified as a configuration source, which is handy for deploying directly frommanifests in your source control system:
๊ฐ์ ์๋น์ค์ ์ํ ๋ฆฌ์์ค๋ ํ๋์ YAML ํ์ผ์ ๋ฌถ์ด๋๋ ๊ฒ ์ข๋ค
์๋ฅผ ๋ค์ด,
1) frontend.yaml ์๋ Deployment(frontend) / Service(frontend)
2) backend.yaml ์๋ Deployment(backend) / Service(backend)
์ ์ฒด ์ ํ๋ฆฌ์ผ์ด์
๊ด๋ จ ํ์ผ์ ํ๋์ ๋๋ ํ ๋ฆฌ์ ๋ชจ์๋๋ ๊ฒ์ด ์ข๋ค
1) my-app / frontend.yaml, backend.yaml
๋ง์ดํฌ๋ก์๋น์ค ๊ฐ์ DNS ๊ธฐ๋ฐ์ผ๋ก ํต์ ํ๊ฒ ๋๋๋ฐ DNS๋ฅผ ํตํด ๋ฌถ์ฌ ์๋ค๋ฉด, ์ ์ฒด ์คํ์ ํ ๋ฒ์ ๋ฐฐํฌํด๋ ์ ์ ๋์ํ ์ ์๋ค.
- ๋ก์ปฌ์ ์ฌ๋ฌ ๋๋ ํ ๋ฆฌ์ ํฉ์ด์ ธ์๋ ๋งค๋ํ์คํธ๋ค์ ํ ๋ฒ์ ์ ์ฉํ๋ ๋ฐฉ๋ฒ
-R ์ต์
์ ์ฃผ๋ฉด, ํ์ ๋๋ ํ ๋ฆฌ๊น์ง ๋ชจ๋ ํ์ํด์ ๋ฆฌ์์ค๋ฅผ ์ ์ฉํ๊ฑฐ๋ ์ญ์ ํ ์ ์๋ค.
project/k8s/development
โโโ configmap
โ โโโ my-configmap.yaml
โโโ deployment
โ โโโ my-deployment.yaml
โโโ pvc
โโโ my-pvc.yaml
kubectl apply -f project/k8s/development --recursive
- ํ์ฉ๋ฐฉ์ : ํ๊ฒฝ๋ณ๋ก ๋๋ ํ ๋ฆฌ ๋ถ๋ฆฌ (development, staging, production ๋ฑ) โ ํ์์ ๋ฆฌ์์ค ์ ํ๋ณ๋ก ์ ๋ฆฌ