How cri-o/cri-o works
Project type and purpose
• CRI-O is a Kubernetes Container Runtime Interface (CRI) implementation that uses OCI-conformant runtimes (e.g., runc, crun).
• It is a backend daemon written in Go that exposes a gRPC CRI API (for kubelet) plus an HTTP status API, pulls/manages container images, invokes OCI runtimes, configures networking via CNI, and collects metrics/tracing.
File structure
• cmd/crio: the CLI entrypoint and daemon bootstrap (main.go).
• server/: the gRPC service handlers implementing CRI calls (container_create, sandbox_run, image_pull, metrics, health, etc.).
• internal/: core libraries broken out by concern—config loading, client code, factory for sandbox & container construction, OCI runtime integration, CNI/networking, cgroup/hostport managers, seccomp/Selinux, resource stores, logging, metrics, tracing, NRI plugin hooks.
• pkg/: shared types and configuration abstractions.
• contrib/, scripts/, hack/, nix/: build, packaging, CI/CD and deployment support.
• test/: end-to-end, BATS, unit and integration tests, mocks, testdata.
• docs/, tutorials/: user-facing documentation.
Key insights from the README
• CRI-O sits between the Kubelet (gRPC CRI caller) and an OCI Runtime (runc/crun).
• It delegates image management to containers/image, storage to containers/storage, and networking to CNI.
• Exposes metrics and tracing for observability.
Detail is key
• Major modules and external integrations.
• Configuration flow (config loader → modules).
• Observability paths (metrics/tracing).
• Don’t hesitate to break out sub-modules if it aids comprehension (e.g., separate Image Manager vs Storage Manager).