[์ฟ ๋ฒ๋คํฐ์ค] ์ฟ ๋ฒ๋คํฐ์ค ๋ฆฌ์์ค ๊ตฌ์กฐ ์ดํดํ๊ธฐ - kind, metadata, spec
apiVersion:
kind:
metadata:
spec:
https://kubernetes.io/docs/concepts/overview/working-with-objects/#required-fields
Objects In Kubernetes
Kubernetes objects are persistent entities in the Kubernetes system. Kubernetes uses these entities to represent the state of your cluster. Learn about the Kubernetes object model and how to work with these objects.
kubernetes.io
spec์ ๋ฆฌ์์ค์ ์ํ๋ ์ํ๋ฅผ ์ ์ํ๋๋ฐ ์ด ๋ถ๋ถ์ด Kind๋ง๋ค ๋ค๋ฅด๋ค
https://kubernetes.io/docs/concepts/overview/working-with-objects/#object-spec-and-status
Objects In Kubernetes
Kubernetes objects are persistent entities in the Kubernetes system. Kubernetes uses these entities to represent the state of your cluster. Learn about the Kubernetes object model and how to work with these objects.
kubernetes.io
Pod : ์ปจํ ์ด๋ ์คํ์ ์ต์ ๋จ์ (์ง๊ธ ์ฌ์ฉ ์ค)
Deployment: Pod๋ฅผ ์ฌ๋ฌ ๊ฐ ์์ฑ/์ ๋ฐ์ดํธ/๋กค๋ฐฑ ๊ด๋ฆฌ
ReplicaSet: Pod ๋ณต์ ๋ณธ ์ ์ ์ง (๋ณดํต Deployment๊ฐ ์๋ ๊ด๋ฆฌ)
StatefulSet: ์ํ๊ฐ ์๋ ์ฑ(DB ๋ฑ) - ์์ ๋ณด์ฅ, ๊ณ ์ ์ด๋ฆ
DaemonSet: ๋ชจ๋ ๋ ธ๋์ Pod 1๊ฐ์ฉ ์คํ (๋ก๊ทธ ์์ง, ๋ชจ๋ํฐ๋ง ๋ฑ)
Job : ํ ๋ฒ ์คํํ๊ณ ๋๋๋ ์์
CronJob : ์ค์ผ์ค์ ๋ฐ๋ผ ๋ฐ๋ณต ์คํํ๋ Job
Service: Pod์ ์์ ์ ์ธ ๋คํธ์ํฌ ์ ์ ์ ๊ณต (์ง๊ธ ์ฌ์ฉ์ค)
Ingress: ์ธ๋ถ HTTP ํธ๋ํฝ์ Service๋ก ๋ผ์ฐํ (๋๋ฉ์ธ/๊ฒฝ๋ก ๊ธฐ๋ฐ)
NetworkPolicy: Pod๊ฐ ๋คํธ์ํฌ ํธ๋ํฝ ์ ์ด (๋ฐฉํ๋ฒฝ)
ConfigMap : ์ค์ ๊ฐ ์ ์ฅ (ํ๊ฒฝ๋ณ์, ์ค์ ํ์ผ)
Secret: ๋ฏผ๊ฐํ ๋ฐ์ดํฐ ์ ์ฅ (๋น๋ฐ๋ฒํธ, ํ ํฐ)
PersistentVolume (PV) : ๋ฌผ๋ฆฌ ์คํ ๋ฆฌ์ง
PersistentVolumeClaim (PVC) : PV ์์ฒญ (Pod๊ฐ ์คํ ๋ฆฌ์ง ์ฌ์ฉ ์)
Namespace : ๋ฆฌ์์ค๋ฅผ ๋ ผ๋ฆฌ์ ์ผ๋ก ๋ถ๋ฆฌ
ServiceAccount : Pod์ ์ธ์ฆ ID
Role/ClusterRole : ๊ถํ ์ ์
RoleBinding/ClusterRoleBinding : ๊ถํ์ SA/์ฌ์ฉ์์ ๋ถ์ฌ
Pod์ spec → "์ด๋ค ์ปจํ ์ด๋๋ฅผ ์คํํ ๊ฒ์ธ๊ฐ"
spec:
containers:
- name: redis
image: redis:alpine
ports:
- containerPort: 6379
Service์ spec → "์ด๋ค Pod์ ์ด๋ป๊ฒ ๋คํธ์ํฌ๋ฅผ ์ฐ๊ฒฐํ ๊ฒ์ธ๊ฐ"
spec:
type: NodePort
ports:
- port: 8080 # ํด๋ฌ์คํฐ ๋ด๋ถ์์ ์๋น์ค ์ ๊ทผ ํฌํธ
targetPort: 80 # Pod์ ์ด๋ ํฌํธ๋ก ๋ณด๋ผ์ง
nodePort: 31000 # ์ธ๋ถ์์ ์ ๊ทผํ๋ ํฌํธ
selector: # label์ด ์ผ์นํ๋ Pod๋ฅผ ์ฐพ์ ์ฐ๊ฒฐ
app: redis
Deployment์ spec → "Pod๋ฅผ ๋ช ๊ฐ, ์ด๋ป๊ฒ ๊ด๋ฆฌํ ๊ฒ์ธ๊ฐ"
spec:
replicas: 3
selector:
matchLabels:
app: redis
template: # Pod ํ
ํ๋ฆฟ (์์ ๋ metadata + spec)
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:alpine
Service์ spec.selector.{key} : {value} == Pod์ metadata.labels.{key} : {value}
https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service
Service
Expose an application running in your cluster behind a single outward-facing endpoint, even when the workload is split across multiple backends.
kubernetes.io
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/