kubeadapt-k8s-pulse

by authors

Helm chartv1.1.0App 3.2.0Apache-2.0Verified publisher

High-performance eBPF-based network metrics agent for Kubernetes

About this chart

kubeadapt-k8s-pulse

High-performance eBPF-based network metrics agent for Kubernetes

Overview

The network monitor runs as a DaemonSet on every node. Its eBPF programs count each pod's traffic at the host side of the pod's network interface, and it sends one batch per node per minute to the Kubeadapt agent, which reports it as network cost.

Key Features

  • Per-pod traffic: sent and received bytes and packets for each pod, attached with TCX on kernel 6.6 and newer and with classic tc on older kernels
  • IPv4 and IPv6: dual-stack accounting on kernel 5.10 and newer
  • Pod and node identity: each node's pods are resolved through the Kubernetes API
  • Delivery to the agent: batches the agent has not acknowledged are kept and retried
  • Overflow handling: flows the kernel table has no room for are carried by a ring buffer instead of being lost
  • Prometheus metrics and health endpoints on every node

Prerequisites

  • Kubernetes: 1.24+
  • Linux Kernel: 5.10+ (full IPv4+IPv6 dual-stack support)
  • Helm: 3.0.0+

Get Repo Info

helm repo add kubeadapt https://kubeadapt.github.io/kubeadapt-helm
helm repo update

Or use OCI registry:

helm pull oci://ghcr.io/kubeadapt/kubeadapt-helm/kubeadapt-k8s-pulse --version 1.1.0

Installing the Chart

To install the chart with the release name kubeadapt-k8s-pulse:

helm install kubeadapt-k8s-pulse kubeadapt/kubeadapt-k8s-pulse -n kubeadapt --create-namespace

Or via OCI:

helm install kubeadapt-k8s-pulse oci://ghcr.io/kubeadapt/kubeadapt-helm/kubeadapt-k8s-pulse -n kubeadapt --create-namespace

Note: Using kubeadapt-k8s-pulse as release name ensures the service name matches Prometheus scrape configurations.

Installed on its own, the DaemonSet serves only its Prometheus metrics. To report network cost, install it through the kubeadapt chart with kubeadapt-k8s-pulse.enabled=true, which also turns on the agent's listener and gives both sides a shared token. To send to an agent installed separately, set config.export.enabled=true, config.export.agentEndpoint and config.export.tokenSecret (a Secret with the agent's token under the key token).

Uninstalling the Chart

To uninstall/delete the deployment:

helm delete kubeadapt-k8s-pulse -n kubeadapt

What the Pod Asks of the Node

Everything the DaemonSet's pod uses beyond an ordinary pod, and why. A platform team can write a policy exception from this table; examples/network-monitor has one each for Pod Security Admission, Kyverno and Gatekeeper.

