Project: kpt (Provisioning / Automation & Configuration)
File: 02-quickstart.md

In this quickstart you will use Porch to discover configuration packages in a . You will use the kpt CLI - the new `kpt alpha` command sub-groups to interact with the Package Orchestration service. Start by registering the sample repository with Porch. The repository already contains a package. ```sh $ kpt alpha repo register --namespace default \ https://github.com/GoogleContainerTools/kpt-samples.git ``` ?> Refer to the for usage. The sample repository is public and Porch therefore doesn't require authentication to read the repository and discover packages within it. You can confirm the repository is now registered with Porch by using the `kpt alpha repo get` command. Similar to `kubectl get`, the command will list all repositories registered with Porch, or get information about specific ones if list of names is provided ```sh $ kpt alpha repo get NAME TYPE CONTENT DEPLOYMENT READY ADDRESS kpt-samples git Package True https://github.com/GoogleContainerTools/kpt-samples.git ``` ?> Refer to the for usage. From the output you can see that: the repository was registered by the name `kpt-samples`. This was chosen by kpt automatically from the repository URL, but can be overridden it is a `git` repository (OCI repositories are also supported, though currently with some limitations) the repository is not* a deployment repository. Repository can be marked as deployment repository which indicates that packages in the repository are intended to be deployed into live state. the repository is ready - Porch successfully registered it and discovered packages stored in the repository. The Package Orchestration service is designed to be part of the Kubernetes ecosystem. The [resources] managed by Porch are KRM resources. You can use the `-oyaml` to see the YAML representation of the repository registration resource: ?> kpt uses the same output format flags as `kubectl`. Flags with which you are already familiar from using `kubectl get` will work with the kpt commands that get or list Porch resources. ```sh $ kpt alpha repo get kpt-samples --namespace default -oyaml apiVersion: config.porch.kpt.dev/v1alpha1 kind: Repository metadata: name: kpt-samples namespace: default spec: content: Package git: branch: main directory: / repo: https://github.com/GoogleContainerTools/kpt-samples.git secretRef: name: "" type: git status: conditions: reason: Ready status: "True" type: Ready ``` Few additional details are available in the YAML listing: The name of the `main` branch and a directory. These specify location within the repository where Porch will be managing packages. Porch also analyzes tags in the repository to identify all packages (and their specific versions), all within the directory specified. By default Porch will analyze the whole

The `secretRef` can contain a name of a Kubernetes resource with authentication credentials for Porch to access the repository. Thanks to the integration with Kubernetes ecosystem, you can also use `kubectl` directly to interact with Porch, such as listing repository resources: ```sh $ kubectl get repository NAME TYPE CONTENT DEPLOYMENT READY ADDRESS kpt-samples git Package True https://github.com/GoogleContainerTools/kpt-samples.git ``` You can use kubectl for all interactions with Porch server if you prefer. The kpt CLI integration provides a variety of convenience features. You can use the `kpt alpha rpkg get` command to list the packages discovered by Porch across all registered repositories. ```sh $ kpt alpha rpkg get NAME PACKAGE REVISION LATEST LIFECYCLE REPOSITORY kpt-samples-da07e9611f9b99028f761c07a79e3c746d6fc43b basens main false Published kpt-samples kpt-samples-afcf4d1fac605a60ba1ea4b87b5b5b82e222cb69 basens v0 true Published kpt-samples ``` ?> Refer to the for usage. ?> The `r` prefix of the `rpkg` command group stands for `remote`. The commands in the `kpt alpha rpkg` group interact with packages managed (remotely) by Porch server. The commands in the `rpkg` group are similar to the `kpt pkg` commands except that they operate on remote packages managed by Porch server rather than on a local disk. The output shows that Porch discovered the `basens` package, and found two different revisions of it. The `v0` revision (associated with the tag) and the `main` revision associated with the in the repository. The `LIFECYCLE` column indicates the lifecycle stage of the package revision. The package revisions in the repository are `Published` - ready to be used. Package revision may be also `Draft` (the package revision is being authored) or `Proposed` (the author of the package revision proposed that it be published). We will encounter examples of these Porch identifies the latest revision of the package (`LATEST` column). The `kpt alpha rpkg get` command displays package metadata. To view the contents of the package revision, use the `kpt alpha rpkg pull` command. You can use the command to output the resources as a on standard output, or save them into a local directory: ```sh $ kpt alpha rpkg pull kpt-samples-afcf4d1fac605a60ba1ea4b87b5b5b82e222cb69 -ndefault apiVersion: config.kubernetes.io/v1 kind: ResourceList items: apiVersion: kpt.dev/v1 kind: Kptfile metadata: name: basens annotations: ... ``` Add a name of a local directory on the command line to save the package onto local disk for inspection or editing. ```sh $ kpt alpha rpkg pull kpt-samples-afcf4d1fac605a60ba1ea4b87b5b5b82e222cb69 ./basens -ndefault $ find basens basens basens/README.md basens/namespace.yaml basens/Kptfile ... ``` ?> Refer to the for usage. When you are done using the repository with Porch, you can unregister it: ```sh $ kpt alpha repo unregister kpt-samples -ndefault ``` To continue learning about Porch, you can review: