Skip to content

fix: update kubelet log path for containerd support#864

Open
sghosh23 wants to merge 1 commit intomasterfrom
update-kube-log-path-for-containerd
Open

fix: update kubelet log path for containerd support#864
sghosh23 wants to merge 1 commit intomasterfrom
update-kube-log-path-for-containerd

Conversation

@sghosh23
Copy link
Contributor

@sghosh23 sghosh23 commented Feb 5, 2026

Summary

Update kubernetes_logging.yml to use the standard kubelet log path instead of Docker-specific paths.

Changes

  • Changed logrotate path from /var/lib/docker/containers/*/*.log to /var/log/pods/*/*/*.log
  • This enables compatibility with containerd and other container runtimes
  • Maintains existing log rotation settings: daily rotation with 2 backups (3 days total)

Why This Change?

Modern Kubernetes clusters increasingly use containerd instead of Docker. The current configuration is Docker-specific and doesn't work reliably with containerd. The new path:

  • ✅ Is the standard Kubernetes kubelet log location
  • ✅ Works with any container runtime (Docker, containerd, CRI-O, etc.)
  • ✅ Follows Kubernetes best practices
  • ✅ Improves integration with log collection tools (Loki, Promtail, etc.)

Testing

This change has been successfully tested on:

  • Cluster: Kubernetes v1.29.10 with containerd v1.7.22
  • Nodes: kubenode1, kubenode2, kubenode3 (all 3 updated successfully)
  • Result: ✅ All nodes updated, no pod disruption, cluster operational

Configuration Details

The logrotate settings remain unchanged:

  • Rotates logs daily
  • Keeps 2 rotated backups (maxage: 1 day = 3 days total retention)
  • Uses copytruncate for safe rotation without interrupting running processes
  • Skips if directory doesn't exist yet (missingok flag)

Files Changed

  • ansible/kubernetes_logging.yml - Single file, minimal change

Note: The /var/log/pods/ directory will be created by kubelet when it starts using this path. Logrotate has missingok flag so it won't fail if the directory doesn't exist initially.

Update kubernetes_logging.yml to use the standard kubelet log path
/var/log/pods/*/*/*.log instead of Docker-specific path. This change:

- Makes log rotation compatible with containerd and other container runtimes
- Uses the standard Kubernetes pod log location
- Maintains daily log rotation with 2 backups (3 days total retention)
- Enables proper log lifecycle management by kubelet
- Improves integration with log collection tools like Loki and Promtail

The logrotate configuration:
- Rotates logs daily
- Keeps 2 rotated backups (maxage: 1 day)
- Uses copytruncate for safe rotation without process interruption
- Skips if directory doesn't exist yet (missingok flag)

Tested on: Kubernetes v1.29.10 with containerd v1.7.22
All 3 nodes (kubenode1, kubenode2, kubenode3) successfully updated.
@sghosh23 sghosh23 requested review from a team and julialongtin as code owners February 5, 2026 09:30
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 5, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments