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
