Repository: kubernetes
Issue: Container using in Memory emptyDir was Evicted on DiskPressure
Labels: kind/bug,sig/storage,needs-triage

### What happened?

This is my Pod/Container definition:

```
apiVersion: v1
kind: Pod
metadata:
  annotations:
    prometheus.io/path: /metrics
    prometheus.io/port: "1024"
    prometheus.io/scrape: "true"
  labels:
    app: ingress-haproxy-internal
    app.kubernetes.io/instance: ingress-haproxy-internal
    app.kubernetes.io/name: kubernetes-ingress
    controller-revision-hash: 7b74744854
    pod-template-generation: "5"
  name: ingress-haproxy-internal-kubernetes-ingress-fbdc9
  namespace: ingress-haproxy
spec:
  containers:
  - args:
    - --default-ssl-certificate=ingress-haproxy/ingress-haproxy-internal-kubernetes-ingress-default-cert
    - --configmap=ingress-haproxy/ingress-haproxy-internal-kubernetes-ingress
    - --http-bind-port=8080
    - --https-bind-port=8443
    - --ingress.class=haproxy-int
    - --publish-service=ingress-haproxy/ingress-haproxy-internal-kubernetes-ingress
    - --log=info
    - --prometheus
    env:
    - name: POD_NAME
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: metadata.name
    - name: POD_NAMESPACE
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: metadata.namespace
    - name: POD_IP
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: status.podIP
    image: hub.willhaben.at:8448/haproxytech/kubernetes-ingress:3.0.4
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 3
      httpGet:
        path: /healthz
        port: 1042
        scheme: HTTP
      periodSeconds: 5
      successThreshold: 1
      timeoutSeconds: 1
    name: kubernetes-ingress-controller
    ports:
    - containerPort: 8080
      name: http
      protocol: TCP
    - containerPort: 8443
      name: https
      protocol: TCP
    - containerPort: 1024
      name: stat
      protocol: TCP
    readinessProbe:
      failureThreshold: 3
      httpGet:
        path: /healthz
        port: 1042
        scheme: HTTP
      periodSeconds: 5
      successThreshold: 1
      timeoutSeconds: 1
    resources:
      requests:
        cpu: 100m
        memory: 512Mi
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        add:
        - NET_BIND_SERVICE
        drop:
        - ALL
      runAsGroup: 1000
      runAsNonRoot: true
      runAsUser: 1000
      seccompProfile:
        type: RuntimeDefault
    startupProbe:
      failureThreshold: 20
      httpGet:
        path: /healthz
        port: 1042
        scheme: HTTP
      periodSeconds: 1
      successThreshold: 1
      timeoutSeconds: 1
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /tmp
      name: tmp
      subPath: tmp
    - mountPath: /run
      name: tmp
      subPath: run
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-fffsq
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: ip-10-11-24-31.eu-central-1.compute.internal
  preemptionPolicy: PreemptLowerPriority
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext:
    runAsGroup: 1000
    runAsNonRoot: true
    runAsUser: 1000
  serviceAccount: ingress-haproxy-internal-kubernetes-ingress
  serviceAccountName: ingress-haproxy-internal-kubernetes-ingress
  terminationGracePeriodSeconds: 60
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
  - effect: NoSchedule
    key: node.kubernetes.io/disk-pressure
    operator: Exists
  - effect: NoSchedule
    key: node.kubernetes.io/memory-pressure
    operator: Exists
  - effect: NoSchedule
    key: node.kubernetes.io/pid-pressure
    operator: Exists
  - effect: NoSchedule
    key: node.kubernetes.io/unschedulable
    operator: Exists
  volumes:
  - emptyDir:
      medium: Memory
      sizeLimit: 64Mi
    name: tmp
  - name: kube-api-access-fffsq
    projected:
      defaultMode: 420
      sources:
      - serviceAccountToken:
          expirationSeconds: 3607
          path: token
      - configMap:
          items:
          - key: ca.crt
            path: ca.crt
          name: kube-root-ca.crt
      - downwardAPI:
          items:
          - fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
            path: namespace
```

and among all other pods it got evicted as first on DiskPressure with the following message:

```
The node was low on resource: ephemeral-storage. Threshold quantity: 2139512454, available: 1732380Ki. Container kubernetes-ingress-controller was using 27984Ki, request is 0, has larger consumption of ephemeral-storage. 
```

### What did you expect to happen?

The `27984Ki` should count as memory usage and not ephemeral storage usage, therefore my pod should not Evicted because it's using more ephemeral-storage than the request 

### How can we reproduce it (as minimally and precisely as possible)?

1. Run a Pod with in Memory emptyDir volume
2. Write something in the volume
3. Check the node /stats/summary 
4. The container should not report any ephemral storage usage

### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: v1.31.2
Kustomize Version: v5.4.2
Server Version: v1.31.0-eks-a737599
```

</details>


### Cloud provider

<details>
EKS
</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.5.20240916"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2028-03-15"
```

</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>