Home > Net >  Create kubernetes events using kubernetes event api
Create kubernetes events using kubernetes event api

Time:04-01

I am pretty new in the kubernetes field, and have specific interest in kubernetes eventing. What I did was creating a K8 cluster, assign PODs to that cluster, and type kubectl get events command to see the corresponding events. Now for my work, I need to explore how can I create an K8 event resource using the eveting API provided here, so that using the kubectl get events command I can see the event stored in etcd. But as I mentioned I don't know K8 that deep, I'm struggling to make this api work.

N.B. I had a look into knative eventing, but seems to be the eventing feature Knative provides, is different than the K8 eveting, as I can't see the Knative events in the kubectl get events command. (please correct me if I am wrong).

Thanks in advance.

CodePudding user response:

Usually events are created in Kubernetes as a way of informing of relevant status changes of an object.

Creating an event is as simple as:

kubectl apply -f - <<EOF
apiVersion: v1
kind: Event
metadata:
  name: myevent
  namespace: default
type: Warning
message: 'not sure if this what you want to do'
involvedObject:
  kind: someObject
EOF

But usually this is done programmatically, using the Kubernetes client library of your choice and the core (v1) API group.

Knative Eventing is platform that enables Event Driven architectures, which does not seems related to your question, but if it were, you can find all getting started docs here:

CodePudding user response:

Maybe this could be helpfull to. Knative have this concepts of "Event Sources" that already exists and serves as links for events for certain producers and sinks.

In the case of the K8's events API there is one called the APIServer Source: https://knative.dev/docs/eventing/sources/apiserversource/

A bit more about Event Sources here: https://knative.dev/docs/eventing/sources/

  • Related