podwatcher

package
v0.0.0-...-2c55fd6 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractContainersFromPod

func ExtractContainersFromPod(pod *corev1.Pod) map[string]*Container

Types

type Container

type Container struct {
	PodName            string
	Namespace          string
	Name               string
	PodUID             string
	UID                string
	InitContainer      bool
	State              *corev1.ContainerState
	LoggregatorOptions config.LoggregatorOptions
	Loggregator        *Loggregator
	AppMeta            *LoggregatorAppMeta
}

func (*Container) Read

func (c *Container) Read(LoggregatorOptions config.LoggregatorOptions, KubeConfig *rest.Config, wg *sync.WaitGroup)

func (*Container) Tail

func (c *Container) Tail(kubeClient *kubernetes.Clientset) error

Tail connects to the Kube

type ContainerList

type ContainerList struct {
	Containers         map[string]*Container
	KubeConfig         *rest.Config
	LoggregatorOptions config.LoggregatorOptions
	Tails              sync.WaitGroup
}

func (*ContainerList) AddContainer

func (cl *ContainerList) AddContainer(c *Container)

func (ContainerList) EnsureContainer

func (cl ContainerList) EnsureContainer(c *Container) error

EnsureContainer make sure the container exists in the list and we are monitoring it.

func (*ContainerList) EnsurePodStatus

func (cl *ContainerList) EnsurePodStatus(pod *corev1.Pod) error

EnsurePodStatus handles a pod event by adding or removing container tailing goroutines. Every running container in the monitored namespace has its own goroutine that reads its log stream. When a container is stopped we stop the relevant gorouting (if it is still running, it could already be stopped because of an error).

func (*ContainerList) GetContainer

func (cl *ContainerList) GetContainer(uid string) (*Container, bool)

func (*ContainerList) RemoveContainer

func (cl *ContainerList) RemoveContainer(uid string) error

func (*ContainerList) UpdateContainer

func (cl *ContainerList) UpdateContainer(c *Container) error

UpdateContainer decides whether a container should be added, left alone or removed from the container list. It does that but checking the state of of the container.

type Loggregator

type Loggregator struct {
	Meta              *LoggregatorAppMeta
	ConnectionOptions config.LoggregatorOptions
	KubeClient        *kubernetes.Clientset
	LoggregatorClient *loggregator.IngressClient
}

func NewLoggregator

func NewLoggregator(m *LoggregatorAppMeta, kubeClient *kubernetes.Clientset, connectionOptions config.LoggregatorOptions) *Loggregator

func (*Loggregator) Envelope

func (l *Loggregator) Envelope(message []byte) *loggregator_v2.Envelope

func (*Loggregator) SetupLoggregatorClient

func (l *Loggregator) SetupLoggregatorClient() error

func (*Loggregator) Tail

func (l *Loggregator) Tail(namespace, pod, container string) error

func (*Loggregator) Write

func (l *Loggregator) Write(b []byte) (int, error)

type LoggregatorAppMeta

type LoggregatorAppMeta struct {
	SourceID, InstanceID                               string
	SourceType, PodName, Namespace, Container, Cluster string // Custom tags
}

type LoggregatorLogger

type LoggregatorLogger struct{}

func (LoggregatorLogger) Panicf

func (LoggregatorLogger) Panicf(message string, args ...interface{})

func (LoggregatorLogger) Printf

func (LoggregatorLogger) Printf(message string, args ...interface{})

type PodWatcher

type PodWatcher struct {
	Config     config.ConfigType
	Containers ContainerList
	Manager    eirinix.Manager
}

func NewPodWatcher

func NewPodWatcher(config config.ConfigType) *PodWatcher

func (*PodWatcher) EnsureLogStream

func (pw *PodWatcher) EnsureLogStream(manager eirinix.Manager) error

EnsureLogStream ensures that the already running pod logs are tracked and sets the latest RV found to be able to track future changes. It gets the current RV to start watching on and reads the pods currently running in the namespace to process them with EnsurePodStatus. This allows the PodWatcher to stream logs of currently running pods if restarted (or updated).

func (*PodWatcher) Finish

func (pw *PodWatcher) Finish()

func (*PodWatcher) Handle

func (pw *PodWatcher) Handle(manager eirinix.Manager, e watch.Event)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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