Skip to content

fix: update kubelet log path for containerd support#864

Merged
mohitrajain merged 2 commits intomasterfrom
update-kube-log-path-for-containerd
Feb 26, 2026
Merged

fix: update kubelet log path for containerd support#864
mohitrajain merged 2 commits 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.

Copy link
Contributor

@mohitrajain mohitrajain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good, please rebase from master before merging.

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.
@mohitrajain mohitrajain force-pushed the update-kube-log-path-for-containerd branch from bf923c4 to 393e5c6 Compare February 26, 2026 10:51
@sonarqubecloud
Copy link

@mohitrajain mohitrajain merged commit 4685a04 into master Feb 26, 2026
23 of 24 checks passed
@mohitrajain mohitrajain deleted the update-kube-log-path-for-containerd branch February 26, 2026 14:58
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.

2 participants