Skip to content

Commit 22fb338

Browse files
committedOct 16, 2019
Added scenarios for modifying a collection
More review necessary. Signed-off-by: Sue Chaplain <sue_chaplain@uk.ibm.com>
1 parent 9143b9e commit 22fb338

File tree

2 files changed

+108
-42
lines changed

2 files changed

+108
-42
lines changed
 

‎README.adoc

+108-42
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ containerized, microservice-based applications.
6868

6969
A Kabanero Collection includes an Appsody stack, together with build and deployment artifacts, such as Tekton pipelines. Stacks
7070
consist of base container images and project templates for different language runtimes and framework, such as Microprofile
71-
with Open Liberty, or Node.js with Express.
71+
with OpenLiberty, or Node.js with Express.
7272

7373
== Creating a local Kabanero Collection Hub
7474

7575
The *public* Kabanero Collection Hub contains all the latest collections from the Kabanero project. Before working with
76-
Kabanero Collections, you must build the Kabanero Collection Hub locally by cloning the public GitHub repository.
76+
Kabanero Collections, you must create a Kabanero Collection Hub locally by cloning the public GitHub repository.
7777

7878
Run the following commands to clone the public Kabanero Collection Hub and push a copy of your repository (`private-org`) to your
7979
GitHub Enterprise organisation (`https://github.acme.com/my_org/collections.git`):
@@ -93,11 +93,11 @@ you are familiar with the contents and configurable components.
9393
Kabanero Collections are categorized into one of the following collection types:
9494

9595
- **stable** collections meet a set of predefined technical requirements.
96-
- **incubator** collections are actively being worked on to meet the requirements for a `stable` collection.
96+
- **incubator** collections are actively being worked on to meet the requirements for a **stable** collection.
9797
- **experimental** collections are just that! You can use them for proof of concept work or to try out specific
9898
scenarios, but these collections are not being actively worked on.
9999

100-
Although three categories are available, Kabanero builds only `stable` or `incubator` collections.
100+
Although three categories are available, Kabanero builds only **incubator** collections.
101101

102102
In a Kabanero Collection GitHub repository, collections are contained in a folder that matches the collection category. For example, `stable/`, `incubator/`,
103103
or `experimental/`. Each folder contains a `common/` directory for pipelines, and a collection folder for each collection in that category. For example:
@@ -173,36 +173,87 @@ for declaring CI/CD pipelines. A Collection can have multiple pipelines.
173173
This directory contains pre-configured templates for applications that can be used with a stack image. These templates help
174174
a developer get started with a development project.
175175

176-
== Creating and modifying Kabanero Collections
176+
== Modifying Kabanero Collections
177177

178-
Draft comment: Pick a stack, make a change.
178+
In some cases, you might want to modify a Kabanero Collection to change the version of a software component or expose a
179+
specific port for a type of application. In this guide, you will modify the `java-microprofile` collection to change the
180+
local port number that your application runs on.
179181

182+
Locate the `java-microprofile` collection in the `incubator` directory. The changes that you need to make are in the
183+
`image` directory, which contains all the artifacts needed for the development Docker image.
184+
185+
Open the `image/project/pom.xml` file and locate the section that defines the OpenLiberty runtime. Search for the string
186+
`<!-- OpenLiberty runtime --> `. The section looks similar to the following example:
187+
188+
```
189+
<!-- OpenLiberty runtime -->
190+
<liberty.groupId>io.openliberty</liberty.groupId>
191+
<liberty.artifactId>openliberty-runtime</liberty.artifactId>
192+
<version.openliberty-runtime>19.0.0.8</version.openliberty-runtime>
193+
<http.port>9080</http.port>
194+
<https.port>9443</https.port>
195+
<packaging.type>usr</packaging.type>
196+
<app.name>${project.artifactId}</app.name>
197+
<package.file>${project.build.directory}/${app.name}.zip</package.file>
198+
```
199+
Change the `<http.port>` from `9080` to `9090` and save your changes.
200+
201+
Modified Kabanero Collections must be built before they can be tested and released for developers to use.
180202

181203
You can also modify the default Tekton pipeline that is part of this Collection. However, this guide does not cover
182204
working with Tekton pipelines, which is the subject of another guide.
183205

