Pod
Kubernetes 应用 troubleshooting
· ☕ 3 分钟
设置合理的 Req 和 Limit 不设置 Req 和 Limit,当应用的 CPU、MEM 暴涨时,会危害同一节点上的其他 Pod,甚至导致集群节点一个接一个被压垮。 Req 和 Limit 一共有四个值,如果只设置部分值,当节点资源使用率达到 Kubelet 预设值时,Kubelet 会驱逐 Pod,驱逐的顺序

Kubernetes 集群 troubleshooting
· ☕ 6 分钟
FailedCreatePodSandBox 错误 Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:402: getting the final child's pid from pipe caused: EOF: unknown 处理 清理 cache 1 echo 3 > /proc/sys/vm/drop_caches 原因 内存碎片过多 calico-node 不停重启 increase max user 错误 runtime: failed to create new OS thread (have 11 already; errno=11),runtime: may need to increase max user processes (ulimit -u) 处理 增加 ulimit 限制额度 1 ulimit -u unlimited 原因 用户进程数耗尽 calico-node BIRD is not ready 错

Kubernetes Job 创建了近 3W Pod,差点导致严重事故
· ☕ 3 分钟
1. 相关背景 早上 10:00 因同事需求,我通过工具在集群上创建 Kubernetes Job 执行任务。 工具创建 Job 时,会拿到集群上的全部节点,然后逐个绑定节点创建 Job。例如,如下集群: 1 2 3 4 5 6 7 8 9 10 kubectl get node NAME STATUS ROLES AGE VERSION node2 Ready control-plane,master,worker 64d v1.16.11 node3 Ready control-plane,master,worker 64d v1.16.11 node4 Ready control-plane,master,worker 64d v1.16.11 node5 Ready worker 64d v1.16.11 node6 Ready worker 64d v1.16.11 node7 NotReady,SchedulingDisabled worker 64d

如何设置 Pod 到指定节点运行
· ☕ 4 分钟
1. 创建负载时,通过 nodeSelector 指定 Node 给节点添加标签 1 kubectl label node node2 project=A 指定 nodeSelector 创建工作负载 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 cat <<EOF | kubectl apply -f - apiVersion: apps/v1 kind: Deployment metadata: name: nginx-nodeselector spec: replicas: 1 selector: matchLabels: app: nginx-nodeselector template: metadata: labels: app: nginx-nodeselector spec: nodeSelector: project: A containers: - name: nginx image: nginx EOF 查看工作负载 1 2 3 4 kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES