Documentation
¶
Overview ¶
Package logreader streams logs from a Kubernetes pod container.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoPodsForJob = errors.New("no pods found for job")
ErrNoPodsForJob is returned when a job has no associated pods at all.
var ErrPodsNotReady = errors.New("pods not ready for job")
ErrPodsNotReady is returned when a job's pods exist but none have reached a phase (Running/Succeeded/Failed) that can serve logs.
Functions ¶
This section is empty.
Types ¶
type KubernetesReader ¶
type KubernetesReader struct {
// contains filtered or unexported fields
}
KubernetesReader implements Reader using the Kubernetes API.
func NewKubernetesReader ¶
func NewKubernetesReader(clientset kubernetes.Interface) *KubernetesReader
NewKubernetesReader returns a Reader backed by the given clientset.
func (*KubernetesReader) ReadJobLogs ¶
func (r *KubernetesReader) ReadJobLogs( ctx context.Context, namespace, jobName, container string, tailLines int64, ) (io.ReadCloser, error)
ReadJobLogs resolves the pod for the given job and streams its container logs. It prefers a Succeeded pod; if none exist, it falls back to the most recent non-pending pod. Pods in the Pending phase are skipped because reading their logs would either fail or return no useful content.
A positive tailLines asks the kubelet to return only the last N lines (server-side filter, no wasted transfer). A value <= 0 returns the full retained log.
type Reader ¶
type Reader interface {
ReadJobLogs(ctx context.Context, namespace, jobName, container string, tailLines int64) (io.ReadCloser, error)
}
Reader streams logs from a job's latest pod. Implementations return the full retained log for the named container. The returned ReadCloser must be closed by the caller.