206+
== Creating Kabanero Collections
207+
208+
Although it is possible to create a new Kabanero Collection for your organisation, we're not going to do this as part of this guide.
209+
However, the following steps outline the necessary tasks:
210+
211+
- Determine which collection category you want for your collection. For example, **incubator**.
212+
- Follow the instructions on the Appsody website for https://appsody.dev/docs/stacks/create[Creating a Stack].
213+
- If you don't want to use the common pipelines (`common/pipelines/`), create and add any collection-specific pipelines
214+
in the `<collection>/pipelines` directory.
215+
- Create a `collection.yaml` file in your new `collection` folder.
216+
217+
Example collection.yaml:
218+
219+
```
220+
default-image: <new-collection-name>
221+
default-pipeline: default
222+
images:
223+
- id: <new-collection-name>
224+
image: $IMAGE_REGISTRY_ORG/<new-collection-name>:<version>
225+
```
226+
227+
Where:
228+
229+
- `default-image:` specifies the Docker image to use for this collection.
230+
- `default-pipeline:` specifies which pipeline to use.
231+
- `images:` provides information about the Docker images used for this collection.
232+
- `- id:` specifies the Docker image reference information. Multiple `- id:` values can be specified, each with a unique
233+
Docker image, but only one can be used by the collection. The name of this Docker image must be specified in `default-image:`.
234+
- `$IMAGE_REGISTRY_ORG` defines the name of the image registry to use. The default is `kabanero`, which indicates the Docker hub
235+
organisation of `kabanero` where the Docker images are stored.
236+
- `<version>` is the version of your Docker image.
237+
238+
New Kabanero Collections must be built before they can be tested and released for developers to use.
239+
240+
== Deleting Kabanero Collections
241+
242+
If there are Kabanero Collections that you never need, you can delete them. Simply delete the directory that contains the collection
243+
before you build. As an alternative, you can set environment variables to exclude collections from the build
244+
process, which is covered in the following section.
245+
184246
== Setting up a local build environment
185247

186248
In addition to the tools that are defined in the **pre-requisites** section of this guide, to correctly build a
187249
Kabanero Collection, set the following environment variables by running `export <ENVIRONMENT_VARIABLE=option>` on the command line:
188250

189251
`IMAGE_REGISTRY_ORG=kabanero`::
190252
Defines the organization for images
191-
`CODEWIND_INDE=false`::
253+
`CODEWIND_INDEX=false`::
192254
Defines whether to build the Codewind index file for application development in VS Code, Eclipse, or Eclipse Che. If you
193255
want to build and test a collection for use with Codewind in an IDE, change this value to `true`.
194256

195-
If you plan to manually release collections, you must also export the following environment variables:
196-
197-
`IMAGE_REGISTRY_PUBLISH=false`::
198-
Defines whether to publish images to an image registry
199-
`IMAGE_REGISTRY=<registry>`::
200-
Defines the image registry
201-
`IMAGE_REGISTRY_USERNAME=<registry_username>`::
202-
Defines the user name for the image registry
203-
`IMAGE_REGISTRY_PASSWORD=<registry_password>`::
204-
Defines the password for the image registry
205-
206257
You are now ready to build a Kabanero Collection.
207258