WhatIn the pod specWhyCan it go?
Node's network namespacehostNetwork: trueThe programs attach to the host side of every pod's network interface and follow interfaces as pods come and go. Both exist only in the node's network namespace.No
A port of the nodecontainer port 9090 (config.metricsPort)Health probes and Prometheus metrics. A port of the node only because the pod uses the node's network. Open on every node address, without authentication.The number can be changed
Node's PID and IPC namespacesnot used
Privileged containerprivileged: true (default)Load and attach the BPF programs, read the node's processes and cgroups.privileged: false runs it with only the five capabilities below and allowPrivilegeEscalation: false, where the node's security policy allows that set
Root userrunAsUser: 0The BPF filesystem and the cgroup tree are owned by root.No
Capability BPFcapabilities.add, with privileged: falseCreate BPF maps and load the programs.No
Capability PERFMONcapabilities.add, with privileged: falseThe kernel verifier accepts the programs only with it.No
Capability NET_ADMINcapabilities.add, with privileged: falseAttach to pod network interfaces, follow interface changes, read connection tracking.No
Capability SYS_RESOURCEcapabilities.add, with privileged: falseRaise the locked-memory limit for BPF maps.Yes, on kernel 5.11 and newer
Capability SYS_PTRACEcapabilities.add, with privileged: falseRead other containers' executables for the runtime inventory.Yes, with EBPF_FINGERPRINT_ENABLED=false in env
Every other capabilitycapabilities.drop: [ALL], with privileged: false
Root filesystemreadOnlyRootFilesystem: trueWrites go to an emptyDir at /tmp.
Host path /procread-only, at /host/procThe node's processes, for the container runtime inventory.No
Host path /sys/fs/bpfwritable, propagation HostToContainer, created if missingThe pinned flow table that survives a restart, the lock that keeps one instance per node, and on Cilium its connection tracking maps.No
Host path /sys/fs/cgroupread-onlyFind pod cgroups, attach the cgroup programs, read the container's own memory use.No
Host path /etc/cni/net.dread-only, at /host/etc/cni/net.d, created if missingIdentify the CNI and the encapsulation overhead it adds to each packet.No
Host path /var/run/ztunnelonly with istioAmbient.enabled: read-only, at /host/var/run/ztunnel, created if missingDetect an Istio ambient mesh by its socket.Not mounted by default
Seccomp profileunset (seccompProfile)The runtime's default profile must allow bpf and perf_event_open before it can be set.
SELinux labelunset (seLinuxOptions)Set it where the node's policy denies the default container label these operations.
Kubernetes APIClusterRole: list, watch pods; get nodes; list ciliumenvoyconfigs.cilium.io (rbac.create)Pod identity for each node's traffic, the node's UID and zone, Envoy detection on Cilium.Traffic is then reported without pod and node identity
Agent tokenSecret volume, read-onlyThe token the agent checks on every batch.Only with export off

Against the Pod Security Standards, the privileged container, the host network, the host paths and the node port are outside baseline (with privileged: false, the added capabilities are); root and the unset seccomp profile are in addition outside restricted. The namespace must therefore allow the privileged level.

Image Version

Do not run a network monitor image older than the chart's minimum (the kubeadapt.io/minimum-image-version annotation in Chart.yaml) on a cluster whose CNI or network policy agent attaches classic tc filters to pod interfaces: those images replace that filter, so network policy stops being enforced on the node and stays off after the network monitor is removed. The chart refuses such an image tag. A tag that is not a release version, or one pinned by digest, cannot be compared: it is accepted, and the install notes say so.

Istio Ambient Mesh

Set istioAmbient.enabled=true on a cluster that runs ztunnel. The pod then mounts the node's /var/run/ztunnel read-only, which is how the network monitor tells that a node is in ambient mode. It is off by default because mounting a host directory that does not exist creates it, which would leave an empty directory on every node of a cluster without the mesh.

