tree
Display resources, files and packages in a tree structure.
tree displays resources, files and packages in a tree structure.
Each package (directory containing a Kptfile) is annotated with its type:
- (independent): The package has an
upstreamsection in itsKptfile, meaning it tracks its own upstream source and can be updated independently. - (dependent): A subpackage that does not have an
upstreamsection in itsKptfile. Its upstream is implicitly inherited from its parent package.
A root package created locally (e.g. via kpt pkg init) has no annotation since
it is neither independent nor dependent — it simply has no upstream source.
Synopsis #
kpt pkg tree [DIR]
Args #
DIR:
Path to a local package directory. Defaults to the current directory.
Displays KRM resources with their Kind and Name, and non-KRM text files
as plain filenames. Dotfiles and symlinks are excluded.
Flags #
--output, -o:
Output format, either "text" or "json". Defaults to "text".
The JSON output is a document with a "tree" field. Every node in the tree has
a "name", a "description" and a list of "children".
For a line printed as "[file.yaml] Kind name", the name is the file and the
description is "Kind name".
A package has its bare name in "name", and its type, "independent" or
"dependent", in a separate "type" field. Nothing else has a "type".
Examples #
# Show resources in the current directory.
$ kpt pkg tree
# Print the tree as JSON, for example to render it in an IDE or process it with jq.
kpt pkg tree -o json
# Example output showing independent and dependent packages:
$ kpt pkg tree wordpress/
Package "wordpress" (independent)
├── [Kptfile] Kptfile wordpress
├── [service.yaml] Service wordpress
├── deployment
│ ├── [deployment.yaml] Deployment wordpress
│ └── [volume.yaml] PersistentVolumeClaim wp-pv-claim
└── Package "mysql" (dependent)
├── [Kptfile] Kptfile mysql
├── [deployment.yaml] Deployment wordpress-mysql
└── [service.yaml] Service wordpress-mysql
Last modified November 10, 2026: Add --format json to kpt pkg tree (#4847) (0ecf3a00)