Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 05098e9

Browse files
Merge pull request #175 from jc-berger/DOCEDITS
doc edits to dev PR and modularization changes
2 parents 2d62577 + 4ff34f1 commit 05098e9

File tree

1 file changed

+69
-54
lines changed

1 file changed

+69
-54
lines changed

docs/modules/ROOT/pages/how-to-guides/Secure-your-supply-chain/proc_java_dependencies.adoc

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ The Java Virtual Machine Build Service (JBS or JVM Build Service) is a controlle
88

99
The Java ecosystem uses a binary distribution model, where binary jar files are downloaded from central repositories, such as Maven Central. This distribution model means that the only way to ensure an application is completely built from source is to rebuild all its component libraries from source in a trusted environment. Due to the Java ecosystem, you would need to manually rebuild the component libraries.
1010

11-
Although the Java binary distribution model is very convenient, it does mean that you will inevitably use untrusted dependencies with unknown provenance maintained by external communities. In general, you don't know who has uploaded these artifacts, the environment that was used to build them, or how that build environment might be compromised. Building from source in a secure environment means that you can be be completely sure as to where the code you are running has come from.
11+
The Java binary distribution model relies on dependencies with unknown provenance maintained by external communities. This means that you can't be sure who uploaded these artifacts or the build environment, so you can't be sure of their flaws or vulnerabilities. The only way to know that you're building from clean, logical code in a secure environment is to build from source code.
1212

1313
JBS automates this process as much as possible, making it much less time-consuming to create builds that are build from source in a controlled environment.
1414

1515
=== Workflow Description
1616

17-
When using the JVM Build Service the end user workflow is as follows:
17+
When using the JVM Build Service, the user workflow is as follows:
1818

19-
- The system builds your application by using community dependencies.
19+
* The system builds your application by using community dependencies.
2020

21-
- The JVM Build Service analyzes your application and determines the dependencies that the system needs to rebuild.
21+
* The JVM Build Service analyzes your application and determines which dependencies the system needs to rebuild.
2222

23-
- The JVM Build Service generates `ArtifactBuild` objects to represent each artifact in your application before determining to which repository the artifacts belong. The JVM Build Service tags from which systems the artifacts derive.
23+
* The JVM Build Service generates `ArtifactBuild` objects to represent each artifact in your application before determining to which repository the artifacts belong. The JVM Build Service tags from which systems the artifacts derive.
2424

25-
- The system analyzes the repository and uses the results to find a build strategy. For example, if the system cannot find the JDK version to use, the system uses all versions to determine the most effective version to use.
25+
* The system analyzes the repository and uses the results to find a build strategy. For example, if the system cannot find the JDK version to use, the system uses all versions to determine the most effective version to use.
2626

27-
- The system attempts to build all the dependencies and stores them in container images in an image registry, and `quay.io` is the default.
27+
* The system attempts to build all the dependencies and stores them in container images in an image registry, and `quay.io` is the default.
2828

29-
- When the system has completed all its builds, you can rebuild your application.
29+
* When the system has completed all its builds, you can rebuild your application.
3030

31-
- If all the builds are successful, your application's SBOM displays that none of the dependencies came from third-party repositories. However, you may need to troubleshoot when some dependencies fail to build.
31+
* If all the builds are successful, your application's SBOM displays that none of the dependencies came from third-party repositories. However, you may need to troubleshoot when some dependencies fail to build.
3232

3333
== Setup
3434

@@ -38,37 +38,55 @@ All interactions with the JVM Build Service require you to be logged into the Op
3838

3939
.Procedure
4040

41-
Copy the login command from: https://registration-service-toolchain-host-operator.apps.stone-prd-host1.wdlc.p1.openshiftapps.com/
41+
* Copy the login command from: https://registration-service-toolchain-host-operator.apps.stone-prd-host1.wdlc.p1.openshiftapps.com/
4242

4343
=== Setting up the CLI
4444

45-
Many of the commands below can be setup using the JVM Build Service CLI.
45+
Many of the commands can be setup using the JVM Build Service CLI. The CLI is currently distributed as a docker image.
4646

47-
The CLI is currently distributed as a docker image. To use the docker image, create the following alias:
47+
.Prerequisite
4848

49+
* Log into your OpenShift namespace.
50+
51+
.Procedure
52+
53+
. To use the Docker image, create the following alias:
54+
55+
+
4956
```
5057
alias jbs='docker run --mount type=bind,source=$HOME/.kube/config,target=/kube --mount type=bind,source=$HOME/.github,target=/root/.github --env KUBECONFIG=/kube -it --rm quay.io/redhat-appstudio/hacbs-jvm-cli:latest'
5158
```
5259

53-
To update the latest version, create an update alias. You can run this alias to pull the latest version of the docker image:
60+
. To update the latest version, create an updated alias.
61+
. To pull the latest version of the Docker image, run the updated alias:
5462

63+
+
5564
```
5665
alias update-jbs='docker pull quay.io/redhat-appstudio/hacbs-jvm-cli:latest'
5766
```
5867

