Representative interview topic

General interview: How can Kubernetes NodeLogQuery expose system logs safely?

GeneralHard
Offer.cc Editorial TeamPublished Updated

Question

An operations platform needs systemd logs from Kubernetes nodes for debugging but must not expose the node filesystem to tenants. How would you bound and observe NodeLogQuery?

Prompt and context

An operations platform needs systemd logs from Kubernetes nodes for debugging but must not expose the node filesystem to tenants. Explain the boundary of stable NodeLogQuery in Kubernetes v1.36, access control, query parameters, pagination, rate limiting, and what to do when a node is unreachable or the result is too large.

What the interviewer evaluates

  • Distinguishing NodeLogQuery from reading node files, container logs, and a centralized logging system.
  • Explaining enableSystemLogQuery, Kubelet authentication and authorization, and tenant isolation.
  • Considering time range, severity, output size, deadlines, and concurrency limits.
  • Providing an observable, auditable, and reversible operations workflow.

Clarifying questions to ask

  1. Are the targets node services, kernel logs, or Pod stdout/stderr? They have different entry points.
  2. Is the caller a cluster administrator, an on-call SRE, or a tenant self-service platform?
  3. Are cross-node, long-range, or live-follow queries required? They affect node load.
  4. Is a log collection system already available for historical search?

30-second answer framework

Set the boundary first: NodeLogQuery is a controlled Kubelet node-log capability, not arbitrary file access. Then give the flow: authenticate and authorize the caller, validate node and query scope, let Kubelet invoke the node log interface, and return bounded results. Finish with guardrails: enable enableSystemLogQuery, limit time, lines, bytes, concurrency, and deadlines; send historical search to centralized logs; and audit and alert on abnormal requests.

Step-by-step deep dive

1. Define log sources and capability boundaries

NodeLogQuery targets node system logs such as systemd and kernel logs. Pod stdout/stderr should use container logging or a centralized collector. The query interface must not accept arbitrary filesystem paths, read credential directories, or bypass Kubelet authorization. Tenants should receive filtered node events or aggregates, while raw node logs remain limited to controlled SRE roles.

2. Authenticate, authorize, and isolate tenants

The Kubelet HTTPS endpoint authenticates the client before evaluating request attributes. The API Server or an operations proxy uses a dedicated identity whose rules are limited to permitted node-log capabilities; tenants do not receive nodes/proxy or equivalent broad access. The platform also verifies the tenant-to-node binding so changing a node name or label cannot reach another tenant's node.

3. Bound queries and protect resources

Require an explicit node, service unit, time range, and severity, with a short default window. Set maximum duration, returned bytes, lines, concurrency, and per-tenant rate. When a limit is reached, return a resumable page token or a clear error. Streaming is acceptable, but a disconnect, deadline, or cap must release Kubelet and proxy resources.

4. Observe, handle failures, and roll back

Record caller identity, node, parameter summary, start and end time, bytes returned, truncation reason, and authorization result; do not copy log content into the audit stream. Fail fast when a node is unreachable and recommend centralized logs. Trip a circuit breaker and alert when Kubelet is overloaded. NodeLogQuery is stable and enabled by default in v1.36, while enableSystemLogQuery remains an operational setting; roll out to a canary node and keep a disable path.

Model answer

I would make NodeLogQuery a controlled node-diagnostics interface, not a file browser. First separate system logs, container logs, and centralized historical search. Callers authenticate and authorize through Kubelet and can query only approved nodes and log types. Tenants do not receive broad nodes/proxy access, and the platform verifies tenant-to-node binding.

Every query includes a node, service unit, time range, and severity with a short default window. Enforce byte, line, concurrency, rate, and deadline limits; stream or paginate results and report truncation. Audits keep identity, node, parameter summary, duration, size, and decision, never the body. Unreachable nodes and overloaded Kubelets fail fast, trip a breaker, and direct users to centralized logs. NodeLogQuery is stable and default-on in v1.36, but I would canary enableSystemLogQuery and retain rollback.

Common mistakes

  • Treating NodeLogQuery as arbitrary node-file access.
  • Giving tenants nodes/proxy and ignoring node and tenant isolation.
  • Allowing unbounded time ranges, output, or concurrency.
  • Writing log bodies to the audit stream and causing a second sensitive-data leak.
  • Retrying unreachable nodes indefinitely and amplifying control-plane or Kubelet load.

Follow-up questions and responses

Follow-up 1: Why not send every historical query through NodeLogQuery?

The node endpoint is suited to near-real-time diagnosis. Centralized collection should handle historical search, indexing, tenant isolation, and retention without consuming Kubelet resources for long reads.

Follow-up 2: How do you prove the query cannot cross a tenant boundary?

Record identity, node, resource, and decision for every request. Use synthetic tests to prove an allowed node succeeds and another tenant's node is denied, and verify the proxy rejects arbitrary paths and node parameters.

Follow-up 3: What if logs contain credentials?

Do not rely on irreversible guess-based redaction in the response. Reduce query scope, role, and retention, and perform structured redaction at collection. Revoke affected access and rotate credentials when a high-risk field is found.

Public sources

Related questions