除了Kubernetes中的Pod之外,我还可以从其他资源中获取事件吗? [英] Can I get events from other resources in addition to the pod in Kubernetes?
问题描述
为Pod以外的资源(部署,ReplicaSet ...)运行此命令时
When running this command for resources ( deployment, ReplicaSet ...) other than Pod
$ kubectl describe deployment xxx-deployment
---- ------ ------
Events: <none>
我已经部署了一些资源,但是除了Pod之外,我还没有看过该活动.
I have deployed several resources, but I haven't seen the event yet except for Pod.
如果事件发生在其他资源中,将会发生什么类型的事件?
What type of event will occur if events occur in other resources?
您能推荐任何参考资料吗?
Could you recommend any materials to refer to?
推荐答案
好的解释Kubernetes
中的事件是什么,您可以在 Kubernetes事件的类型文章.作者还提到了事件类型.
Good explanation what is event in Kubernetes
you can find in Types of Kubernetes Events article. Author also mentioned about types of events.
Kubernetes事件是Kubernetes中的一种资源类型,当其他资源具有状态更改,错误或应向系统广播的其他消息时会自动创建.尽管没有太多有关事件的文档,但在调试Kubernetes集群中的问题时,它们是宝贵的资源.
Kubernetes events are a resource type in Kubernetes that are automatically created when other resources have state changes, errors, or other messages that should be broadcast to the system. While there is not a lot of documentation available for events, they are an invaluable resource when debugging issues in your Kubernetes cluster.
您不仅可以描述kubernetes中的pod
,deployment
或replicaset
,而且可以几乎所有资源.
You can describe not only pod
, deployment
or replicaset
but almost all resources in kubernetes.
示例:
-
kubectl describe job pi -n test
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 12s job-controller Created pod: pi-5rgbz
-
kubectl describe node ubuntu
kubectl describe node ubuntu
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning MissingClusterDNS 22h (x98 over 23h) kubelet, ubuntu-18 kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to "Default" policy.
Normal Starting 22h kubelet, ubuntu-18 Starting kubelet.
Warning InvalidDiskCapacity 22h kubelet, ubuntu-18 invalid capacity 0 on image filesystem
Normal NodeHasSufficientMemory 22h kubelet, ubuntu-18 Node ubuntu-18 status is now: NodeHasSufficientMemory
Normal NodeHasSufficientPID 22h
要列出您可以使用的所有资源事件
$ kubectl get events --all-namespaces
To list all resources events you can use
$ kubectl get events --all-namespaces
$ kubectl get events --all-namespaces
NAMESPACE LAST SEEN TYPE REASON OBJECT MESSAGE
default 50m Normal Starting node/gke-cluster-1-default-pool-XXXXXXXXXXXXX Starting kubelet.
default 50m Normal NodeHasSufficientMemory node/gke-cluster-1-default-pool-XXXXXXXXXXXXX Node gke-cluster-1-default-pool-XXXXXXXXXXXXX status is now: NodeHasSufficientMemory
default 2m47s Normal SuccessfulCreate job/pi Created pod: pi-5rgbz
kube-system 50m Normal ScalingReplicaSet deployment/fluentd-gcp-scaler Scaled up replica set fluentd-gcp-scaler-6855f55bcc to 1
在对象"列中,您输入资源类型.
In Object column you resource type.
如果您想了解更多详细信息,可以使用-o wide
标志-$ kubectl get events --all-namespaces -o wide
If you would like more detailed information you can use -o wide
flag - $ kubectl get events --all-namespaces -o wide
$ kubectl get events -o wide
LAST SEEN TYPE REASON OBJECT SUBOBJECT SOURCE MESSAGE
FIRST SEEN COUNT NAME
20m Normal Scheduled pod/hello-world-86d6c6f84d-8qz9d default-scheduler Successfully assigned default/hello-world-86d
6c6f84d-8qz9d to ubuntu-18
可能是根本原因.
一开始我没有任何事件都无法创建部署,我想您已经设置了--event-ttl
,这在
I wasn't able to create deployment without any event at the beginning I would guess that you have set --event-ttl
which is described in Kube-apiserver docs.
--event-ttl duration Default: 1h0m0s
保留事件的时间.
Amount of time to retain events.
在 Github线程中也提到过.
简而言之,如果您设置了此标志,所有事件将在1小时后消失.
要检查是否在kube-apiserver
中设置了此标志,可以检查此StackOverflow线程.
To check if you have this flag set in kube-apiserver
you can check this StackOverflow thread.
如果这对您没有帮助,请使用配置YAML,您使用的K8版本,复制步骤等信息来编辑您的问题.
这篇关于除了Kubernetes中的Pod之外,我还可以从其他资源中获取事件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!