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

Commit 87b1d44

Browse files
authored
Merge pull request #98 from stuartwdouglas/jvm-build-service-spi
feat: Change docs to use SPI
2 parents e608b4a + 98ad345 commit 87b1d44

File tree

1 file changed

+79
-6
lines changed

1 file changed

+79
-6
lines changed

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

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ The JVM build service addressed this concern by allowing you to rebuild your app
2626

2727
.*Procedure*
2828

29-
. Configure the secret that is used to authenticate against the image registry. This is a standard `kubernetes.io/dockerconfigjson` secret that holds a `.dockerconfigjson` secret key. The easiest way to create this is to log into the image registry with `docker login`, and then run: `kubectl create secret generic jvm-build-image-secrets --from-file=.dockerconfigjson=$HOME/.docker/config.json --type=kubernetes.io/dockerconfigjson`.
30-
+
31-
WARNING: This command includes all your docker logins, therefore, before running it, make sure that the `config.json` only contains information for the relevant repository. A good way to do this is to temporarily move your existing file somewhere else, do a `docker login`, create the secret, then move the old file back.
32-
3329
. Create a file, for example, `config.yaml`.
3430

3531
. In the `config.yaml` file, create a *JBSConfig* resource with the following data:
@@ -47,7 +43,7 @@ spec:
4743
owner: OrgID <3>
4844
repository: artifact-deployments <4>
4945
mavenBaseLocations:
50-
maven-repository-300-jboss: "https://repository.jboss.org/nexus/content/groups/public/"
46+
maven-repository-300-jboss: "https://repository.jboss.org/nexus/content/groups/public/" <5>
5147
maven-repository-301-gradleplugins: "https://plugins.gradle.org/m2"
5248
maven-repository-302-confluent: "https://packages.confluent.io/maven"
5349
@@ -56,9 +52,86 @@ spec:
5652
<2> The URL of the registry that holds the images of your rebuild dependencies.
5753
<3> The organization ID.
5854
<4> The repository to store the images in.
55+
<5> List any additional Maven repositories here.
5956

6057
. Run `kubectl apply -f config.yaml` while logged into the build namespace.
6158

59+
Now we have added the configuration we need to setup the Quay.io credentials to be able to push to our repository. The JVM
60+
Build Service uses the https://github.com/redhat-appstudio/service-provider-integration-operator[Service Provider Integration Operator] to store credentials in AWS Secrets Manager.
61+
62+
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
63+
run the following command:
64+
65+
----
66+
kubectl get spiaccesstokenbindings.appstudio.redhat.com jvm-build-image-secrets -o yaml`
67+
----
68+
69+
The output should look something like this:
70+
[source,yaml]
71+
----
72+
apiVersion: appstudio.redhat.com/v1beta1
73+
kind: SPIAccessTokenBinding
74+
metadata:
75+
creationTimestamp: "2023-05-11T00:23:00Z"
76+
finalizers:
77+
- spi.appstudio.redhat.com/linked-objects
78+
generation: 1
79+
labels:
80+
spi.appstudio.redhat.com/linked-access-token: generated-spi-access-token-px5w8
81+
name: jvm-build-image-secrets
82+
namespace: sdouglas1-tenant
83+
ownerReferences:
84+
- apiVersion: jvmbuildservice.io/v1alpha1
85+
kind: JBSConfig
86+
name: jvm-build-config
87+
uid: b0210099-d116-4742-9cff-a521e9bbe61b
88+
resourceVersion: "287987482"
89+
uid: 2763469b-9340-4a83-8489-a283f3505c5d
90+
spec:
91+
lifetime: "-1"
92+
permissions:
93+
required:
94+
- area: registry
95+
type: rw
96+
repoUrl: https://quay.io/sdouglas/artifact-deployments
97+
secret:
98+
fields: {}
99+
name: jvm-build-image-secrets
100+
type: kubernetes.io/dockerconfigjson
101+
status:
102+
linkedAccessTokenName: generated-spi-access-token-px5w8 <1>
103+
phase: Injected
104+
syncedObjectRef:
105+
apiVersion: v1
106+
kind: Secret
107+
name: jvm-build-image-secrets
108+
uploadUrl: https://spi-oauth-spi-system.apps.stone-prd-m01.84db.p1.openshiftapps.com/token/sdouglas1-tenant/generated-spi-access-token-px5w8
109+
----
110+
<1> This is the name of the APIAccessToken we need to upload the secret
111+
112+
Record the name of the `linkedAccessTokenName` (in this case `generated-spi-access-token-px5w8`), this
113+
will be referred to as $ACCESS_TOKEN in the examples below.
114+
115+
Now we need to create a secret with specific config that will be uploaded to AWS Secrets Manager.
116+
117+
For the next step we need a quay.io username and password. The best way to get these is to log in
118+
and create a robot account, and record the username and password after account creation. For the purposes
119+
of the examples below these will be referred to as $QUAY_USERNAME and $QUAY_PASSWORD.
120+
121+
Create a secret with the following command:
122+
123+
----
124+
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
125+
----
126+
127+
Then we need to add a special label to the secret so that the SPI knows to store it in AWS Secrets Manager:
128+
129+
----
130+
kubectl label secret jvm-build-service-upload spi.appstudio.redhat.com/upload-secret=token
131+
----
132+
133+
Once these steps are completed the secret should disappear, and the system is ready to use.
134+
62135
=== Examining the System State
63136

64137
After you have run your first java build with rebuilds enabled you can use `kubectl` to view the state of the rebuilds.
@@ -344,4 +417,4 @@ For more information, see:
344417

345418
* xref:concepts/java-build-service/java-build-service.adoc[Java build service].
346419

347-
* xref:concepts/java-build-service/java-build-service-components.adoc[Java build service components]
420+
* xref:concepts/java-build-service/java-build-service-components.adoc[Java build service components]

0 commit comments

Comments
 (0)