While reading the "Kubernetes in Action" book I saw the following excerpt (p. 124):

Listing 5.2 Enabling standard input for a container

apiVersion: v1
kind: Pod
  name: kiada-stdin
  - name: kiada
    image: luksa/kiada:0.2
    stdin: true
    - containerPort: 8080

As you can see in the listing, if the application running in a pod wants to read from standard input, you must indicate this in the pod manifest by setting the stdin field in the container definition to true. This tells Kubernetes to allocate a buffer for the standard input stream, otherwise, the application will always receive an EOF when it tries to read from it.

The last sentence confuses me. What does it mean to "allocate a buffer for the standard input"? I tried to look for some clues, but I only see some things related to C programming, which I do not have much idea about and have hard time understanding the concept.

Could someone explain it in a more "language-agnostic" way? What is that buffer? What is EOF?

As far as I know, every (?) Linux process is given three files:

  • stdin
  • stdout
  • stderr

The process can write to the last two, and it can read the first one.


It is the amount of memory that is reserved by kubernetes to hold whatever is put into the stdin of the application. If you say that it doesn't require stdin, then there is no need to hold this amount of memory. The trick here is that because it is a buffer with a certain size, the application will make sure to not overrun it.... so even if the application feeding into the k8s app is throwing TB/s at it, once the buffer is filled, k8s will not read from stdin any longer until the app has captured that data.

About EOF (a.k.a. End of File), that is what you get when you try to read from a file (or a stream) once you have reached the end of it and there's no more data to read. If there is no buffer set up and the app tried to read from stdin, well, and EOF will be seen there.

  • Does it mean that stdin "attached" to any process running on my Linux PC is also actually a memory buffer? I know that there is a file "stdin" that the terminal listens to. But, I guess, it's not actually a file on a disk, it's just an "illusion", which is backed by some amount of memory that you call a buffer. Are we able to change the size of that buffer?
    – Loreno
    Oct 6 '21 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.