Understand the kapp source code structure
developThe kapp repository is organized into several key packages that separate CLI logic, resource management, and Kubernetes interaction:
- CLI Entrypoints:
cmd/kappis the main entry point. Commands are defined inpkg/kapp/cmd, withkapp.goacting as the root command andpkg/kapp/cmd/appcontaining top-level commands likedeployanddelete. - App Abstractions:
pkg/kapp/appdefines how applications are tracked:LabeledApp: Represents an app based on a user-provided label.RecordedApp: Represents an app backed by aConfigMap(usesLabeledAppinternally).
- Resource Management:
pkg/kapp/resourceshandles parsing, fetching, and modifying Kubernetes resources via theResourceinterface andResourceImpl. - Diffing Logic:
pkg/kapp/diffandpkg/kapp/diffgraphmanage resource differences and deployment/deletion ordering. Note: These packages are Kubernetes-agnostic. - Cluster Application:
pkg/kapp/clusterapplyis the single package responsible for modifying the Kubernetes cluster. It usesClusterChangeobjects to apply diffs and includes logic for resource convergence, retries, and deletions. - Resource Utilities:
pkg/kapp/resourcesmiscprovides objects for waiting on specific resource types (e.g., Pods, Services, Deployments). - Logging:
pkg/kapp/logsprovides log streaming functionality for thekapp logscommand.