https://github.com/twin/kevent
Simple library for creating Kubernetes events
https://github.com/twin/kevent
event events kubernetes library
Last synced: 8 months ago
JSON representation
Simple library for creating Kubernetes events
- Host: GitHub
- URL: https://github.com/twin/kevent
- Owner: TwiN
- License: mit
- Created: 2022-11-13T23:45:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T01:58:36.000Z (over 1 year ago)
- Last Synced: 2025-02-01T11:34:43.948Z (over 1 year ago)
- Topics: event, events, kubernetes, library
- Language: Go
- Homepage:
- Size: 80.1 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kevent

[](https://pkg.go.dev/github.com/TwiN/kevent)
Very simple library for creating Kubernetes events.
```go
eventManager := kevent.NewEventManager(kubernetesClient, applicationName)
eventManager.Create(resourceNamespace, resourceKind, resourceName, reason, message, isWarning)
```
Where:
- `applicationName` is the name of the application that creates the event.
- `kubernetesClient` is a Kubernetes client (e.g. `kubernetes.Clientset`). Note that for testing purposes, the actual parameter type is kubernetes.Interface, which `kubernetes.Clientset` implements.
- `resourceNamespace` is the namespace of the resource that the event is related to.
- `resourceKind` is the kind of the resource that the event is related to.
- `resourceName` is the name of the resource that the event is related to.
- `reason` is the reason for the event (e.g. `FailedToCreate`, `Scheduled`, `FailedToSchedule`, etc.).
- `message` is the message for the event.
- `isWarning` is a boolean indicating whether the event is of type `Warning` or `Normal`.
Example:
```go
package main
import (
"github.com/TwiN/kevent"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
func main() {
clientConfig, _ := rest.InClusterConfig()
kubernetesClient, _ := kubernetes.NewForConfig(clientConfig)
eventManager := kevent.NewEventManager(kubernetesClient, "your-application-name")
eventManager.Create("kube-system", "pod", "nginx", "Deleted", "Application was unstable", true)
}
```