Struct kube_runtime::events::Recorder
source · [−]pub struct Recorder { /* private fields */ }
Expand description
A publisher abstraction to emit Kubernetes’ events.
All events emitted by an Recorder
are attached to the ObjectReference
specified when building the recorder using Recorder::new
.
use kube::{
core::Resource,
runtime::events::{Reporter, Recorder, Event, EventType}
};
use k8s_openapi::api::core::v1::ObjectReference;
let reporter = Reporter {
controller: "my-awesome-controller".into(),
instance: std::env::var("CONTROLLER_POD_NAME").ok(),
};
// references can be made manually using `ObjectMeta` and `ApiResource`/`Resource` info
let reference = ObjectReference {
// [...]
..Default::default()
};
// or for k8s-openapi / kube-derive types, use Resource::object_ref:
// let reference = myobject.object_ref();
let recorder = Recorder::new(client, reporter, reference);
recorder.publish(Event {
action: "Scheduling".into(),
reason: "Pulling".into(),
note: Some("Pulling image `nginx`".into()),
type_: EventType::Normal,
secondary: None,
}).await?;
Events attached to an object will be shown in the Events
section of the output of
of kubectl describe
for that object.
Implementations
Create a new recorder that can publish events for one specific object
This is intended to be createad at the start of your controller’s reconcile fn.
Publish a new Kubernetes’ event.
Access control
The event object is created in the same namespace of the ObjectReference
you specified in Recorder::new
.
Make sure that your controller has create
permissions in the required namespaces
for the event
resource in the API group events.k8s.io
.
Errors
Returns an Error
if the event is rejected by Kubernetes.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Recorder
impl !UnwindSafe for Recorder
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more