Documentation ¶
Index ¶
- Constants
- Variables
- func List(ctx context.Context, client kubernetes.Interface, config *Config) (map[string]string, error)
- func Run(ctx context.Context, client kubernetes.Interface, config *Config) error
- func WatchTargets(ctx context.Context, i v1.PodInterface, labelSelector labels.Selector, ...) (chan *Target, error)
- type Config
- type ContainerState
- type FileTail
- type Log
- type ResourceMatcher
- type ResumeRequest
- type Tail
- func (t *Tail) Close()
- func (t *Tail) ConsumeRequest(ctx context.Context, request rest.ResponseWrapper) error
- func (t *Tail) GetResumeRequest() *ResumeRequest
- func (t *Tail) Print(msg string)
- func (t *Tail) Resume(ctx context.Context, resumeRequest *ResumeRequest) error
- func (t *Tail) Start(ctx context.Context) error
- type TailOptions
- type Target
Constants ¶
const ( RUNNING = "running" WAITING = "waiting" TERMINATED = "terminated" ALL_STATES = "all" )
const TimestampFormatDefault = "2006-01-02T15:04:05.000000000Z07:00"
RFC3339Nano with trailing zeros
const TimestampFormatShort = "01-02 15:04:05"
time.DateTime without year
Variables ¶
var ( PodMatcher = ResourceMatcher{/* contains filtered or unexported fields */} ReplicationControllerMatcher = ResourceMatcher{/* contains filtered or unexported fields */} ServiceMatcher = ResourceMatcher{/* contains filtered or unexported fields */} DaemonSetMatcher = ResourceMatcher{/* contains filtered or unexported fields */} DeploymentMatcher = ResourceMatcher{/* contains filtered or unexported fields */} ReplicaSetMatcher = ResourceMatcher{/* contains filtered or unexported fields */} StatefulSetMatcher = ResourceMatcher{/* contains filtered or unexported fields */} JobMatcher = ResourceMatcher{/* contains filtered or unexported fields */} // job does not have a short name ResourceMatchers = []ResourceMatcher{ PodMatcher, ReplicationControllerMatcher, ServiceMatcher, DeploymentMatcher, DaemonSetMatcher, ReplicaSetMatcher, StatefulSetMatcher, JobMatcher, } )
Functions ¶
func List ¶ added in v1.19.0
func List(ctx context.Context, client kubernetes.Interface, config *Config) (map[string]string, error)
List returns a map of all 'app.kubernetes.io/instance' values.
func WatchTargets ¶ added in v1.23.0
func WatchTargets(ctx context.Context, i v1.PodInterface, labelSelector labels.Selector, fieldSelector fields.Selector, filter *targetFilter) (chan *Target, error)
Watch starts listening to Kubernetes events and emits modified containers/pods. The result is targets added.
Types ¶
type Config ¶
type Config struct { Namespaces []string PodQuery *regexp.Regexp ExcludePodQuery []*regexp.Regexp Timestamps bool TimestampFormat string Location *time.Location ContainerQuery *regexp.Regexp ExcludeContainerQuery []*regexp.Regexp ContainerStates []ContainerState Exclude []*regexp.Regexp Include []*regexp.Regexp Highlight []*regexp.Regexp InitContainers bool EphemeralContainers bool Since time.Duration AllNamespaces bool LabelSelector labels.Selector FieldSelector fields.Selector TailLines *int64 Template *template.Template Follow bool Resource string OnlyLogLines bool MaxLogRequests int Stdin bool Out io.Writer ErrOut io.Writer }
Config contains the config for stern
type ContainerState ¶
type ContainerState string
func NewContainerState ¶
func NewContainerState(stateConfig string) (ContainerState, error)
NewContainerState returns corresponding ContainerState
func (ContainerState) Match ¶
func (stateConfig ContainerState) Match(containerState v1.ContainerState) bool
Match returns ContainerState is matched
type FileTail ¶ added in v1.29.0
type FileTail struct { Options *TailOptions // contains filtered or unexported fields }
func NewFileTail ¶ added in v1.29.0
func NewFileTail(tmpl *template.Template, in io.Reader, out, errOut io.Writer, options *TailOptions) *FileTail
NewFileTail returns a new tail of the input reader
func (*FileTail) ConsumeReader ¶ added in v1.29.0
ConsumeReader reads the data from the reader and writes into the out writer.
type Log ¶
type Log struct { // Message is the log message itself Message string `json:"message"` // Node name of the pod NodeName string `json:"nodeName"` // Namespace of the pod Namespace string `json:"namespace"` // PodName of the pod PodName string `json:"podName"` // ContainerName of the container ContainerName string `json:"containerName"` PodColor *color.Color `json:"-"` ContainerColor *color.Color `json:"-"` }
Log is the object which will be used together with the template to generate the output.
type ResourceMatcher ¶ added in v1.23.0
type ResourceMatcher struct {
// contains filtered or unexported fields
}
ResourceMatcher is a matcher for Kubernetes resources
func (*ResourceMatcher) AllNames ¶ added in v1.23.0
func (r *ResourceMatcher) AllNames() []string
AllNames returns the resource names including the aliases
func (*ResourceMatcher) Matches ¶ added in v1.23.0
func (r *ResourceMatcher) Matches(name string) bool
Matches returns if name matches one of the resource names
func (*ResourceMatcher) Name ¶ added in v1.23.0
func (r *ResourceMatcher) Name() string
Name returns the resource name in singular
type ResumeRequest ¶ added in v1.24.0
type Tail ¶
type Tail struct { NodeName string Namespace string PodName string ContainerName string Options *TailOptions // contains filtered or unexported fields }
func NewTail ¶
func NewTail(clientset corev1client.CoreV1Interface, nodeName, namespace, podName, containerName string, tmpl *template.Template, out, errOut io.Writer, options *TailOptions) *Tail
NewTail returns a new tail for a Kubernetes container inside a pod
func (*Tail) ConsumeRequest ¶ added in v1.13.1
ConsumeRequest reads the data from request and writes into the out writer.
func (*Tail) GetResumeRequest ¶ added in v1.24.0
func (t *Tail) GetResumeRequest() *ResumeRequest
type TailOptions ¶
type TailOptions struct { Timestamps bool TimestampFormat string Location *time.Location SinceSeconds *int64 SinceTime *metav1.Time Exclude []*regexp.Regexp Include []*regexp.Regexp Highlight []*regexp.Regexp Namespace bool TailLines *int64 Follow bool OnlyLogLines bool // contains filtered or unexported fields }
func (TailOptions) HighlightMatchedString ¶ added in v1.24.0
func (o TailOptions) HighlightMatchedString(msg string) string
func (TailOptions) IsExclude ¶ added in v1.13.0
func (o TailOptions) IsExclude(msg string) bool
func (TailOptions) IsInclude ¶ added in v1.13.0
func (o TailOptions) IsInclude(msg string) bool
func (TailOptions) UpdateTimezoneAndFormat ¶ added in v1.24.0
func (o TailOptions) UpdateTimezoneAndFormat(timestamp string) (string, error)
type Target ¶
Target is a target to watch
func ListTargets ¶ added in v1.23.0
func ListTargets(ctx context.Context, i corev1client.PodInterface, labelSelector labels.Selector, fieldSelector fields.Selector, filter *targetFilter) ([]*Target, error)
ListTargets returns targets by listing and filtering pods