59-
The CLI supports tab completion and all the commands have a --help option to show usage.
68+
. To show the usage, run commands with `--help` option.
69+
. To modify build recipes, like commands that fix failing builds, create a file like, `$HOME/.github`, that is specified at https://github-api.kohsuke.org/[].
70+
71+
== Configuring The JVM Rebuild Service
6072

61-
Note that this CLI also requires you to be logged in as described above.
73+
You can set up the JVM Build Service in the following ways:
6274

63-
To use commands that modify build recipes (i.e. commands that are used to fix failing builds) you will need to create a `$HOME/.github` file as specified at https://github-api.kohsuke.org/[].
75+
* Setting up with the CLI
76+
* Setting up without Quay.io configuration
77+
* Setting up with Quay.io configuration
6478

65-
== Configuring The JVM Rebuild Service
79+
=== Setting up with the CLI
6680

67-
There are three ways to setup the JVM Build Service, they are listed below.
81+
If you do not require explicit quay.io configuration, you can simply set up the JVM Build Service. The JVM Build service automatically creates rebuilds for you and creates a query repository to store your rebuilt artifacts.
6882

69-
=== Setting up using the CLI
83+
.Prerequisite
7084

71-
If you do not require explicit quay.io configuration, and you have setup the CLI this is the simplest way to setup the JVM Build Service. To do this run the `setup rebuilds` command in the CLI:
85+
* You have setup the CLI.
86+
87+
.Procedure
88+
89+
* In the CLI, run the `setup rebuilds` commmand:
7290

7391
[source]
7492
----
@@ -78,14 +96,15 @@ found .dockerconfigjson secret with appropriate token keys in namespace sdouglas
7896
Rebuilds setup successfully
7997
----
8098

81-
This will automatically perform the steps detailed below and setup rebuilds for you. The JVM Build Service will automatically create a quary repository to store your rebuilt artifacts.
99+
The `setup rebuilds` command automatically performs the steps detailed below and creates rebuilds for you. The JVM Build Service automatically creates a query repository to store your rebuilt artifacts.
82100

83-
=== Manual Setup Without Quay.io Configuration*
101+
=== Setting up without Quay.io configuration*
84102

85-
If you do not want to use the CLI this method creates the Kubernetes objects to setup the JVM Build Service directory using `kubectl`.
103+
If you do not want to use the CLI, use the `kubectl` command to create the Kubernetes objects to set up the JVM Build Service directory.
86104

87-
. Create a file, for example, `config.yaml`.
105+
.Procedure
88106

107+
. Create a file, for example, `config.yaml`.
89108
. In the `config.yaml` file, create a `JBSConfig` resource with the following data:
90109

91110
+
@@ -102,12 +121,13 @@ spec:
102121
. Run `kubectl apply -f config.yaml`
103122

104123

105-
=== Manual Procedure With Explicit Quay.io Config
124+
=== Setting up with explicit Quay.io configuration
106125

107-
This is required if you want to specify where the rebuilt artifacts are stored. It is more complex you must also provision a secret to allow the JVM Build Service to push to the repository.
126+
If you want to specify where the rebuilt artfiacts are stored, you must use the Quay.io configuration to configure your JVM Build Service. You must also provision a secret to allow the JVM Build Service to push to the repository.
108127

109-
. Create a file, for example, `config.yaml`.
128+
.Procedure
110129

130+
. Create a file, for example, `config.yaml`.
111131
. In the `config.yaml` file, create a *JBSConfig* resource with the following data:
112132

113133
+
@@ -128,19 +148,16 @@ spec:
128148
maven-repository-302-confluent: "https://packages.confluent.io/maven"
129149
130150
----
131-
<1> To enable and configure the rebuild dependencies function you need to add enable-rebuilds: "true" to the `JBSConfig` object.
151+
<1> To enable and configure the rebuild dependencies function, add enable-rebuilds: "true" to the `JBSConfig` object.
132152
<2> The URL of the registry that holds the images of your rebuild dependencies.
133153
<3> The organization ID.
134154
<4> The repository to store the images in.
135155
<5> List any additional Maven repositories here.
136156

137-
. Run `kubectl apply -f config.yaml` while logged into the build namespace.
138-
139-
Now we have added the configuration we need to setup the Quay.io credentials to be able to push to our repository. The JVM
140-
Build Service uses the https://github.com/redhat-appstudio/service-provider-integration-operator[Service Provider Integration Operator] to store credentials in AWS Secrets Manager.
141-
142-
To upload our secret first we need to run a command to get the name of the `SPIAccessToken` we need to update, to do this
143-
run the following command:
157+
. While logged into the build namespace, run `kubectl apply -f config.yaml`.
158+
. Add the configuration to set up the Quay.io credentials to be able to push to the repository. To store credentials in AWS Secrets Manager, the JVM
159+
Build Service uses the https://github.com/redhat-appstudio/service-provider-integration-operator[Service Provider Integration Operator].
160+
. To upload the secret first, run a command to get the name of the `SPIAccessToken` that you need to update. Run the following command:
144161

