liveBook · Manning

Node agent

As explained in Kubernetes in Action, Second Edition

A node agent is a node-local software component that exposes system information to client applications over a network protocol.

A node agent is a node-local software component that exposes system information to client applications over a network protocol. In Kubernetes, it commonly runs as a daemon Pod on every node and serves the workloads scheduled there. section 17.3 section 17.2

Node agents differ from ordinary application workloads in several practical ways:

  • Require elevated access to node devices, files, or kernel system calls because containers normally run inside Linux namespaces. section 17.2
  • Run one Pod per node through a DaemonSet, so each client can use the agent associated with its own node. section 17.2 section 17.3
  • May use hostPath volumes to access node files such as xtables.lock and kernel modules. section 17.2.2

Serving node information over a host port

A node-agent DaemonSet can listen on container port 80 and expose each local agent through host port 11559. Querying a node's address returns information such as uptime, load average, and active threads. A client can obtain its host IP through the Downward API and construct NODE_AGENT_URL as http://$(NODE_IP):11559. Unlike a NodePort Service, this host-port mapping forwards only to the agent Pod on the same node. section 17.3.1

Listing 17.5 Forwarding a host port to a container
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-agent
  ...
spec:
  template:
    spec:
      containers:
      - name: node-agent
        image: luksa/node-agent:0.1
        args:                           #1
        - --listen-address              #1
        - :80                           #1
        ...
        ports:                       #2
        - name: http
          containerPort: 80             #3
          hostPort: 11559     #4

Shows the DaemonSet manifest fields that bind container port 80 to host port 11559. section 17.3.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains DaemonSet placement, local connectivity, hostPort forwarding, and hostPath access, while deferring hostPath details.
Examples
Demonstrates a Go HTTP agent, kube-proxy, hostPort 11559, curl requests, and Kiada retrieving node uptime and utilization.
What it assumes
Assumes basic Pods and containers, while establishing node isolation, DaemonSets, local routing, and host access requirements.
What you can do after
Operate/configure a DaemonSet-based agent and connect client Pods to the local instance through hostPort and the Downward API.
How it connects
Connects node agents with DaemonSets, Pods, Services, NodePort Services, the Downward API, and hostPath volumes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.