github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/site/book/08-package-orchestration/02-quickstart.md (about) 1 In this quickstart you will use Porch to discover configuration packages 2 in a [sample repository](https://github.com/GoogleContainerTools/kpt-samples). 3 4 You will use the kpt CLI - the new `kpt alpha` command sub-groups to interact 5 with the Package Orchestration service. 6 7 ## Register the repository 8 9 Start by registering the sample repository with Porch. The repository already 10 contains a [`basens`][basens] package. 11 12 ```sh 13 # Register a sample Git repository: 14 $ kpt alpha repo register --namespace default \ 15 https://github.com/GoogleContainerTools/kpt-samples.git 16 ``` 17 18 ?> Refer to the [register command reference][register-doc] for usage. 19 20 The sample repository is public and Porch therefore doesn't require 21 authentication to read the repository and discover packages within it. 22 23 You can confirm the repository is now registered with Porch by using the 24 `kpt alpha repo get` command. Similar to `kubectl get`, the command will list 25 all repositories registered with Porch, or get information about specific ones 26 if list of names is provided 27 28 ```sh 29 # Query repositories registered with Porch: 30 $ kpt alpha repo get 31 NAME TYPE CONTENT DEPLOYMENT READY ADDRESS 32 kpt-samples git Package True https://github.com/GoogleContainerTools/kpt-samples.git 33 ``` 34 35 ?> Refer to the [get command reference][get-doc] for usage. 36 37 From the output you can see that: 38 39 * the repository was registered by the name `kpt-samples`. This was chosen 40 by kpt automatically from the repository URL, but can be overridden 41 * it is a `git` repository (OCI repositories are also supported, though 42 currently with some limitations) 43 * the repository is *not* a deployment repository. Repository can be marked 44 as deployment repository which indicates that packages in the repository are 45 intended to be deployed into live state. 46 * the repository is ready - Porch successfully registered it and discovered 47 packages stored in the repository. 48 49 The Package Orchestration service is designed to be part of the Kubernetes 50 ecosystem. The [resources] managed by Porch are KRM resources. 51 52 You can use the `-oyaml` to see the YAML representation of the repository 53 registration resource: 54 55 ?> kpt uses the same output format flags as `kubectl`. Flags with which you are 56 already familiar from using `kubectl get` will work with the kpt commands 57 that get or list Porch resources. 58 59 ```sh 60 # View the Repository registration resource as YAML: 61 $ kpt alpha repo get kpt-samples --namespace default -oyaml 62 apiVersion: config.porch.kpt.dev/v1alpha1 63 kind: Repository 64 metadata: 65 name: kpt-samples 66 namespace: default 67 spec: 68 content: Package 69 git: 70 branch: main 71 directory: / 72 repo: https://github.com/GoogleContainerTools/kpt-samples.git 73 secretRef: 74 name: "" 75 type: git 76 status: 77 conditions: 78 - reason: Ready 79 status: "True" 80 type: Ready 81 ``` 82 83 Few additional details are available in the YAML listing: 84 85 The name of the `main` branch and a directory. These specify location within 86 the repository where Porch will be managing packages. Porch also analyzes tags 87 in the repository to identify all packages (and their specific versions), all 88 within the directory specified. By default Porch will analyze the whole 89 repository. 90 91 The `secretRef` can contain a name of a Kubernetes [Secret][secret] resource 92 with authentication credentials for Porch to access the repository. 93 94 ### kubectl 95 96 Thanks to the integration with Kubernetes ecosystem, you can also use `kubectl` 97 directly to interact with Porch, such as listing repository resources: 98 99 ```sh 100 # List registered repositories using kubectl 101 $ kubectl get repository 102 NAME TYPE CONTENT DEPLOYMENT READY ADDRESS 103 kpt-samples git Package True https://github.com/GoogleContainerTools/kpt-samples.git 104 ``` 105 106 You can use kubectl for _all_ interactions with Porch server if you prefer. 107 The kpt CLI integration provides a variety of convenience features. 108 109 ## Discover packages 110 111 You can use the `kpt alpha rpkg get` command to list the packages discovered 112 by Porch across all registered repositories. 113 114 ```sh 115 # List package revisions in registered repositories 116 $ kpt alpha rpkg get 117 NAME PACKAGE REVISION LATEST LIFECYCLE REPOSITORY 118 kpt-samples-da07e9611f9b99028f761c07a79e3c746d6fc43b basens main false Published kpt-samples 119 kpt-samples-afcf4d1fac605a60ba1ea4b87b5b5b82e222cb69 basens v0 true Published kpt-samples 120 ``` 121 122 ?> Refer to the [get command reference][get-doc] for usage. 123 124 ?> The `r` prefix of the `rpkg` command group stands for `remote`. The commands 125 in the `kpt alpha rpkg` group interact with packages managed (remotely) by Porch 126 server. The commands in the `rpkg` group are similar to the `kpt pkg` commands 127 except that they operate on remote packages managed by Porch server rather than 128 on a local disk. 129 130 The output shows that Porch discovered the `basens` package, and found two 131 different revisions of it. The `v0` revision (associated with the 132 [`basens/v0`][basens-v0] tag) and the `main` revision associated with the 133 [`main` branch][main-branch] in the repository. 134 135 The `LIFECYCLE` column indicates the lifecycle stage of the package revision. 136 The package revisions in the repository are *`Published`* - ready to be used. 137 Package revision may be also *`Draft`* (the package revision is being authored) 138 or *`Proposed`* (the author of the package revision proposed that it be 139 published). We will encounter examples of these 140 141 Porch identifies the latest revision of the package (`LATEST` column). 142 143 ### View package resources 144 145 The `kpt alpha rpkg get` command displays package metadata. To view the 146 _contents_ of the package revision, use the `kpt alpha rpkg pull` command. 147 148 You can use the command to output the resources as a 149 [`ResourceList`][resourcelist] on standard output, or save them into a local 150 directory: 151 152 ```sh 153 # View contents of the basens/v0 package revision 154 $ kpt alpha rpkg pull kpt-samples-afcf4d1fac605a60ba1ea4b87b5b5b82e222cb69 -ndefault 155 156 apiVersion: config.kubernetes.io/v1 157 kind: ResourceList 158 items: 159 - apiVersion: kpt.dev/v1 160 kind: Kptfile 161 metadata: 162 name: basens 163 annotations: 164 ... 165 ``` 166 167 Add a name of a local directory on the command line to save the package onto 168 local disk for inspection or editing. 169 170 ```sh 171 # Pull package revision resources, save to local disk into `./basens` directory 172 $ kpt alpha rpkg pull kpt-samples-afcf4d1fac605a60ba1ea4b87b5b5b82e222cb69 ./basens -ndefault 173 174 # Explore the package contents 175 $ find basens 176 177 basens 178 basens/README.md 179 basens/namespace.yaml 180 basens/Kptfile 181 ... 182 ``` 183 184 ?> Refer to the [pull command reference][pull-doc] for usage. 185 186 ## Unregister the repository 187 188 When you are done using the repository with Porch, you can unregister it: 189 190 ```sh 191 # Unregister the repository 192 $ kpt alpha repo unregister kpt-samples -ndefault 193 ``` 194 195 ## More resources 196 197 To continue learning about Porch, you can review: 198 199 * [Porch User Guide](/guides/porch-user-guide) 200 * [Provisioning Namespaces with the UI](/guides/namespace-provisioning-ui) 201 * [Porch Design Document][design] 202 203 [basens]: https://github.com/GoogleContainerTools/kpt-samples/tree/main/basens 204 [register-doc]: /reference/cli/alpha/repo/reg/ 205 [get-doc]: /reference/cli/alpha/repo/get/ 206 [pull-doc]: /reference/cli/alpha/rpkg/pull/ 207 [unregister-doc]: /reference/cli/alpha/repo/unreg/ 208 [resources]: /guides/porch-user-guide 209 [secret]: https://kubernetes.io/docs/concepts/configuration/secret/ 210 [basens-v0]: https://github.com/GoogleContainerTools/kpt-samples/tree/basens/v0 211 [main-branch]: https://github.com/GoogleContainerTools/kpt-samples/tree/main 212 [resource-list]: /reference/schema/resource-list/ 213 [design]: https://github.com/GoogleContainerTools/kpt/blob/main/docs/design-docs/07-package-orchestration.md