Skip to content

Commit a357ebd

Browse files
committed
kp-cli tutorial updated
- Clarifies secret creation for dockerhub registry - Fixes order on secret and builder creation - Fixes kp secret save command to kp secret create
1 parent 9217f99 commit a357ebd

1 file changed

Lines changed: 40 additions & 34 deletions

File tree

docs/tutorial_kp.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ build an OCI image from source and allow kpack rebuild the OCI image with update
2929
```
3030

3131
> Note: The `<REGISTRY-HOSTNAME>` must be the registry prefix for its corresponding registry
32-
> - For [dockerhub](https://hub.docker.com/) this should be `https://index.docker.io/v1/`. `kp` also offers a simplified way to create a dockerhub secret with a `--dockerhub` flag.
33-
> - For [GCR](https://cloud.google.com/container-registry/) this should be `gcr.io`. `kp` also offers a simplified way to create a GCR secret with a `--gcr` flag that gets a path to a json file containing the service account password.
32+
> - For [dockerhub](https://hub.docker.com/) `kp` offers a simplified way to create a dockerhub secret with a `--dockerhub` flag. The registry in the secret should be `https://index.docker.io/v1/`.
33+
> - For [GCR](https://cloud.google.com/container-registry/), `kp` also offers a simplified way to create a GCR secret with a `--gcr` flag that followed by a path to a json file containing the service account password. The registry in the secret should be `gcr.io`.
3434

3535
> Note: The `<REPOSITORY>` must be a location in the docker registry that can be written to with the credentials
3636
> - For [dockerhub](https://hub.docker.com/) this should be `my-username/my-repo`.
3737
> - For [GCR](https://cloud.google.com/container-registry/) this should be `gcr.io/my-project/my-repo`.
3838

39+
> Note: Learn more about kpack secrets with the [kpack secret documentation](secrets.md)
40+
3941
2. Create a cluster store
4042

4143
A store resource is a repository of [buildpacks](http://buildpacks.io/) packaged
@@ -63,57 +65,60 @@ build an OCI image from source and allow kpack rebuild the OCI image with update
6365
kp clusterstack save base --build-image paketobuildpacks/build:base-cnb --run-image paketobuildpacks/run:base-cnb
6466
```
6567

66-
4. Create a Builder
67-
68-
A Builder is the kpack configuration for a [builder image](https://buildpacks.io/docs/concepts/components/builder/)
69-
that includes the stack and buildpacks needed to build an OCI image from your app source code.
70-
71-
The Builder configuration will write to the registry with the secret configured in step one and will reference the
72-
stack and store created in step three and four. The builder order will determine the order in which buildpacks are
73-
used in the builder.
74-
75-
```
76-
kp builder save my-builder \
77-
--tag <IMAGE-TAG> \
78-
--stack base \
79-
--store default \
80-
--buildpack paketo-buildpacks/java \
81-
-n default
82-
```
83-
84-
- Replace `<IMAGE-TAG>` with a valid image tag that exists in the registry you configured with the `--registry` flag when creating a Secret in step #1. The tag should be something like: `your-name/builder` or `gcr.io/your-project/your-repo/builder`.
85-
86-
5. Create a secret with push credentials for the docker registry that you plan on publishing OCI images to with kpack.
68+
4. Create a secret with push credentials for the docker registry that you plan on publishing OCI images to with kpack.
69+
This secret needs to be located in the same namespace as the builder that you will create in the next step.
8770

8871
The easiest way to do that is with `kp secret create`
8972

9073
```bash
91-
kp secret save tutorial-registry-credentials \
74+
kp secret create tutorial-registry-credentials \
9275
--registry <REGISTRY-HOSTNAME> \
9376
--registry-user <REGISTRY-USER> \
9477
-n default
9578
```
9679

9780
> Note: The `<REGISTRY-HOSTNAME>` must be the registry prefix for its corresponding registry
98-
> - For [dockerhub](https://hub.docker.com/) this should be `https://index.docker.io/v1/`. `kp` also offers a simplified way to create a dockerhub secret with a `--dockerhub` flag.
99-
> - For [GCR](https://cloud.google.com/container-registry/) this should be `gcr.io`. `kp` also offers a simplified way to create a GCR secret with a `--gcr` flag that followed by a path to a json file containing the service account password.
81+
> - For [dockerhub](https://hub.docker.com/) `kp` offers a simplified way to create a dockerhub secret with a `--dockerhub` flag. The registry in the secret should be `https://index.docker.io/v1/`.
82+
> - For [GCR](https://cloud.google.com/container-registry/), `kp` also offers a simplified way to create a GCR secret with a `--gcr` flag that followed by a path to a json file containing the service account password. The registry in the secret should be `gcr.io`.
10083

10184
Your secret create should look something like this:
10285

10386
```bash
10487
kp secret create tutorial-registry-credentials \
105-
--registry https://index.docker.io/v1/ \
106-
--registry-user my-dockerhub-username \
88+
--registry my-registry.io \
89+
--registry-user my-registry-username \
10790
-n default
10891
```
109-
or
92+
or
11093
```bash
11194
kp secret create tutorial-registry-credentials \
112-
--gcr service_account_password.json
95+
--gcr service_account_password.json \
96+
-n default
11397
```
11498

11599
> Note: Learn more about kpack secrets with the [kpack secret documentation](secrets.md)
116100

101+
5. Create a Builder
102+
103+
A Builder is the kpack configuration for a [builder image](https://buildpacks.io/docs/concepts/components/builder/)
104+
that includes the stack and buildpacks needed to build an OCI image from your app source code.
105+
106+
The Builder configuration will write to the registry with the secret configured in step one and will reference the
107+
stack and store created in step three and four. The builder order will determine the order in which buildpacks are
108+
used in the builder.
109+
110+
```
111+
kp builder save my-builder \
112+
--tag <IMAGE-TAG> \
113+
--stack base \
114+
--store default \
115+
--buildpack paketo-buildpacks/java \
116+
-n default
117+
```
118+
119+
- Replace `<IMAGE-TAG>` with a valid image tag that exists in the registry you configured with the `--registry` flag when creating a Secret in the previous step.
120+
The tag should be something like: `your-name/builder` or `gcr.io/your-project/your-repo/builder`.
121+
117122

118123
6. Create a kpack image resource
119124

@@ -136,9 +141,9 @@ build an OCI image from source and allow kpack rebuild the OCI image with update
136141
-n default
137142
```
138143

139-
- Make sure to replace `<IMAGE-TAG>` with the tag in the registry of the secret you configured in step #5. Something like:
140-
your-name/app or gcr.io/your-project/app
141-
- If you are using your application source, replace `--git` & `--git-revision`.
144+
- Make sure to replace `<IMAGE-TAG>` with the tag in the registry of the secret you configured in step #5. Something like:
145+
your-name/app or gcr.io/your-project/app
146+
- If you are using your application source, replace `--git` & `--git-revision`.
142147
> Note: To use a private git repo follow the instructions in [secrets](secrets.md)
143148

144149
You can now check the status of the image resource.
@@ -179,7 +184,7 @@ build an OCI image from source and allow kpack rebuild the OCI image with update
179184
kp build logs tutorial-image -n default
180185
```
181186

182-
Once the image resource finishes building you can get the fully resolved built OCI image with `kubectl get`
187+
Once the image resource finishes building you can get the fully resolved built OCI image with `kp image status`
183188

184189
```bash
185190
kp image status tutorial-image -n default
@@ -285,3 +290,4 @@ build an OCI image from source and allow kpack rebuild the OCI image with update
285290

286291
The next time new buildpacks are added to the store, kpack will automatically rebuild the builder. If the updated
287292
buildpacks were used by the tutorial image resource, kpack will automatically create a new build to rebuild your OCI image.
293+
in the registry you configured with the `--registry` flag when creating a Secret in step #1. The tag should be something like: `your-name/builder` or `gcr.io/your-project/your-repo/builder`.

0 commit comments

Comments
 (0)