208259
== Building a Kabanero Collection
@@ -214,25 +265,39 @@ of your local Kabanero Collections repository:
214265
./ci/build.sh
215266
```
216267

217-
When the build completes, you can find the deployment Docker images in your local registry by running the `docker images` command.
268+
The build processes the files for **incubator** collections, testing the format of the files, and finally building
269+
the development Docker images. When the build completes, you can find the images in your local registry by running the
270+
`docker images` command.
218271

219272
Other collection assets can be found in the `$PWD/ci/assets/` directory.
220273

221-
The build process also adds your local Kabanero Collection to the Appsody repository list.
274+
275+
=== Excluding a collection
276+
277+
If you want to exclude a collection at build time, you must set the following two environment variables:
278+
279+
REPO_LIST=<category>::
280+
Defines the category of collection to search. For example, `export REPO_LIST=incubator` builds only collections in the incubator directory, which is the default.
281+
To build collections in the **experimental** and **incubator** categories, use `export REPO_LIST=incubator experimental`.
282+
EXCLUDED_STACKS=<category/collection_name>::
283+
Defines which collections to exclude from the build. For example, `export EXCLUDED_STACKS=incubator/nodejs`
222284

223285
== Testing a Kabanero Collection locally
224286

225287
First, make sure that your local Kabanero index is correctly added to the Appsody repository list by running `appsody repo list`.
226288
The output is similar to the following example:
227289

228-
229290
If the `kabanero-index-local` repository is not in the list, add it manually by running the following command:
230291

231292
```
232-
appsody repo add kabanero-index-list file://$PWD/ci/assets/kabanero-index-local.YAML
293+
appsody repo add kabanero-index-local file://$PWD/ci/assets/kabanero-index-local.yaml
233294
```
234295

235-
Draft comment: Do we need to set the repo as the default?
296+
To set your repository as the default, run:
297+
298+
```
299+
appsody repo set-default kabanero-index-local
300+
```
236301

237302
You can now test your updated collection.
238303

@@ -245,27 +310,30 @@ export APPSODY_PULL_POLICY=IFNOTPRESENT
245310
To create a new project that is based on your updated collection, run:
246311

247312
```
248-
appsody init whatevercollectionwechoose (and if we set a default we can avoid specifying the index-repo/stack)
313+
mkdir java-microprofile
314+
cd java-microprofile
315+
appsody init java-microprofile
249316
```
250317

251-
Draft comment: We should have a quick sample and appsody run to prove it works correctly.
318+
The project is created in the `java-microprofile` directory with a sample starter application. To start the development
319+
environment, type `appsody run`.
252320

253-
Draft comment: We should have something better here for testing pipelines.
321+
The Appsody CLI launches a local Docker image that contains an Open Liberty server that hosts the microservice.
322+
After some time, you see a message similar to the following example:
254323

255-
Testing your collection would not be complete without testing your pipelines. Working with pipelines is covered in a separate guide.
324+
```
325+
[Container] [INFO] [AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 20.235 seconds.
326+
```
256327

257-
== Testing your Kabanero Collection with a test GIT release
328+
To check that the port changes you made when you modified the collection were successful, open your browser and
329+
navigate to `http://localhost:9090` to see the running application:
258330

259-
Draft comment: Is this more a Todd test? ->-> unedited
331+
image:https://github.com/kabanero-io/draft-guide-working-with-collections/raw/master/resources/browser.png[Diagram
332+
shows the browser for http://localhost:9090, which shows the "Welcome to your Appsody microservice" starter app.]
260333

261-
Before creating a final production release for use with your Kabanero installation, you may wish to create a test release on a test GIT repository.
334+
Congratulations! Your changes were successful.
262335

263-
Use these instructions to create a GIT release manually from your local build.
264-
Once all the artifacts are uploaded to the GIT Release, go to the assets inside that release and find the file kabanero-index.yaml and copy its URL. e.g. https://github.com/kabanero-io/collections/releases/download/v0.2.0.beta2/kabanero-index.yaml
265-
Within your Kabanero environment create a sample.yaml based on this sample yaml e.g. https://raw.githubusercontent.com/kabanero-io/kabanero-operator/master/config/samples/full.yaml
266-
In the yaml update the URL for the kabanero-index.yaml to tghe one from the release. e.g. https://github.com/kabanero-io/collections/releases/download/v0.2.0.beta2/kabanero-index.yaml
267-
Save the yaml and then apply it to your Kabanero instance kubectl apply -f sample.yaml
268-
This will update the collections and pipelines in your environment. New collections and pipeline should get activated as a result of this step.
336+
Full testing for your collections would not be complete without testing your pipelines. Working with pipelines is covered in a separate guide.
269337

270338
== Releasing Kabanero Collections
271339

@@ -276,10 +344,8 @@ git commit -a -m "Test Kabanero Collection created"
276344
git push -u private-org
277345
```
278346

279-
You can use Jenkins or Travis to trigger events based on webhooks. For example, you can set up a webhook that triggers a Travis build
280-
of your collections when a GIT merge takes place, providing an additional build test.
281-
282-
Draft comment: Annotated tags?
347+
You can use Jenkins or Travis to trigger events. For example, you can set up a Travis to automatically build your
348+
collections when a GIT merge takes place, providing an additional build test.
283349

284350
It is good practice to create release tags in GIT for versions of your collections. Create a GIT tag for your
285351
test collection:
@@ -290,5 +356,5 @@ git tag v0.1.0 -m "Test collection, version 0.1.0"
290356

291357
Push the tags to your GIT repository by running `git push --tags`.
292358

293-
A further webhook can be set up to trigger a Travis build that generates a GIT release, pushing the images to the image
294-
repository.
359+
Again, you can set up Travis to automatically trigger a build that generates a GIT release, pushing the images to the
360+
image repository for your organisation.

‎resources/browser.png

106 KB
Loading

0 commit comments

Comments
 (0)