How kube-logging/logging-operator works
Project Type and Purpose
• This is a Kubernetes Operator (an “open-source tool”) implemented in Go.
• It automates deployment and configuration of a logging pipeline on Kubernetes:
• Fluent Bit DaemonSet as log collectors on each node
• Fluentd or syslog-ng as log forwarders
• CustomResourceDefinitions (CRDs) that drive configuration: Logging, Flow, Output, ClusterFlow, ClusterOutput, and their syslog-ng equivalents.
File Structure
• cmd, main.go: the entrypoint for the operator binary (controller manager).
• controllers/*: controller implementations for Logging, Flows, Outputs, Extensions, Telemetry.
• pkg/resources/*: helper code that “reconciles” CRs into Kubernetes primitives (DaemonSets, StatefulSets, Services, RBAC).
• pkg/sdk/*: generated CRD types and client code for extensions and logging APIs.
• config/: Kubernetes manifests & Kustomize overlays for CRDs, RBAC, webhook, manager deployment.
• charts/: Helm charts to install the operator and sample logging pipelines.
• images/: sidecar / utility images (config-reloader, drain-watch, node-exporter).
• e2e/: end-to-end tests deploying operator into a Kind cluster.
README
• High-level flow:
1. Operator watches CRDs.
2. Operator reconciles to deploy Fluent Bit collectors and Fluentd/syslog-ng forwarders.
3. Fluent Bit reads logs, enriches with metadata from the API.
4. Forwarder filters/transforms per Flow CRs and ships to Outputs (Elasticsearch, S3, Loki, etc.).
• Architecture section confirms components: log collectors, log forwarders, flows, outputs, control-plane operator.
Main Components
a. Kubernetes Control Plane / API Server
– CRDs: Logging, Flow, Output, ClusterFlow, ClusterOutput, SyslogNG equivalents
– Operator’s Deployment (controller-manager) and Webhook Server
b. Operator (Control Plane)
– main.go → manager (controller-runtime)
– controllers/*
– pkg/resources for reconciliation logic
– config-reloader sidecar (Hot-reload)
c. Data Plane
– Fluent Bit DaemonSet on every node (collect logs + metadata enrichment via K8s API)
– Fluentd / syslog-ng Forwarder (StatefulSet or DaemonSet)
– Telemetry-controller (optional)
d. External Services (Outputs)
– Elasticsearch, S3, GCS, Loki, Datadog, etc.
– (show multiple, configurable per Output CR)
e. Supporting Infrastructure
– Prometheus metrics & ServiceMonitors
– RBAC resources (Roles, RoleBindings)
– Webhook Admission for validation
– Helm Chart / Kustomize as install layer
Relationships and Data Flows
• Operator watches CRDs → reconciles → deploys/updates Collector and Forwarder workloads.
• Fluent Bit reads logs from node’s file system → queries API Server for Pod metadata → forwards enriched logs to Forwarder.
• Forwarder applies Flow rules (filters, transforms) → forwards to configured Outputs over TLS.
• Metrics scraped by Prometheus via ServiceMonitor.
Architectural Patterns and Design Principles
• Kubernetes Operator pattern (control loop + reconciliation)
• Use of Controller-Runtime library in Go
• CRD-driven configuration → declarative infrastructure
• Sidecar pattern for dynamic configuration reload (config-reloader)
• Helm + Kustomize for deployment templating
• Modular code: separate pkg/resources per component (fluentbit, fluentd, syslog-ng, eventtailer, nodeagent)
Essential Architectural Elements
• CRD definitions as the “source of truth”
• Controller Manager (multi-controller binary)
• Admission Webhook (validation)
• Dynamic reconfiguration via config-reloader sidecar
• Node-level DaemonSets vs. clustered StatefulSets
• Secure communication channels (TLS between components and outputs)