Helm 包管理
生产集群必须能看:Pod 是否健康、资源占用、日志在哪里。K8s 提供基础的探针和日志,完整监控用 Prometheus + Grafana 生态。
健康检查探针
- livenessProbe:活着吗?挂了重启容器
- readinessProbe:就绪吗?就绪才接流量
日志
kubectl logs 看单个 Pod;多 Pod 日志聚合用 Loki 或 ELK;指标用 Prometheus 采集 + Grafana 展示。
代码示例
# Deployment 加探针
# spec:
# containers:
# - name: web
# livenessProbe:
# httpGet:
# path: /health
# port: 80
# initialDelaySeconds: 10
# periodSeconds: 5
# readinessProbe:
# httpGet:
# path: /ready
# port: 80
# initialDelaySeconds: 5
# periodSeconds: 5
# 看日志
kubectl logs deployment/web
kubectl logs -f pod/web-abc123
# 看资源占用
kubectl top nodes
kubectl top pods