Max size of Environment variables in kubernetes

12/18/2018

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
kubernetes

1 Answer

12/19/2018

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
Source: StackOverflow