logo

Revamping Kubernetes with Contextual and Structured Logging, a Deep Dive

2023-04-20

Authors:   Shivanshu Raj Shrivastava


Summary

The presentation discusses the implementation of structured and contextual logging in Kubernetes to make logs more queryable and provide essential information about Kubernetes objects.
  • Structured logging with key-value pairs and references to Kubernetes objects
  • Contextual logging to retain context from parent to leaf and share information between different go routines
  • API changes required for implementation
  • Goal is not to remove Klog and Klog will remain in use
The presentation mentions a wrapper added to Klog for unit testing the functionality of complete context. This illustrates the importance of testing and ensuring the implementation of structured and contextual logging is effective.

Abstract

Kubernetes is undergoing fundamental changes in its logging infrastructure to emit structured logs containing references to Kubernetes objects and the context of a log entry, making logging in Kubernetes uniform and machine-readable, bringing more automation to Kubernetes monitoring. Much effort has gone into enhancing klog and migrating Kubernetes components to achieve structured and contextual logging. We aim to cover a deep dive into the changes, a demo comparing performances and seamless log ingestion with log collection agents like Fluent Bit. It affects the complete code base of Kubernetes and needs collaboration between maintainers of different SIGs. This talk will make adopting best practices easy as we advance. We welcome everyone contributing to Kubernetes or interested in understanding the modern way of Kubernetes logs collection. New contributors are most welcome as it gives a good starting point to familiarize themselves with the Kubernetes code base.

Materials:

Post a comment