How openkruise/kruise works
Project type and purpose
• Kruise is not a traditional web frontend/backend app but a CNCF‑incubating Kubernetes operator and runtime extension.
• Its purpose is to extend Kubernetes by defining new CRDs (CloneSet, SidecarSet, UnitedDeployment, etc.), running controllers (reconciliation loops), admission webhooks, and a node‑side daemon to manage pods, sidecars, and container runtimes.
File structure
• apis/ & config/crd/: CRD definitions for custom workloads.
• cmd/daemon & pkg/daemon/: node‑side daemon that interacts with the container runtime via CRI.
• pkg/controller/: control‑plane controllers implementing reconciliation logic for each CRD.
• pkg/webhook/: mutating & validating admission webhook server.
• pkg/client/, pkg/util/: generated clientsets, informers, listers, utility libraries using client‑go/controller‑runtime.
• config/, scripts/: YAML manifests (RBAC, manager, webhook), Helm hooks, Kustomize setups, CI/CD pipelines.
Gather additional insights from README
• Kruise runs as a Deployment (manager) in the Kubernetes control plane and as a DaemonSet (daemon) on each node.
• It uses controller‑runtime for controllers and client‑go informers to watch API objects.
• Webhook server handles admission requests before objects are persisted.
a. Kubernetes Control Plane
• kube‑apiserver + etcd (central API storage)
• CRDs (volume) for each Kruise resource
b. Kruise Manager (controller Deployment)
• Controllers (CloneSet, StatefulSet, SidecarSet, etc.)
• Shared informer‑factory, work queues, reconciliation loops
c. Admission Webhook Server
• Mutating & Validating webhook endpoints
• Kube‑apiserver calls webhooks on CREATE/UPDATE
d. Kruise Daemon (node‑side)
• Runs as a DaemonSet on each node
• Interacts with container runtime (CRI shim)
• Handles image pre‑pull, container recreate, probe management
e. Kubernetes Nodes & Pods
• Standard pods + Kruise‑managed pods
• Sidecar injection paths
f. External Clients & Tools
• kubectl / Helm CLI installing manifests
• Helm hook binary (cmd/helm_hook)
Relationships & interactions
• User (kubectl/Helm) → API Server → (Mutation webhook) → etcd
• etcd → Informers in Kruise Manager → enqueue reconciliation
• Controllers → API Server → create/update underlying Kubernetes primitives (Pods, Services, PVCs)
• Pod creations → (Mutation webhook) adds sidecar annotations → Pods scheduled to nodes
• Node kubelet runs Kruise Daemon → Daemon monitors container lifecycles, calls CRI plugin
• Metrics & health probes from both manager and daemon expose endpoints for Prometheus
Architectural patterns & design principles
• Kubernetes Controller pattern: informer → workqueue → reconcile
• Event‑driven, declarative — state converges to spec
• CRD extension and admission control (mutating/validating)
• Separation of control‑plane logic (stateless Deployment) and node agent (DaemonSet)
• Use of code‑gen for clientsets/informers (pkg/client), Kustomize for manifest composition
Relevant technologies & frameworks
• Go, controller‑runtime, client‑go for controllers and clients
• Kubebuilder conventions (CRD scaffolding)
• Kustomize & Helm for packaging CRDs, RBAC, webhook configurations
• Docker images multi‑arch build, CI pipelines (GitHub Actions)
• CRI shim interfaces for container runtime (pkg/daemon/criruntime)
Be very detailed
• Pkg/client informers funneling events into work queues.
• DaemonSet pod on each node, linking to CRI factory abstraction and container runtime.