Skip to main content
KBY Technologies Logo

Switching the Kubelet to Webhook Authorization Cuts Off Monitoring Scrapers Until They Hold nodes/metrics

Medium severityKubernetes About 20 minutes to fix

Overview

A one-line kubelet hardening change blanks the dashboards for every node it touches. The scraper authenticates fine; it is the authorisation step that now says no.

At a glance

Symptom
A hardening ticket asks for kubelet authorisation to be delegated to the API server.
Likely cause
Authentication and authorisation are separate steps.
Impact
Metrics, and any alert rules built on them, stop for every node switched.
Verification signal
The scrape target for the changed node comes back up, and kubectl auth can-i get nodes --subresource=proxy --as=system:serviceaccount:monitoring:scraper still answers no.
Safe correction
Grant the narrow right first, then change the kubelet.
Rollback or recovery
Each step has its own way back.

Moving a kubelet from AlwaysAllow to Webhook authorization stops every caller that authenticates but holds no RBAC permission on the node, and a monitoring scraper reading the kubelet’s /metrics endpoint is a common casualty. The caller needs get on the nodes/metrics subresource. Grant exactly that, confirm it with kubectl auth can-i, and only then switch the nodes. Do not reach for nodes/proxy or system:kubelet-api-admin.

Symptom

A hardening ticket asks for kubelet authorisation to be delegated to the API server. The change goes out node by node. Shortly afterwards the kubelet scrape targets in your monitoring system go down on the nodes already changed, and dashboards for those nodes go blank. The scraper’s pod is healthy, its token has not expired, and the nodes are Ready.

The pattern follows the rollout. Nodes still on the old setting keep answering, so the fault looks like a flaky network or a bad node pool until you notice which nodes have the new setting.

Why the change looks safe

The caller already authenticates. Its service account token is accepted by the kubelet, so nothing about its identity is changing, and the change itself is a single line. It is also a standard hardening step. It is easy to assume that a request the kubelet already accepts will carry on being accepted.

Root cause

Authentication and authorisation are separate steps. Any request that is successfully authenticated, including an anonymous one, is then authorised, and the documented default mode for the kubelet is AlwaysAllow, which allows all requests. While that mode is set, a valid token is all the scraper needs.

The kubelet’s configuration-file default differs: authorization.mode is documented as Webhook there, and the documentation notes that some defaults differ between flags and the file. A node can therefore behave differently depending on how its kubelet was started.

With Webhook, the kubelet calls the API server’s SubjectAccessReview API for every request, using the same attribute approach as the API server.

