# alexei-led/pumba architecture

> Architecture diagram of the GitHub repository alexei-led/pumba, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexei-led/pumba
- Repository: https://github.com/alexei-led/pumba

## Overview

Pumba is a CLI chaos-testing tool for Docker, containerd, and Podman. Users select a runtime, choose containers by name, pattern, labels, or random selection, and invoke lifecycle, execution, network, or stress actions; interval scheduling can repeat the action. Runtime adapters implement the shared container interface, while network and stress operations may use helper containers or direct execution. README documents the major capabilities and runtime behaviors; some implementation links for unsampled command families are therefore shown as documented rather than source-verified.

Main entry points: [`pkg/container/client.go`](https://github.com/alexei-led/pumba/blob/master/pkg/container/client.go) (Container interface), [`cmd/runtime.go`](https://github.com/alexei-led/pumba/blob/master/cmd/runtime.go) (Runtime selection), [`cmd/main.go`](https://github.com/alexei-led/pumba/blob/master/cmd/main.go) (Pumba entry), [`pkg/runtime/docker/client.go`](https://github.com/alexei-led/pumba/blob/master/pkg/runtime/docker/client.go) (Docker adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and orchestration"]
  node_entry["Pumba entry<br/>[main.go]"]
  node_registration["Command registration<br/>[commands.go]"]
  node_runtime_select["Runtime selection<br/>[runtime.go]"]
  node_command_flow["Command scheduling<br/>[command.go]"]
  node_targeting["Container selection<br/>[runner.go]"]
end

subgraph group_actions["Chaos actions"]
  node_lifecycle["Lifecycle actions"]
  node_exec["Container execution<br/>[exec.go]"]
  node_netem["Network emulation"]
  node_target_resolve["Network targets<br/>[target.go]"]
  node_iptables["Ingress packet loss"]
  node_stress["Resource stress"]
end

subgraph group_runtime["Runtime adapters"]
  node_docker["Docker adapter<br/>[client.go]"]
  node_containerd["containerd adapter<br/>[client.go]"]
  node_podman["Podman adapter<br/>[client.go]"]
  node_helper["Helper containers<br/>[sidecar.go]"]
  node_containerd_stress["containerd stress<br/>[stress_sidecar.go]"]
  node_podman_stress["Podman stress<br/>[stress.go]"]
end

subgraph group_internals["Execution primitives"]
  node_shared_client["Container interface<br/>[client.go]"]
  node_container_model["Container model<br/>[container.go]"]
  node_tc["Traffic control<br/>[netem.go]"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_entry
node_entry -->|"registers commands"| node_registration
node_entry -->|"creates runtime"| node_runtime_select
node_registration -->|"builds actions"| node_command_flow
node_runtime_select -->|"selects Docker"| node_docker
node_runtime_select -->|"selects containerd"| node_containerd
node_runtime_select -->|"selects Podman"| node_podman
node_command_flow -->|"runs command"| node_targeting
node_targeting -->|"lists containers"| node_shared_client
node_lifecycle -.->|"changes lifecycle"| node_shared_client
node_exec -.->|"executes command"| node_shared_client
node_netem -->|"resolves targets"| node_target_resolve
node_target_resolve -->|"lists and resolves"| node_shared_client
node_netem -.->|"applies qdisc"| node_tc
node_iptables -.->|"applies packet loss"| node_shared_client
node_stress -.->|"stresses containers"| node_shared_client
node_docker -->|"implements interface"| node_shared_client
node_containerd -->|"implements interface"| node_shared_client
node_podman -->|"implements interface"| node_shared_client
node_docker -.->|"runs sidecars"| node_helper
node_containerd -.->|"supports stress"| node_containerd_stress
node_podman -.->|"supports stress"| node_podman_stress
node_shared_client -.->|"uses container model"| node_container_model

click node_entry "https://github.com/alexei-led/pumba/blob/master/cmd/main.go"
click node_registration "https://github.com/alexei-led/pumba/blob/master/cmd/commands.go"
click node_runtime_select "https://github.com/alexei-led/pumba/blob/master/cmd/runtime.go"
click node_command_flow "https://github.com/alexei-led/pumba/blob/master/pkg/chaos/command.go"
click node_targeting "https://github.com/alexei-led/pumba/blob/master/pkg/chaos/runner.go"
click node_lifecycle "https://github.com/alexei-led/pumba/tree/master/pkg/chaos/lifecycle"
click node_exec "https://github.com/alexei-led/pumba/blob/master/pkg/chaos/lifecycle/exec.go"
click node_netem "https://github.com/alexei-led/pumba/tree/master/pkg/chaos/netem"
click node_target_resolve "https://github.com/alexei-led/pumba/blob/master/pkg/chaos/netem/target.go"
click node_iptables "https://github.com/alexei-led/pumba/tree/master/pkg/chaos/iptables"
click node_stress "https://github.com/alexei-led/pumba/tree/master/pkg/chaos/stress"
click node_shared_client "https://github.com/alexei-led/pumba/blob/master/pkg/container/client.go"
click node_container_model "https://github.com/alexei-led/pumba/blob/master/pkg/container/container.go"
click node_tc "https://github.com/alexei-led/pumba/blob/master/pkg/tc/netem.go"
click node_docker "https://github.com/alexei-led/pumba/blob/master/pkg/runtime/docker/client.go"
click node_containerd "https://github.com/alexei-led/pumba/blob/master/pkg/runtime/containerd/client.go"
click node_podman "https://github.com/alexei-led/pumba/blob/master/pkg/runtime/podman/client.go"
click node_helper "https://github.com/alexei-led/pumba/blob/master/pkg/runtime/docker/sidecar.go"
click node_containerd_stress "https://github.com/alexei-led/pumba/blob/master/pkg/runtime/containerd/stress_sidecar.go"
click node_podman_stress "https://github.com/alexei-led/pumba/blob/master/pkg/runtime/podman/stress.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_registration,node_runtime_select,node_command_flow,node_targeting,node_user toneBlue
class node_lifecycle,node_exec,node_netem,node_target_resolve,node_iptables,node_stress toneAmber
class node_docker,node_containerd,node_podman,node_helper,node_containerd_stress,node_podman_stress toneMint
class node_shared_client,node_container_model,node_tc toneRose
```

## Components

### CLI and orchestration

- [Pumba entry](https://github.com/alexei-led/pumba/blob/master/cmd/main.go): `cmd/main.go`
- [Command registration](https://github.com/alexei-led/pumba/blob/master/cmd/commands.go): `cmd/commands.go`
- [Runtime selection](https://github.com/alexei-led/pumba/blob/master/cmd/runtime.go): `cmd/runtime.go`
- [Command scheduling](https://github.com/alexei-led/pumba/blob/master/pkg/chaos/command.go): `pkg/chaos/command.go`
- [Container selection](https://github.com/alexei-led/pumba/blob/master/pkg/chaos/runner.go): `pkg/chaos/runner.go`

### Chaos actions

- [Lifecycle actions](https://github.com/alexei-led/pumba/tree/master/pkg/chaos/lifecycle): `pkg/chaos/lifecycle`
- [Container execution](https://github.com/alexei-led/pumba/blob/master/pkg/chaos/lifecycle/exec.go): `pkg/chaos/lifecycle/exec.go`
- [Network emulation](https://github.com/alexei-led/pumba/tree/master/pkg/chaos/netem): `pkg/chaos/netem`
- [Network targets](https://github.com/alexei-led/pumba/blob/master/pkg/chaos/netem/target.go): `pkg/chaos/netem/target.go`
- [Ingress packet loss](https://github.com/alexei-led/pumba/tree/master/pkg/chaos/iptables): `pkg/chaos/iptables`
- [Resource stress](https://github.com/alexei-led/pumba/tree/master/pkg/chaos/stress): `pkg/chaos/stress`

### Runtime adapters

- [Docker adapter](https://github.com/alexei-led/pumba/blob/master/pkg/runtime/docker/client.go): `pkg/runtime/docker/client.go`
- [containerd adapter](https://github.com/alexei-led/pumba/blob/master/pkg/runtime/containerd/client.go): `pkg/runtime/containerd/client.go`
- [Podman adapter](https://github.com/alexei-led/pumba/blob/master/pkg/runtime/podman/client.go): `pkg/runtime/podman/client.go`
- [Helper containers](https://github.com/alexei-led/pumba/blob/master/pkg/runtime/docker/sidecar.go): `pkg/runtime/docker/sidecar.go`
- [containerd stress](https://github.com/alexei-led/pumba/blob/master/pkg/runtime/containerd/stress_sidecar.go): `pkg/runtime/containerd/stress_sidecar.go`
- [Podman stress](https://github.com/alexei-led/pumba/blob/master/pkg/runtime/podman/stress.go): `pkg/runtime/podman/stress.go`

### Execution primitives

- [Container interface](https://github.com/alexei-led/pumba/blob/master/pkg/container/client.go): `pkg/container/client.go`
- [Container model](https://github.com/alexei-led/pumba/blob/master/pkg/container/container.go): `pkg/container/container.go`
- [Traffic control](https://github.com/alexei-led/pumba/blob/master/pkg/tc/netem.go): `pkg/tc/netem.go`

### Other components

- **CLI user**

## Connections

- CLI user → Pumba entry: invokes (evidence: `README.md`)
- Pumba entry → Command registration: registers commands (evidence: `cmd/main.go`)
- Pumba entry → Runtime selection: creates runtime (evidence: `cmd/main.go`)
- Command registration → Command scheduling: builds actions (evidence: `cmd/commands.go`)
- Runtime selection → Docker adapter: selects Docker (evidence: `cmd/runtime.go`)
- Runtime selection → containerd adapter: selects containerd (evidence: `cmd/runtime.go`)
- Runtime selection → Podman adapter: selects Podman (evidence: `cmd/runtime.go`)
- Command scheduling → Container selection: runs command (evidence: `pkg/chaos/command.go`)
- Container selection → Container interface: lists containers (evidence: `pkg/chaos/runner.go`)
- Lifecycle actions → Container interface: changes lifecycle (evidence: `README.md`)
- Container execution → Container interface: executes command (evidence: `README.md`)
- Network emulation → Network targets: resolves targets (evidence: `pkg/chaos/netem/target.go`)
- Network targets → Container interface: lists and resolves (evidence: `pkg/chaos/netem/target.go`)
- Network emulation → Traffic control: applies qdisc (evidence: `README.md`)
- Ingress packet loss → Container interface: applies packet loss (evidence: `README.md`)
- Resource stress → Container interface: stresses containers (evidence: `README.md`)
- Docker adapter → Container interface: implements interface (evidence: `pkg/runtime/docker/client.go`)
- containerd adapter → Container interface: implements interface (evidence: `pkg/runtime/containerd/client.go`)
- Podman adapter → Container interface: implements interface (evidence: `pkg/runtime/podman/client.go`)
- Docker adapter → Helper containers: runs sidecars (evidence: `README.md`)
- containerd adapter → containerd stress: supports stress (evidence: `README.md`)
- Podman adapter → Podman stress: supports stress (evidence: `README.md`)
- Container interface → Container model: uses container model
