skip to Main Content

When i issue

kubectl logs MY_POD_NAME –limit-bytes=1

command, the –limit-bytes option is ignored and i get all the pod’s logs.
My kubernetes version is 1.15.3
Trying to understand why that would be. When i issue the same command in GKE setup, the –limit-bytes option works as expected. I wonder what might be different in my setup to prevent this option from working correctly. (This is on CentOS).

Update: i tracked down the issue to Docker’s –log-driver option.
If the Docker –log-driver is set to ‘json-file’, then kubectl logs command works fine with –limit-bytes option. However, if the Docker -log-driver is set to ‘journald’, then kubectl logs command ignores the –limit-bytes option. Seems like a kubectl bug to me.

2

Answers


  1. After executing this command you shoud have seen following error:

    error: expected 'logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]'.
    POD or TYPE/NAME is a required argument for the logs command
    See 'kubectl logs -h' for help and examples.
    

    Execute:

    $ kubectl logs your_pod_name  -c container_name --limit-bytes=1 -n namespace_name
    

    If you set –limit-bytes flag you must know that
    –limit-bytes=0: Maximum bytes of logs to return.

    Defaults to no limit.=0: Maximum bytes of logs to return. Defaults to no limit.

    Documentation of kubectl-logs.

    Please let me know if it helps.

    Login or Signup to reply.
  2. Yeah, it should work fine –

    Please try this, if you have one container in application –

    kubectl -n namespace logs pod_name --limit-bytes=1 
    

    If you have multiple containers then please mention like –

    kubectl -n namespace logs pod_name -c container_name --limit-bytes=1 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search