145162
----
146163
kubectl get spiaccesstokenbindings.appstudio.redhat.com jvm-build-image-secrets -o yaml`
@@ -189,30 +206,34 @@ status:
189206
----
190207
<1> This is the name of the APIAccessToken we need to upload the secret
191208

192-
Record the name of the `linkedAccessTokenName` (in this case `generated-spi-access-token-px5w8`), this
193-
will be referred to as $ACCESS_TOKEN in the examples below.
209+
. Record the name of the `linkedAccessTokenName`. In this case, `generated-spi-access-token-px5w8`. This is referenced as
210+
$ACCESS_TOKEN in the examples below.
211+
212+
==== Creating a secret with specific configuration
194213

195-
Now we need to create a secret with specific config that will be uploaded to AWS Secrets Manager.
214+
Create a secret with specific configuration that uploads to AWS Secrets Manager. You need a quay.io username and password. The best way to get a username and password is to log in,
215+
create a robot account, and then record the username and password. For the purposes
216+
of the examples below, the username and password are referred to as $QUAY_USERNAME and $QUAY_PASSWORD.
196217

197-
For the next step we need a quay.io username and password. The best way to get these is to log in
198-
and create a robot account, and record the username and password after account creation. For the purposes
199-
of the examples below these will be referred to as $QUAY_USERNAME and $QUAY_PASSWORD.
218+
.Procedure
200219

201-
Create a secret with the following command:
220+
. Create a secret with the following command:
202221

222+
+
203223
----
204224
kubectl create secret generic jvm-build-service-upload --from-literal=userName=$QUAY_USERNAME --from-literal=tokenData=$QUAY_PASSWORD --from-literal=providerUrl=quay.io --from-literal=spiTokenName=$ACCESS_TOKEN
205225
----
206226

207-
Then we need to add a special label to the secret so that the SPI knows to store it in AWS Secrets Manager:
227+
. Add a special label to the secret so that the SPI knows to store it in AWS Secrets Manager:
208228

229+
+
209230
----
210231
kubectl label secret jvm-build-service-upload spi.appstudio.redhat.com/upload-secret=token
211232
----
212233

213-
Once these steps are completed the secret should disappear, and the system is ready to use.
234+
After you complete these steps, the secret should disappear, and the system is ready to use.
214235

215-
== Examining the System State
236+
== Examining the system state
216237

217238
After you have run your first java build with rebuilds enabled you can use `kubectl` to view the state of the rebuilds.
218239

@@ -245,7 +266,7 @@ NAME URL
245266

246267
The names of the `PipelineRun` objects begin with the build name. This enables you to view logs for each `PipelineRun`.
247268

248-
=== Re-Running Builds [[rebuilding_artifacts]]
269+
=== Rerunning builds [[rebuilding_artifacts]]
249270

250271
To rebuild an artifact, you need to annotate the `ArtifactBuild` object with `jvmbuildservice.io/rebuild=true`. For example, to rebuild the `zookeeper.3.6.3-8fc126b0` `ArtifactBuild`, you would run:
251272

@@ -263,7 +284,7 @@ kubectl annotate artifactbuild --all jvmbuildservice.io/rebuild=failed
263284

264285
Generally, when you are trying to fix a failure, you must manually run the builds yourself.
265286

266-
== Dealing With failed Builds
287+
== Dealing wth failed builds
267288

268289
In order to see why the build failed, look at the results from the JVM Build Service.
269290

@@ -377,12 +398,9 @@ To fix failed builds, first look at the build logs and figure out why it failed.
377398
*Procedure*
378399

379400
. Identify the correct `DependencyBuild` object.
380-
381401
. Run `kubectl get dependencybuilds` to list the objects.
382-
383402
. Pick the object you are interested in. Generally each `DependencyBuild` will have multiple pipeline
384403
runs, named using the pattern `<dependency-build-name>-build-<n>`.
385-
386404
. View the logs by using the command `tkn pr logs <name>`:
387405

388406
[source]
@@ -400,9 +418,7 @@ If there are no builds at all, then the analyser could not find a build file to
400418
*Procedure*
401419

402420
. Create a fork of the repository.
403-
404421
. Change the build system to Maven.
405-
406422
. Build from the fork.
407423

408424
To see an example, go to https://github.com/jvm-build-service-code/cs-au-dk-dk.brics.automaton[this Java package project] on GitHub.
@@ -464,7 +480,6 @@ which allows the namespace administrator to control where dependencies come from
464480
.*Procedure*
465481

466482
. Browse to an appropriate directory and create a file, for example, `config.yaml`.
467-
468483
. In the `config.yaml` file, create a *ConfigMap* resource with the following data:
469484

470485
+
@@ -483,7 +498,7 @@ spec:
483498
----
484499
<1> To add a maven repository the key in the map must follow a set pattern, which is, maven-repository-$priority-$name: $repo-url. Additionally, Maven central has a priority of 200; therefore the system tries anything with a lower priority before maven central. The rebuilt artifacts if they are in use have a priority of 100.
485500

486-
=== Clearing the Cache
501+
=== Clearing the cache
487502

488503
If for some reason you need to clear the cache you can do it by applying an annotation to the `JBSConfig` object:
489504

0 commit comments

Comments
 (0)