Scheduling and Rollout

  • Which nodes. One pod per Linux node without taints. The default tolerations is empty, so tainted pools (control plane, GPU, spot and other dedicated pools) are not measured; add their taints, or [{operator: Exists}] for every taint. nodeRequirements keeps the DaemonSet off nodes where its pod can never start (AWS Fargate, virtual-kubelet, other operating systems): no pod is created for them, so none stays Pending. It is applied on top of nodeSelector and affinity.

  • Priority. The pod requests 100m CPU and 256Mi. A node whose capacity is already requested has no room for it, when the network monitor is first turned on and again whenever its pod there restarts or is replaced: the DaemonSet deletes the old pod before it creates the new one, nothing holds the room in between, and a workload pod that was waiting takes it within the same second. Kubernetes has no way to keep the room without evicting for it, so there are three choices, described in full in values.yaml:

    priorityClassName: "" (default)priorityClass.create: truepriorityClassName: system-node-critical
    Evicts workload podsneveron a node without room: as few as needed, lowest priority and most recently started first, only below priorityClass.value (1000000)on a node without room: any pod below the node-critical ones
    First enable on a full nodepod Pending, node not measured until room appearsone workload pod evicted in tests; the network monitor starts when that pod has ended (2 s in tests, at most its termination grace period)same
    Restart or rollout on a full node with workload pods waitinga waiting pod takes the room, network monitor Pendingthe pod that just took the room is evicted before its container starts, network monitor back in 2 ssame
    Can be evicted byany workload with a priority classworkloads with a class above priorityClass.valueno workload
    Rollout and helm upgrade --waitstop when the waiting pods fill the maxUnavailable sharecompletecomplete
    Under node memory pressureends like any workload containerends like any workload containerworkload containers are ended first
  • Rollout. A change reaches updateStrategy.rollingUpdate.maxUnavailable of the nodes at a time, 25% by default: four waves of well under a minute each, on any number of nodes. A pod that fails to become ready counts against that share, so a bad release stops there; so does a pod that waits Pending on a node without room. A restart leaves a short gap in that node's measurements and does not touch pod traffic. maxSurge cannot be used, because the pod uses the node's network and only one instance per node attaches. A rollout that is held by waiting pods continues when they start; to push it through, raise the share for that one upgrade (--set updateStrategy.rollingUpdate.maxUnavailable=50%, under kubeadapt-k8s-pulse. in the kubeadapt chart).

  • helm upgrade --wait. Helm waits until the rollout has reached every node, so pods that wait Pending can hold it until the timeout; the release is then marked failed although everything else runs, and --atomic rolls it back. On a large cluster, leave --wait and --atomic out of the upgrade that turns the network monitor on or changes it, and watch the DaemonSet (see Troubleshooting). Helm 4 in addition needs every pod ready by default; --wait=legacy gives the Helm 3 rule.

Private Registries

Set image.repository to your copy of the image and, where the registry needs credentials, imagePullSecrets (or global.imagePullSecrets in the kubeadapt chart, which also covers the agent and the upgrade Job). The pull policy is IfNotPresent: release tags are not moved, and a pull on every pod start on every node runs into registry rate limits on a large cluster.

Exported Metrics

Traffic

MetricTypeDescription
kubeadapt_connection_traffic_bytes_totalCounterBytes the node's pods sent, by protocol (use rate() for throughput)
kubeadapt_connection_traffic_packets_totalCounterPackets the node's pods sent, by protocol
kubeadapt_overflow_bytes_drained_totalCounterBytes carried by the overflow ring buffer, by protocol; add to the bytes above for the total

Health

MetricTypeDescription
kubeadapt_bpf_load_statusGauge1 when the BPF programs loaded
kubeadapt_attach_modeGaugeAttach mode in use (TCX or classic tc)
kubeadapt_veth_coverage_ratioGaugeShare of pod interfaces pulse is attached to
kubeadapt_bpf_map_utilization_percentGaugeFill level of the kernel flow table
kubeadapt_pod_resolver_syncedGauge1 when pod identity is available
kubeadapt_duplicate_pulse_instanceGauge1 when another instance already runs on the node
kubeadapt_lost_events_totalCounterObservations that did not reach a batch, by site
kubeadapt_pulse_retry_buffer_batchesGaugeBatches waiting for the agent
kubeadapt_pulse_export_acked_batches_totalCounterBatches the agent acknowledged

Values

KeyTypeDefaultDescription
affinityobject{}
capabilities[0]string"BPF"
capabilities[1]string"PERFMON"
capabilities[2]string"NET_ADMIN"
capabilities[3]string"SYS_RESOURCE"
capabilities[4]string"SYS_PTRACE"
config.connectionTrackingbooltrue
config.enableProfilingboolfalse
config.export.agentEndpointstring""
config.export.enabledboolfalse
config.export.tokenSecretstring""
config.logFormatstring"json"
config.logLevelstring"info"
config.metricsPortint9090
config.profilingPortint6060
dnsPolicystring"ClusterFirstWithHostNet"
enabledbooltrue
env[0].namestring"EBPF_RETRY_BUFFER_SIZE"
env[0].valuestring"120"
image.pullPolicystring"IfNotPresent"
image.repositorystring`"public.ecr.aws/k2x0t8t6/kubeadapt/ap

Deploy kubeadapt-k8s-pulse with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kubeadapt-k8s-pulse on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartkubeadapt-k8s-pulse is pinned at v1.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply