Pods, Deployments, Services

K8sの基本3点セット。「状態」をYAMLで宣言する。

Pod
Kubernetesの最小単位。1つ以上のコンテナの集まり。
Deployment
「コンテナを常にN個動かし続ける」という宣言。自動復旧(Self-healing)の要。
Service
ネットワークの窓口。Podは死ぬがServiceのIPは変わらない。

Deployment Manifest

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3 # "Always keep 3 alive"
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.25