beater

package
v0.0.0-...-364af87 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TAIL_LOGS_METHOD   string = "tail"
	FOLLOW_LOGS_METHOD string = "follow"
	MAX_TAIL_LOGGERS   int    = 15
)
View Source
const (
	ELASTIC_ENV_USERNAME = "KUBEAT_ELASTIC_USERNAME"
	ELASTIC_ENV_PASSWORD = "KUBEAT_ELASTIC_PASSWORD"
)

Variables

This section is empty.

Functions

func GetTickFromFlags

func GetTickFromFlags() int

func NewDB

func NewDB() (*memdb.MemDB, error)

NewDB creates a new MemDB instance

Types

type Annotations

type Annotations struct {
	ChecksumConfig     string `json:"checksum/config"`
	OpenshiftIoScc     string `json:"openshift.io/scc"`
	PrometheusIoPath   string `json:"prometheus.io/path"`
	PrometheusIoPort   string `json:"prometheus.io/port"`
	PrometheusIoScrape string `json:"prometheus.io/scrape"`
}

type Capabilities

type Capabilities struct {
	Drop []string `json:"drop"`
}

type Conditions

type Conditions struct {
	Type               string      `json:"type"`
	Status             string      `json:"status"`
	LastProbeTime      interface{} `json:"lastProbeTime"`
	LastTransitionTime time.Time   `json:"lastTransitionTime"`
}

type ConfigMap

type ConfigMap struct {
	Name        string `json:"name"`
	DefaultMode int    `json:"defaultMode"`
}

type ContainerStatuses

type ContainerStatuses struct {
	Name         string    `json:"name"`
	State        State     `json:"state"`
	Ready        bool      `json:"ready"`
	RestartCount int       `json:"restartCount"`
	Image        string    `json:"image"`
	ImageID      string    `json:"imageID"`
	ContainerID  string    `json:"containerID"`
	LastState    LastState `json:"lastState,omitempty"`
}

type Containers

type Containers struct {
	Name                     string          `json:"name"`
	Image                    string          `json:"image"`
	Command                  []string        `json:"command"`
	Args                     []string        `json:"args,omitempty"`
	Ports                    []Ports         `json:"ports"`
	Resources                Resources       `json:"resources"`
	VolumeMounts             []VolumeMounts  `json:"volumeMounts"`
	LivenessProbe            LivenessProbe   `json:"livenessProbe"`
	ReadinessProbe           ReadinessProbe  `json:"readinessProbe,omitempty"`
	TerminationMessagePath   string          `json:"terminationMessagePath"`
	TerminationMessagePolicy string          `json:"terminationMessagePolicy"`
	ImagePullPolicy          string          `json:"imagePullPolicy"`
	SecurityContext          SecurityContext `json:"securityContext"`
	Env                      []Env           `json:"env,omitempty"`
}

type ElasticClient

type ElasticClient struct {
	Client *elastic.Client
	// contains filtered or unexported fields
}

func (*ElasticClient) Connect

func (e *ElasticClient) Connect(conf *SenderConfig) (err error)

func (*ElasticClient) Push

func (e *ElasticClient) Push(l map[int64]LogMessage) error

type EmptyDir

type EmptyDir struct {
}

type Env

type Env struct {
	Name      string      `json:"name"`
	Value     string      `json:"value,omitempty"`
	ValueFrom interface{} `json:"valueFrom,omitempty"`
}

type Exec

type Exec struct {
	Command []string `json:"command"`
}

type FieldRef

type FieldRef struct {
	APIVersion string `json:"apiVersion"`
	FieldPath  string `json:"fieldPath"`
}

type ImagePullSecrets

type ImagePullSecrets struct {
	Name string `json:"name"`
}

type InitContainerStatuses

type InitContainerStatuses struct {
	Name         string    `json:"name"`
	State        State     `json:"state"`
	LastState    LastState `json:"lastState"`
	Ready        bool      `json:"ready"`
	RestartCount int       `json:"restartCount"`
	Image        string    `json:"image"`
	ImageID      string    `json:"imageID"`
	ContainerID  string    `json:"containerID"`
}

type InitContainers

type InitContainers struct {
	Name                     string          `json:"name"`
	Image                    string          `json:"image"`
	Command                  []string        `json:"command,omitempty"`
	Args                     []string        `json:"args"`
	Resources                Resources       `json:"resources"`
	VolumeMounts             []VolumeMounts  `json:"volumeMounts"`
	TerminationMessagePath   string          `json:"terminationMessagePath"`
	TerminationMessagePolicy string          `json:"terminationMessagePolicy"`
	ImagePullPolicy          string          `json:"imagePullPolicy"`
	SecurityContext          SecurityContext `json:"securityContext"`
	Env                      []Env           `json:"env,omitempty"`
}

type Labels

type Labels struct {
	App                            string `json:"app"`
	ControllerRevisionHash         string `json:"controller-revision-hash"`
	Release                        string `json:"release"`
	StatefulsetKubernetesIoPodName string `json:"statefulset.kubernetes.io/pod-name"`
}

