How to properly set ephemeral storage limits in kubernetes

99 Views Asked by At

I have the following k8s job definition:

apiVersion: batch/v1
kind: Job
metadata:
  name: ephemeral-limit-test
spec:
  template:
    spec:
      containers:
      - name: ephemeral-limit-test
        image: alpine
        command: ["sh", "-c"]
        args: ["cd /tmp && truncate -s 200M dummy && pwd && ls -lh dummy"]
        resources:
          requests:
            ephemeral-storage: "100Mi"
          limits:
            ephemeral-storage: "100Mi"
        volumeMounts:
        - name: ephemeral
          mountPath: "/tmp"
      restartPolicy: Never
      volumes:
        - name: ephemeral
          emptyDir:
            sizeLimit: "100Mi"
  backoffLimit: 4

As we can see I set both the ephemeral storage request and limit to 100Mi, same as the emptyDir sizeLimit.

The output of the job is

/tmp                                                                                                                                                                                                           
-rw-r--r--    1 root     root      200.0M Sep 18 14:01 dummy

How is it possible for the job to finish successfully before being evicted, after creating a file with size 200MB?

0

There are 0 best solutions below