Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidResourceType is returned when the given resource type is invalid ErrInvalidResourceType = errors.New("invalid resource type") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client allows to retrieve logs of differents resources on k8s
func (Client) Logs ¶
Logs retrieve logs of on or multiple resource.
A resource can be a pod, a deployment, a statefulsets, etc. It can has the following forms:
- X/Y/Z: all the pods of the resource "Z" of type "Y" in namespace "X"
- Y/Z: all the pods of the resource "Z" of type "Y" in namespace "default"
- Z: the pod "Z" in namespace "default"
Examples:
- mysvc-abcd: the pod "mysvc-abcd" in namespace "default"
- deploy/mysvc: all the pods of the deployment "mysvc" in namespace "default"
- prod/deploy/mysvc: all the pods of the deployment "mysvc" in namespace "prod"
type Deployment ¶
type Deployment struct {
// contains filtered or unexported fields
}
Deployment is a deployment resource
func (Deployment) GetLogs ¶
func (d Deployment) GetLogs(opts *k8s.PodLogOptions) (<-chan LogLine, error)
GetLogs retrieve logs for the deployment resource
This will get logs from all the pods matching the deployment selector
type LogLine ¶
type LogLine struct { // Pod is the name of the pod Pod string // Line is the log line itself Line string // contains filtered or unexported fields }
LogLine is a log line of a pod
type Opts ¶
type Opts func(c *Client)
Opts is an option used to configure Client
func WithOptsFollow ¶
WithOptsFollow enable to follow log stream (default: false).
If the follow option is enabled, the client will follow the log stream of the resources. If the given resource type is not a pod, the client will also watch for new pods of the resource.
func WithOptsJSONFields ¶
WithOptsJSONFields configure the json option (default: none).
If enabled, log lines will be handled as JSON objects and only the given fields will be printed.
func WithOptsTimestamps ¶
WithOptsTimestamps enable timestamps at the beginning of the log line (default: true)
type ReplicaSet ¶
type ReplicaSet struct {
// contains filtered or unexported fields
}
ReplicaSet is a ReplicaSet resource
func (ReplicaSet) GetLogs ¶
func (rs ReplicaSet) GetLogs(opts *k8s.PodLogOptions) (<-chan LogLine, error)
GetLogs retrieve logs for the ReplicaSet resource
This will get logs from all the pods matching the ReplicaSet selector
type Resource ¶
type Resource interface {
GetLogs(*k8s.PodLogOptions) (<-chan LogLine, error)
}
Resource is a k8s resource (namespace/type/name)
func NewResource ¶
NewResource creates new Resource object
A resource can be a pod, a deployment, a statefulsets, etc. It can has the following forms:
- X/Y/Z: all the pods of the resource "Z" of type "Y" in namespace "X"
- Y/Z: all the pods of the resource "Z" of type "Y" in namespace "default"
- Z: the pod "Z" in namespace "default"
Examples:
- mysvc-abcd: the pod "mysvc-abcd" in namespace "default"
- deploy/mysvc: all the pods of the deployment "mysvc" in namespace "default"
- prod/deploy/mysvc: all the pods of the deployment "mysvc" in namespace "prod"
Lists of resource type:
- pod, po
- deployment, deploy
type ResourceType ¶
type ResourceType int
ResourceType represents a k8s resource type
const ( // TypeUnknown is an unknown resource type TypeUnknown ResourceType = iota // TypePod is the resource type for pods TypePod // TypeDeploy is the resource type for deployments TypeDeploy // TypeStatefulSet is the resource type for statefulsets TypeStatefulSet // TypeReplicaSet is the resource type for replicasets TypeReplicaSet // TypeService is the resource type for services TypeService )
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a Service resource
type StatefulSet ¶
type StatefulSet struct {
// contains filtered or unexported fields
}
StatefulSet is a statefulset resource
func (StatefulSet) GetLogs ¶
func (ss StatefulSet) GetLogs(opts *k8s.PodLogOptions) (<-chan LogLine, error)
GetLogs retrieve logs for the statefulset resource
This will get logs from all the pods matching the statefulset selector