4

What is the max size allowed for Environment variable (pod->container->Env) in kubernetes, assuming base ubuntu containers? I am unable to find the relevant documentation. Question might seem stupid, but, I do need the info to make my design robust.

AdmiralThrawn
  • 374
  • 5
  • 15

1 Answers1

5

So at bare minimum there is some 1,048,576 byte limitation imposed:

The ConfigMap "too-big" is invalid: []: Too long: must have at most 1048576 characters

which I generated as:

cat > too-big.yml<<FOO
apiVersion: v1
kind: ConfigMap
metadata:
  name: too-big
data:
  kaboom.txt: |
    $(python -c 'print("x" * 1024 * 1024)')
FOO

And when I try that same stunt with a Pod, I'm met with a very similar outcome:

containers:
- image: ubuntu:18.10
  env:
  - name: TOO_BIG
    value: |
      $(python -c the same print)

standard_init_linux.go:178: exec user process caused "argument list too long"

So I would guess it's somewhere in between those two numbers: 0 and 1048576

That said, as the practically duplicate question answered, you are very, very likely solving the wrong problem. The very fact that you have to come to a community site to ask such a question means you are brining risk to your project that it will work one way on Linux, another way on docker, another way on kubernetes, and a different way on macOS.

mdaniel
  • 31,240
  • 5
  • 55
  • 58
  • 1
    Thanks for the response. I do believe 1mb could be the limit - as that is what is getting imposed for secrets and is documented. As far as the problem being solved, it is just a matter of trade-offs of design complexity to reusing existing infrastructure(after knowing their limits - which are currently not documented). I came to stack over flow as that is what k8s troubleshooting guide suggested. – AdmiralThrawn Dec 19 '18 at 17:37