<p>I am running EKS cluster with fargate profile. I checked nodes status by using <code>kubectl describe node</code> and it is showing disk pressure:</p>
<pre><code>Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  MemoryPressure   False   Tue, 12 Jul 2022 03:10:33 +0000   Wed, 29 Jun 2022 13:21:17 +0000   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     True    Tue, 12 Jul 2022 03:10:33 +0000   Wed, 06 Jul 2022 19:46:54 +0000   KubeletHasDiskPressure       kubelet has disk pressure
  PIDPressure      False   Tue, 12 Jul 2022 03:10:33 +0000   Wed, 29 Jun 2022 13:21:17 +0000   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            True    Tue, 12 Jul 2022 03:10:33 +0000   Wed, 29 Jun 2022 13:21:27 +0000   KubeletReady                 kubelet is posting ready status
</code></pre>
<p>And also there is failed garbage collection event.</p>
<pre><code>Events:
  Type     Reason                Age                     From     Message
  ----     ------                ----                    ----     -------
  Warning  FreeDiskSpaceFailed   11m (x844 over 2d22h)   kubelet  failed to garbage collect required amount of images. Wanted to free 6314505830 bytes, but freed 0 bytes
  Warning  EvictionThresholdMet  65s (x45728 over 5d7h)  kubelet  Attempting to reclaim ephemeral-storage
</code></pre>
<p>I think cause of disk filling quickly is due to  application logs, which application is writing to stdout, as per aws documentation which in turn is written to log files by container agent and I am using fargate in-built fluentbit to push application logs to opensearch cluster.</p>
<p>But looks like EKS cluster is not deleting old log files created by container agent.</p>
<p>I was looking to SSH into fargate nodes to furhter debug issue but as per aws support ssh into fargate nodes not possible.</p>
<p>What can be done to remove disk pressure from fargate nodes?</p>
<p>As suggested in answers I am using logrotate in sidecar. But as per logs of logrotate container it is not able to find dir:</p>
<pre><code>rotating pattern: /var/log/containers/*.log
 52428800 bytes (5 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/containers/*.log
  log /var/log/containers/*.log does not exist -- skipping
reading config file /etc/logrotate.conf
Reading state from file: /var/lib/logrotate.status
Allocating hash table for state file, size 64 entries
Creating new state
</code></pre>
<p>yaml file is:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-apis
  namespace: kube-system
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: my-apis
          image: 111111xxxxx.dkr.ecr.us-west-2.amazonaws.com/my-apis:1.0.3
          ports:
            - containerPort: 8080
          resources:
            limits:
              cpu: &quot;1000m&quot;
              memory: &quot;1200Mi&quot;
            requests:
              cpu: &quot;1000m&quot;
              memory: &quot;1200Mi&quot;
          readinessProbe:
            httpGet:
              path: &quot;/ping&quot;
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 2
          livenessProbe:
            httpGet:
              path: &quot;/ping&quot;
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 5
        - name: logrotate
          image: realz/logrotate
          volumeMounts:
          - mountPath: /var/log/containers
            name: my-app-logs
          env:
          - name: CRON_EXPR
            value: &quot;*/5 * * * *&quot;
          - name: LOGROTATE_LOGFILES
            value: &quot;/var/log/containers/*.log&quot;
          - name: LOGROTATE_FILESIZE
            value: &quot;50M&quot;
          - name: LOGROTATE_FILENUM
            value: &quot;5&quot;
      volumes:
      - name: my-app-logs
        emptyDir: {}
</code></pre>

anujprashar
<p><code>What can be done to remove disk pressure from fargate nodes?</code></p>
<p>No known configuration that could have Fargate to automatic clean a specific log location. You can run logrotate as sidecar. Plenty of choices <a href="https://hub.docker.com/search?q=logrotate" rel="nofollow noreferrer">here</a>.</p>
