Skip to main content

SUMMARIZE POD HEALTH IN A KUBERNETES NAMESPACE

This guide shows you how to produce a health summary of the pods in a Kubernetes namespace. The summary includes counts by phase and by node, restart totals, high-restart pods and a healthy/unhealthy breakdown, all computed from pod data that Swamp has already stored. The examples use the shop namespace on the prod-cluster context.

Prerequisites

  • A kubeconfig with a prod-cluster context that can list pods in the shop namespace
  • A Swamp repository

Pull the extension

swamp extension pull @swamp/kubernetes

You will see output like:

INF extension·pull: Pulling "@swamp/kubernetes"@"2026.10.13.1"
INF extension·pull: Identity verified: "@swamp/kubernetes"@"2026.10.13.1"
INF extension·pull: Pulled "@swamp/kubernetes"@"2026.10.13.1"
INF extension·pull: Extracted 50 files:

Use a pod behavior and a summary behavior

The summary needs two behaviors. If you do not have them, create them as described in Create and Run a Behavior.

The first is a behavior named shop-pods of type @swamp/kubernetes/pod, which collects the pods:

globalArguments:
  namespace: shop
  context: prod-cluster

The second is a behavior named shop-pod-summary of type @swamp/kubernetes/pod-summary. Its sourceName points at the pod behavior whose stored data it reads:

globalArguments:
  sourceName: shop-pods

The summary behavior does not contact the cluster. It needs no namespace, context or kubeconfig.

Collect the pods

swamp behavior run shop-pods list

This fetches every pod in the shop namespace through the prod-cluster context and writes a pod resource for each, with phase, container statuses, conditions, IPs and restart counts.

The summary reflects the pods as of the last collection. Run this step again whenever you need a current summary.

Compute the summary

swamp behavior run shop-pod-summary summarize

This reads the pod resources stored by shop-pods and writes a summary resource with pod counts by phase and node, restart totals, high-restart pods and the healthy/unhealthy breakdown.

Read the summary

The summary resource is stored with the pod records it was computed from. To find and read it, see Query and Manage Data.

To repeat this collection on a fixed interval, put the two runs in a workflow and see Run Workflows on a Schedule.