spec.containers[].ports[].containerPort:容器监听端口,常和 Service 的 targetPort 对应。
spec.restartPolicy:Pod 默认 Always;Job/CronJob 模板里常用 Never 或 OnFailure。
resources.requests/limits:调度和限制资源,常考 CPU、内存格式。
livenessProbe:存活检查,失败会重启容器。
readinessProbe:就绪检查,失败时不会接入 Service endpoints。
常用命令
1
2
3
4
5
6
k run nginx-pod --image=nginx --restart=Never -n dev
k run nginx-pod --image=nginx --restart=Never --dry-run=client -o yaml > pod.yaml
k get pod -n dev --show-labels
k describe pod nginx-pod -n dev
k logs nginx-pod -n dev
k exec -it nginx-pod -n dev -- sh