apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
spec:
replicas: 3 # Хочу 3 экземпляра
selector:
matchLabels:
app: nginx
template: # Шаблон пода
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
resources: # Лимиты (Request/Limit) - ОБЯЗАТЕЛЬНО
requests:
memory: "64Mi"
cpu: "250m" # 0.25 ядра
limits:
memory: "128Mi"
cpu: "500m" apiVersion: v1
kind: Service
metadata:
name: web-service
spec:
selector:
app: nginx # Трафик пойдет на поды с лейблом app: nginx
ports:
- protocol: TCP
port: 80 # Порт сервиса
targetPort: 80 # Порт контейнера
type: ClusterIP # Доступен только внутри кластера watch kubectl get pods kubectl set image deployment/web-app nginx=nginx:1.23 kubectl rollout undo deployment/web-app