Created event failed if 'eventTime' doesn't be set 'null'

Cluster information:

Kubernetes version: v1.19.0
Cloud being used: bare-metal
Installation method: kubeadm
Host OS: centOS7

Hi experts, I try to create an event which refers to cluster-scoped resources in involvedObject . If I use below yaml, I get this error The Event "master-0.zwg98" is invalid: involvedObject.namespace: Invalid value: "": does not match event.namespace , than, I remove the eventTime or set it to null, the event will be created successfully.
I want to know how to use eventTime in kubernetes events, please come up with some idea for me to understand this issue

action: Test action
apiVersion: v1
eventTime: "2022-01-21T08:40:54.132918Z"
firstTimestamp: null
  apiVersion: v1
  kind: Node
  name: master-0
  #namespace: default
  resourceVersion: "11404858"
  uid: fefc2644-55b7-42c2-8e03-fa19d1889cbf
kind: Event
lastTimestamp: null
message: Test message
  generateName: master-0.
  name: master-0.zwg98
  namespace: default
reason: Test
reportingComponent: ""
reportingInstance: ""
  component: my-component
type: Normal

Please refer to: kubernetes/events.go at bd6b5b12297968004ca8697890ea8b315f187214 · kubernetes/kubernetes · GitHub

1 Like