The verb comes from the HTTP verb, so a GET is get. The path decides the resource: anything under /metrics/ is nodes with subresource metrics. The scraper’s service account has no rule for that (the table lists /metrics/*, and the plain /metrics path is assumed to map the same way), so RBAC, which is purely additive, gives it nothing and the request is refused.

Impact

Metrics, and any alert rules built on them, stop for every node switched. Nothing in the workloads fails, so the gap is silent until someone needs the data. A second caller is easy to miss: in Webhook mode, the identity the API server presents to the kubelet (the one named by --kubelet-client-certificate and --kubelet-client-key) must be authorised for the subresources proxy, stats, log, spec and metrics.

If it is not, the API server’s own requests to the kubelet are subject to the same check and can be refused the same way. With fine-grained authorisation (documented as stable from v1.36), the kubelet also checks pods, healthz and configz before falling back to proxy, so confirm the list on the documentation page for your version.

How to confirm it

These checks change nothing.

  1. On an affected node, see how the kubelet was started with ps -o args= -C kubelet. Look for --authorization-mode and the --config file. A flag overrides the same value in the file, so read both.
  2. Ask the API server whether the scraper may read node metrics: kubectl auth can-i get nodes --subresource=metrics --as=system:serviceaccount:monitoring:scraper. no matches the symptom.
  3. Check the other side of the same change with the identity that the API server uses to reach kubelets, using the same command with --as set to that identity.

Following along? Tap a step’s number to tick it off.

Authentication failures look different: with anonymous access disabled, the kubelet answers unauthenticated requests with 401 Unauthorized. A scraper that gets past authentication but is refused afterwards points at authorisation. For the unauthenticated side of the same endpoint, see kubelet Anonymous Auth Left On Grants Unauthenticated Root-Level Node API Access.

The tempting shortcut

Under pressure, people bind the scraper to system:kubelet-api-admin or give it get on nodes/proxy, or put the node back to AlwaysAllow. Each works and each costs the protection you just added.

The documentation warns that nodes/proxy grants access to all the other kubelet APIs, including those that can execute commands in any container on the node. Because some of those endpoints use WebSocket over HTTP GET, get on nodes/proxy is not a read-only permission. system:kubelet-api-admin is documented as full access to the kubelet API. Reverting to AlwaysAllow returns every authenticated caller to full access.

Correction

Grant the narrow right first, then change the kubelet. Do this on a test node pool before production.

  1. Back up the kubelet config file and note which nodes you will change. Keep the file you will edit under a dated name.
  2. Grant first. Apply a ClusterRole that allows only get on nodes/metrics and bind it to the scraper’s service account. A subresource is written resource/subresource, and the core API group is the empty string.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kubelet-metrics-reader
rules:
- apiGroups: [""]
  resources: ["nodes/metrics"]
  verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kubelet-metrics-reader
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kubelet-metrics-reader
subjects:
- kind: ServiceAccount
  name: scraper
  namespace: monitoring
  1. Prove it with the kubectl auth can-i check above, which should now answer yes, and the same command for nodes/proxy, which should still answer no. If the API server’s kubelet client identity is missing any of the subresources listed under Impact, grant those before continuing.
  2. Switch one node. Set the mode in the kubelet configuration file, and remove any --authorization-mode flag that contradicts it.
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
authorization:
  mode: Webhook
  1. Webhook mode needs the kubelet to have a --kubeconfig for the API server, and service account tokens authenticate only when webhook authentication is on (the configuration-file default; for flags it is --authentication-token-webhook). Restart the kubelet on that one node so it reads the file, then check the scrape target.
  2. Roll through the remaining nodes in small batches, stopping at the first failing target.

Validation

The scrape target for the changed node comes back up, and kubectl auth can-i get nodes --subresource=proxy --as=system:serviceaccount:monitoring:scraper still answers no. If the target stays down just after you granted the role, wait: the kubelet caches webhook answers, and the documented configuration-file default for unauthorised answers is 30 seconds (5 minutes for authorised ones). A denied request can therefore keep failing briefly after the grant.

Rollback

Each step has its own way back. To undo the grant, delete the ClusterRole and ClusterRoleBinding you applied with kubectl delete -f on the same manifest, which removes only the scraper’s access.

To undo the switch on a node, restore the dated copy of the kubelet configuration file and restart the kubelet. Reverting leaves that node on AlwaysAllow if that is what the flag or file said before, so record that as an open risk and not as a fix.

Stop the rollout and roll back the current batch when a target stays down after the cache window, or the API server’s own requests to a changed node start failing.

Prevention

Treat the kubelet’s authorisation mode as a dependency list. Before changing it, list who calls the kubelet (scrapers, log shippers, the API server’s client identity) and give each caller its specific subresource.

Review system:kubelet-api-admin and nodes/proxy bindings as you would cluster-admin. Keep the mode in one place, the configuration file, and make flags the exception, since a flag silently wins. Related reading on another route onto a node that sits outside the API server’s usual controls: Static Pod Manifests: hostPath’s Admission Bypass. Documentation to check for your version: the kubelet authentication and authorisation page and the KubeletConfiguration reference.

3

Apply the safer control

Before you change production

Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.

Fix commands and configuration

AlwaysAllow
Webhook
/metrics
4

When to escalate

Validation and rollback are covered in the sections above.

Escalate

Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.

The KBY Brief

Fixed? Get the next one before it hits you: The KBY Brief

Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.

About this page

Credited to

Dates

Published

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Found this useful? Follow KBY for more like it.

After remediation

Further reading stays below the corrective workflow and is selected by platform, category and shared technical keywords.

More from KBY that goes with this config trap.

Discover more

Connected KBY resources