type LastState

type LastState struct {
	Terminated Terminated `json:"terminated"`
}

type LivenessProbe

type LivenessProbe struct {
	Exec                Exec `json:"exec"`
	InitialDelaySeconds int  `json:"initialDelaySeconds"`
	TimeoutSeconds      int  `json:"timeoutSeconds"`
	PeriodSeconds       int  `json:"periodSeconds"`
	SuccessThreshold    int  `json:"successThreshold"`
	FailureThreshold    int  `json:"failureThreshold"`
}

type LogMessage

type LogMessage struct {
	PodName    string                 `json:"pod_name"`
	Namespace  string                 `json:"namespace"`
	Container  string                 `json:"container"`
	Message    string                 `json:"message"`
	SenderTime time.Time              `json:"sender_time"`
	Meta       map[string]interface{} `json:"meta"`
}

type LogRequestError

type LogRequestError struct {
	Kind       string      `json:"kind"`
	APIVersion string      `json:"apiVersion"`
	Metadata   interface{} `json:"metadata"`
	Status     string      `json:"status"`
	Message    string      `json:"message"`
	Reason     string      `json:"reason"`
	Code       int         `json:"code"`
}

func (*LogRequestError) Containers

func (l *LogRequestError) Containers() (containers []string)

func (*LogRequestError) IsContanerCreating

func (l *LogRequestError) IsContanerCreating() bool

type LogWatcher

type LogWatcher struct {
	Name string
	Chan chan bool
	// contains filtered or unexported fields
}

type Metadata

type Metadata struct {
	Name              string            `json:"name"`
	GenerateName      string            `json:"generateName"`
	Namespace         string            `json:"namespace"`
	SelfLink          string            `json:"selfLink"`
	UID               string            `json:"uid"`
	ResourceVersion   string            `json:"resourceVersion"`
	CreationTimestamp time.Time         `json:"creationTimestamp"`
	Labels            Labels            `json:"labels"`
	Annotations       Annotations       `json:"annotations"`
	OwnerReferences   []OwnerReferences `json:"ownerReferences"`
}

type NodeSelector

type NodeSelector struct {
	NodeRoleKubernetesIoCompute string `json:"node-role.kubernetes.io/compute"`
}

type Object

type Object struct {
	Metadata Metadata `json:"metadata"`
	Spec     Spec     `json:"spec"`
	Status   Status   `json:"status"`
}

type OwnerReferences

type OwnerReferences struct {
	APIVersion         string `json:"apiVersion"`
	Kind               string `json:"kind"`
	Name               string `json:"name"`
	UID                string `json:"uid"`
	Controller         bool   `json:"controller"`
	BlockOwnerDeletion bool   `json:"blockOwnerDeletion"`
}

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	ClaimName string `json:"claimName"`
}

type PodLogs

type PodLogs struct {
	Channels      map[string]chan bool
	Client        *kubernetes.Clientset
	Config        *rest.Config
	Ignored       string
	Namespace     string
	SkipVerify    bool
	EnableWatcher bool
	// contains filtered or unexported fields
}

func NewPodLogs

func NewPodLogs(namespace string, client *kubernetes.Clientset, config *rest.Config) *PodLogs

func (*PodLogs) Add

func (p *PodLogs) Add(pod string, ch chan bool)

Add adds control channel

func (*PodLogs) AddWatcherToDb

func (p *PodLogs) AddWatcherToDb(pod string) (chan bool, error)

AddWatcherToDb adds a watcher record into DB

func (*PodLogs) Del

func (p *PodLogs) Del(pod string)

Del deletes pod control channel

func (*PodLogs) DelWatcherFromDB

func (p *PodLogs) DelWatcherFromDB(pod string) error

DelWatcherFromDB removes a watcher record from the DB

func (*PodLogs) GetWatcherFromDB

func (p *PodLogs) GetWatcherFromDB(pod string) (*LogWatcher, error)

GetWatcherFromDB returns a watcher from the DB

func (*PodLogs) GetWatchersFromDBLen

func (p *PodLogs) GetWatchersFromDBLen() int

GetWatchersFromDBLen retunrns the logwatchers count

func (*PodLogs) IsWatcherInTheDB

func (p *PodLogs) IsWatcherInTheDB(pod string) (bool, *LogWatcher, error)

IsWatcherInTheDB checks the watcher already in the DB

func (*PodLogs) Len

func (p *PodLogs) Len() int

func (*PodLogs) NewSender

func (p *PodLogs) NewSender() (err error)

func (*PodLogs) PodTicker

func (p *PodLogs) PodTicker()

func (*PodLogs) Run

func (p *PodLogs) Run(pod string, ch chan bool, con string)

Run runs the logwatcher

func (*PodLogs) Shutdown

func (p *PodLogs) Shutdown(pod, con string)

func (*PodLogs) Stop

func (p *PodLogs) Stop(ch chan bool)

func (*PodLogs) Watch

func (p *PodLogs) Watch()

Watch watches for k8s events DEPRECATED

type Ports

