Creating Package Revisions
A step by step guide to creating a package revision in Porch
In Porch, you work with PackageRevisions - there is no separate “Package” resource. When we say “package” colloquially, we’re referring to a PackageRevision. The rpkg command stands for “revision package”.
PackageRevisions are Kubernetes resources that represent versioned collections of configuration files stored in Git repositories. Each PackageRevision contains:
PackageRevision Operations:
| Operation | Git Command | Description |
|---|---|---|
| Creation | init, clone, copy |
Create new PackageRevisions from scratch, existing packages, or new revisions |
| Inspection | get |
List and view PackageRevision information and metadata |
| Content Management | pull, push |
Move PackageRevision content between Git repositories and local filesystem |
| Lifecycle Management | propose, approve, reject |
Control PackageRevision workflow states |
| Upgrading | upgrade |
Create new revision upgrading downstream to more recent upstream package |
| Deletion | propose-delete, del |
Propose deletion of published PackageRevisions, then delete them |
PackageRevisions follow a structured lifecycle with three main states:
PackageRevisions use the following lifecycle transitions:
| Transition | Command | Meaning |
|---|---|---|
| Draft → Proposed | porchctl rpkg propose |
Signal readiness for review |
| Proposed → Published | porchctl rpkg approve |
Approve and make immutable |
| Proposed → Draft | porchctl rpkg reject |
Return for more work |
| Published → DeletionProposed | porchctl rpkg propose-delete |
Mark for deletion, pending approval |
| DeletionProposed → Published | porchctl rpkg reject |
Reject deletion proposal |
Porch generates PackageRevision names automatically using the {repositoryName}.{packageName}.{workspaceName} format. An example PackageRevision naming would be porch-test.my-first-package.v1.
The name consists of the following components:
Workspace names must be unique within a package. Multiple PackageRevisions can share the same package name with different workspaces and published PackageRevisions get tagged in Git using the workspace name.
PackageRevisions contain structured configuration files that can be modified through various operations:
Local Operations:
KRM functions defined in the Kptfile automatically transform resources; they run when PackageRevisions are pushed to Porch. Common examples include set-namespace, apply-replacements, and search-replace.
When specifying a function image in the Kptfile pipeline, you can use the shorthand form (e.g. set-namespace:latest) without a full container registry path. Porch will automatically resolve it using the default registry prefix configured in the Function Runner. You can also use the full image path (e.g. ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest) if you prefer to be explicit. To see which functions are available, run kubectl get functionconfigs -n porch-fn-system.
Content Structure:
package-revision/
├── Kptfile # Package metadata and pipeline
├── .KptRevisionMetadata # Porch-managed metadata
├── package-context.yaml # Package context information
├── README.md # Package documentation
└── *.yaml # KRM resources
PackageRevisions are stored in Git repositories registered with Porch:
Git Branch Mapping:
draft/{workspace} branchproposed/{workspace} branch{workspace} and stored in main branchPorch differentiates two types of repositories: “blueprint” and “deployment”. Blueprint repositories are meant to contain upstream package templates for cloning, while deployment repositories should store deployment-ready packages. The latter are marked with the --deployment flag.
Porch automatically syncs with Git repositories, however you can perform a manual sync with the porchctl repo sync <repository-name> command. You can also configure periodic sync with cron expressions.
Common issues when working with PackageRevisions and their solutions:
PackageRevision stuck in Draft?
porchctl rpkg get <PACKAGE-REVISION> -o yaml | grep -A 5 conditions commandPush fails with conflict?
porchctl rpkg pull <PACKAGE-REVISION> <directory> commandCannot modify Published PackageRevision?
porchctl rpkg copy commandPackageRevision not found?
porchctl rpkg get --namespace default commandPermission denied errors?
kubectl auth can-i get packagerevisions -n default commandErrors about “placeholder package revision”?
Pipeline functions failing?
porch.kpt.dev/push-on-render-failure: "true" annotation to the PackageRevision
kubectl annotate packagerevision <name> porch.kpt.dev/push-on-render-failure=true
Important terms and concepts for working with PackageRevisions:
A step by step guide to creating a package revision in Porch
A guide to getting/listing, reading, querying, and inspecting package revisions in Porch
A step by step guide to copying package revisions in Porch
A step by step guide to cloning package revisions in Porch
A guide to upgrade package revisions using Porch and porchctl
A step by step guide to deleting package revisions in Porch