kevent

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2023 License: MIT Imports: 6 Imported by: 1

README

kevent

Go Reference

Very simple library for creating Kubernetes events.

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:

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)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventManager added in v0.1.0

type EventManager struct {
	// contains filtered or unexported fields
}

func NewEventManager added in v0.1.0

func NewEventManager(kubernetesClient kubernetes.Interface, component string) *EventManager

NewEventManager creates a new EventManager with the given parameters.

func (*EventManager) Create added in v0.1.0

func (em *EventManager) Create(resourceNamespace, resourceKind, resourceName, reason, message string, isWarning bool)

Create creates a Kubernetes Event with the given parameters.

func (*EventManager) EnableDebugLogs added in v0.1.1

func (em *EventManager) EnableDebugLogs()

EnableDebugLogs enables debug logs for the EventManager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL