H.jenny
H.jenny

Reputation: 179

Can I get events from other resources in addition to the pod in Kubernetes?

When running this command for resources ( deployment, ReplicaSet ...) other than Pod

$ kubectl describe deployment xxx-deployment 

----           ------  ------

Events:          <none>

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?

Upvotes: 0

Views: 3227

Answers (3)

PjoterS
PjoterS

Reputation: 14092

Good explanation what is event in Kubernetes you can find in Types of Kubernetes Events article. Author also mentioned about types of events.

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.

You can describe not only pod, deployment or replicaset but almost all resources in kubernetes.

Examples:

  • 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
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    

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.

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  

Possibly root cause.

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.

It was also mentioned in Github thread.

In short, all events will disappear after 1 hour if you have this flag set.

To check if you have this flag set in kube-apiserver you can check this StackOverflow thread.

If this didn't help you please edit your question with informations like your configuration YAMLs, what version of K8s are you using, steps to reproduce etc.

Upvotes: 2

Dashrath Mundkar
Dashrath Mundkar

Reputation: 9184

Well yes deployment do have events. But keep that in mind events only available for around 1 hr.

enter image description here

Upvotes: 1

breizh5729
breizh5729

Reputation: 192

you can also filter by labels with --labelsfor describe all resources

Upvotes: 0

Related Questions