Skip to content

k8s get-pod-logs

Get k8s pod logs

Description

Get logs from kubernetes pods

Synopsis

k8s get-pod-logs
    [--site <site>]
    [--cluster <cluster>]
    [--namespace|-n <namespace>]
    <name>
    [--since <since>]
    [--since_time <since_time>]
    [--tail_lines <tail_lines>]
    [--limit_bytes <limit_bytes>]
    [--label_selector <label_selector>]

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

cluster - (string)

     Cluster where this command will be executed
     Example: --cluster "in-cluster"
     Default: in-cluster      Attributes: optional

namespace - (string)

     Kubernetes namespace
     Example: --namespace "namespace-1"
     Default: default      Attributes: optional

name - (string)

     Name of the pod
     Example: "name-1"
     Default: _None_      Attributes: required

since - (duration)

     Duration for which logs are required. Only one of since or since_time can be specified
     Example: --since "5 seconds"
     Default: _None_      Attributes: optional

since_time - (string)

     Timestamp from which logs required. Should follow RFC3339 standard
     Example: --since_time "2019-10-12T07:20:50.52Z"
     Default: _None_      Attributes: optional

tail_lines - (int)

     the number of lines from the end of the logs to show
     Example: --tail_lines 1
     Default: _None_      Attributes: optional

limit_bytes - (int)

     the number of bytes to read from the server before terminating the log output
     Example: --limit_bytes 1
     Default: _None_      Attributes: optional

label_selector - (string)

     label selector to select pods to get logs for. Only used if name is not provided
     Example: --label_selector "app=myapp"
     Default: _None_      Attributes: optional

Examples

Input:

! k8s get-pod-logs "hello-1629338580-jw8sf"
Output:
{
     "logs": [
          "Thu Aug 19 02:03:06 UTC 2021",
          "Hello from the Kubernetes cluster",
          ""
     ]
}

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "k8s"
Service Instance cluster
Namespace namespace
Object Type "pod"
Object ID name

Please see Access Control for details.