podwatch

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabel

func AddLabel(pod *v1.Pod, key, value string) error

AddLabel adds the given label to the given pod.

func AddPodLabel

func AddPodLabel(name, project, namespace, key, value string) error

AddPodLabel adds a label to the XDC pod with the given name.

func GetPod added in v1.1.25

func GetPod(namespace, name, project string) (*v1.Pod, error)

GetPod returns the k8s Pod data gtiven a name and project.

func InitPodWatch

func InitPodWatch()

InitPodwatch is required to be called befora any podatch methods. Call in your client init().

func K8SClient

func K8SClient() *kubernetes.Clientset

func PodName

func PodName(pod *v1.Pod) (string, string, error)

PodName returns the Merge pod name,project for the pod is it is an XDC.

func RemoveLabel

func RemoveLabel(pod *v1.Pod, key string) error

RemoveLabel removes the given label from the given pod.

func RemovePodLabel

func RemovePodLabel(name, project, namespace, key string) error

RemovePodLabel - removes the label

Types

type MergePodType

type MergePodType int

MergePodType describes all possible pod types that Merge will spawn.

const (
	// NOTMERGE is not a merge pod.
	NOTMERGE MergePodType = iota

	// XDC is an XDC
	XDC

	// JUMP is an ssh jump host
	JUMP
)

func PodType

func PodType(pod *v1.Pod) (MergePodType, error)

PodType is a utility function that takes a pod and returns its type.

type PodEventType added in v1.2.3

type PodEventType int

Different types of callback types, defined here for convenience for users of this package

const (
	Create PodEventType = iota
	Update
	Delete
)

type PodWatcher

type PodWatcher struct {

	// On* functcions get called when that event happens. The interface is a k8s core API *v1.Pod.
	OnPodAdd    func(pod *v1.Pod)
	OnPodDelete func(obj *v1.Pod)
	OnPodUpdate func(prevObj, newObj *v1.Pod)

	// The namespace in which to watch for events. (The XDC namespace.)
	Namespace string

	// Control callback events.
	Unfiltered bool // if true get all underlying k8s pod events.

	// Number of workers to allocate to handle events. If not given, 10 is used.
	WorkerPoolSize int
}

PodWatcher encapsulates a client that gets pod events. Podwatcher gets events from k8s, filters out the noise, then invokes the given callbacks (OnPodadd, OnPodUpdate, OnPodDelete), in a worker thread.

func (*PodWatcher) Watch

func (pw *PodWatcher) Watch()

Watch keeps track of pod events and sets up the configured callbacks. This method does not return.

Jump to

Keyboard shortcuts

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