type Ports struct {
	Name          string `json:"name"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol"`
}

type ReadinessProbe

type ReadinessProbe struct {
	Exec                Exec `json:"exec"`
	InitialDelaySeconds int  `json:"initialDelaySeconds"`
	TimeoutSeconds      int  `json:"timeoutSeconds"`
	PeriodSeconds       int  `json:"periodSeconds"`
	SuccessThreshold    int  `json:"successThreshold"`
	FailureThreshold    int  `json:"failureThreshold"`
}

type Resources

type Resources struct {
}

type Running

type Running struct {
	StartedAt time.Time `json:"startedAt"`
}

type SeLinuxOptions

type SeLinuxOptions struct {
	Level string `json:"level"`
}

type Secret

type Secret struct {
	SecretName  string `json:"secretName"`
	DefaultMode int    `json:"defaultMode"`
}

type SecretKeyRef

type SecretKeyRef struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

type SecurityContext

type SecurityContext struct {
	Capabilities Capabilities `json:"capabilities"`
}

type Sender

type Sender struct {
	Client SenderClient
	Config *SenderConfig
	// contains filtered or unexported fields
}

func (*Sender) Send

func (s *Sender) Send(ns, pod, message, con string)

func (*Sender) Ticker

func (s *Sender) Ticker()

type SenderClient

type SenderClient interface {
	Connect(*SenderConfig) error
	Push(map[int64]LogMessage) error
}

type SenderConfig

type SenderConfig struct {
	Type     string   `json:"type"`
	Hosts    []string `json:"hosts"`
	Username string   `json:"username"`
	Password string   `json:"password"`
	Index    string   `json:"index"`
	DocType  string   `json:"doc_type"`
	Limit    int      `json:"limit"`
}

func GetSenderConfigFromFlags

func GetSenderConfigFromFlags() *SenderConfig

type Spec

type Spec struct {
	Volumes                       []Volumes          `json:"volumes"`
	InitContainers                []InitContainers   `json:"initContainers"`
	Containers                    []Containers       `json:"containers"`
	RestartPolicy                 string             `json:"restartPolicy"`
	TerminationGracePeriodSeconds int                `json:"terminationGracePeriodSeconds"`
	DNSPolicy                     string             `json:"dnsPolicy"`
	NodeSelector                  NodeSelector       `json:"nodeSelector"`
	ServiceAccountName            string             `json:"serviceAccountName"`
	ServiceAccount                string             `json:"serviceAccount"`
	NodeName                      string             `json:"nodeName"`
	SecurityContext               SecurityContext    `json:"securityContext"`
	ImagePullSecrets              []ImagePullSecrets `json:"imagePullSecrets"`
	Hostname                      string             `json:"hostname"`
	Subdomain                     string             `json:"subdomain"`
	SchedulerName                 string             `json:"schedulerName"`
	Priority                      int                `json:"priority"`
}

type State

type State struct {
	Running    Running    `json:"running"`
	Terminated Terminated `json:"terminated"`
}

type Status

type Status struct {
	Phase                 string                  `json:"phase"`
	Conditions            []Conditions            `json:"conditions"`
	HostIP                string                  `json:"hostIP"`
	PodIP                 string                  `json:"podIP"`
	StartTime             time.Time               `json:"startTime"`
	InitContainerStatuses []InitContainerStatuses `json:"initContainerStatuses"`
	ContainerStatuses     []ContainerStatuses     `json:"containerStatuses"`
	QosClass              string                  `json:"qosClass"`
}

type TCPClient

type TCPClient struct {
	Client net.Conn
	// contains filtered or unexported fields
}

func (*TCPClient) Connect

func (t *TCPClient) Connect(conf *SenderConfig) (err error)

func (*TCPClient) Push

func (t *TCPClient) Push(l map[int64]LogMessage) error

type Terminated

type Terminated struct {
	ExitCode    int       `json:"exitCode"`
	Reason      string    `json:"reason"`
	StartedAt   time.Time `json:"startedAt"`
	FinishedAt  time.Time `json:"finishedAt"`
	ContainerID string    `json:"containerID"`
}

type ValueFrom

type ValueFrom struct {
	FieldRef FieldRef `json:"fieldRef"`
}

type VolumeMounts

type VolumeMounts struct {
	Name      string `json:"name"`
	MountPath string `json:"mountPath"`
	ReadOnly  bool   `json:"readOnly,omitempty"`
}

type Volumes

type Volumes struct {
	Name                  string                `json:"name"`
	PersistentVolumeClaim PersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"`
	ConfigMap             ConfigMap             `json:"configMap,omitempty"`
	Secret                Secret                `json:"secret,omitempty"`
	EmptyDir              EmptyDir              `json:"emptyDir,omitempty"`
}

type WatchEvent

type WatchEvent struct {
	Type   string `json:"Type"`
	Object Object `json:"Object"`
}

func (WatchEvent) Name

func (e WatchEvent) Name() string

func (WatchEvent) State

func (e WatchEvent) State() string

Jump to

Keyboard shortcuts

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