k8s DaemonSet:被拒绝的pod被重新创建得太快,无法获取任何日志或事件

时间:2018-06-06 14:11:58

标签: kubernetes project-calico

我遇到的问题完全相同:https://github.com/kubernetes/kubernetes/issues/51884

创建了calico节点,但又被直接删除了:

Jun 06 04:38:28 [..] I0606 08:38:28.170339       1 event.go:218] Event(v1.ObjectReference{Kind:"DaemonSet", Namespace:"kube-system", Name:"calico-node", UID:"10999117-6962-11e8-a147-0800278037c3", APIVersion:"extensions", ResourceVersion:"29749", FieldPath:""}): type: 'Normal' reason: 'SuccessfulCreate' Created pod: calico-node-rm2gl
Jun 06 04:38:28 [..] I0606 08:38:28.732348       1 event.go:218] Event(v1.ObjectReference{Kind:"DaemonSet", Namespace:"kube-system", Name:"calico-node", UID:"10999117-6962-11e8-a147-0800278037c3", APIVersion:"extensions", ResourceVersion:"29749", FieldPath:""}): type: 'Warning' reason: 'FailedDaemonPod' Found failed daemon pod kube-system/calico-node-rm2gl on node localhost.localdomain, will try to kill it
Jun 06 04:38:28 [..] E0606 08:38:28.755021       1 daemon_controller.go:265] kube-system/calico-node failed with : deleted 1 failed pods of DaemonSet kube-system/calico-node
Jun 06 04:38:28 [..] I0606 08:38:28.757246       1 event.go:218] Event(v1.ObjectReference{Kind:"DaemonSet", Namespace:"kube-system", Name:"calico-node", UID:"10999117-6962-11e8-a147-0800278037c3", APIVersion:"extensions", ResourceVersion:"29749", FieldPath:""}): type: 'Normal' reason: 'SuccessfulDelete' Deleted pod: calico-node-rm2gl

你能告诉我怎么解决这个问题吗? journalctl不打印pod失败的原因。并且甚至没有创建pod或者可以看到日志。

1 个答案:

答案 0 :(得分:0)

我找到了一个解决方案: 获取pod的yaml修改它并使用它进行部署。你需要在这里快速检索它,因为pod被删除得那么快。这就是为什么我们使用journalctl获取pod的真实姓名:

kubectl -n kube-system get pod $(sudo journalctl -e |grep calico-node- |awk '{print $NF}') -o yaml > calico_pod.yaml

你也可以这样做:

`kubectl -n kube-system get pod calico-node-<unique-hash> -o yaml > calico_pod.yaml`

但你需要非常快!

然后你可以对calico_pod.yaml做一些小改动,找出问题所在:

kubectl create -f calico_pod.yaml

我的问题是定义了cpu资源:

resources:
  requests:
    cpu: 250m

并且没有资源。