Skip to content

Commit 6b93380

Browse files
committed
fix mistake with dockerregistry configuration
1 parent a3ce9bb commit 6b93380

File tree

2 files changed

+78
-68
lines changed

2 files changed

+78
-68
lines changed

docs/jenkinsx/lighthouse-bitbucket.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ See the docs for all the possible values[^5].
106106
* **gitKind: bitbucketserver**: the `kind` of git server, in this case `bitbucketserver`, because `bitbucket` refers to [Bitbucket Cloud](https://bitbucket.org/)
107107
* **gitName: bs**: the name for our gitserver configuration
108108
* **gitServer: http://bitbucket.openshift.example.com**: the url to our Bitbucket Server
109+
* **registry: docker.io**: when not using a Public Cloud provider, you have to specify the docker registry URL, in this case, Dockerhub (which is `docker.io`)
110+
* **dockerRegistryOrg: caladreas**: when the docker registry owner - in my case, `caladreas`- is different from the git repository owner, you have to specify this via `dockerRegistryOrg`
109111

110112
We also have to set the storage for at least the logs.
111113
If we do not configure the storage for our logs, they will be assumed to be written to github pages of our application.
@@ -141,6 +143,7 @@ jx edit storage -c logs --git-url http://bitbucket.openshift.kearos.net/scm/jx/b
141143
namespace: jx
142144
provider: kubernetes
143145
registry: docker.io
146+
dockerRegistryOrg: caladreas
144147
environments:
145148
- ingress:
146149
domain: openshift.example.com

docs/jenkinsx/rhos-311-minimal.md

Lines changed: 75 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ The current (as of March 2020) recommended way of installing Jenkins X, is via [
8686

8787
* **provider: kubernetes**: Normally, this is set to your cloud provider. in order to stay close to Kubernetes itself and thus OpenShift, we set this to `kubernetes`
8888
* **registry: docker.io**: If you're on a public cloud vender, `jx boot` creates a docker registry for you (GCR on GCP, ACR on AWS, and so on), in this example we leverage Docker Hub (`docker.io`). This should be indicative for any self-hosted registry as well!
89+
* **dockerRegistryOrg: caladreas**: when the docker registry owner - in my case, `caladreas`- is different from the git repository owner, you have to specify this via `dockerRegistryOrg`
8990
* **secretStorage: local**: Thre recommended approach is to use the HashiCorp Vault integration, but that isn't supported on OpenShift
9091
* **webhook: prow**: This uses Prow for webhook management. In March 2020 the best option to use with GitHub. If you want to use Bitbucket [read my guide on jx with lighthouse & bitbucket](/jenkinsx/lighthouse-bitbucket/).
9192

93+
9294
??? example "jx-requirements.yaml"
9395

9496
```yaml
@@ -104,6 +106,7 @@ The current (as of March 2020) recommended way of installing Jenkins X, is via [
104106
namespace: jx
105107
provider: kubernetes
106108
registry: docker.io
109+
dockerRegistryOrg: caladreas
107110
environments:
108111
- ingress:
109112
domain: openshift.kearos.net
@@ -235,9 +238,8 @@ jx create quickstart --filter golang-http --project-name jx-go-rhos311 --batch-m
235238

236239
This creates a new repository based on the quickstart for Go (lang)[^4] and the build pack for Go (lang)[^5].
237240

238-
I ran into three issues:
241+
I ran into two issues:
239242

240-
1. Jenkins X buildpack expects, that the Docker registry owner is the same as the Git repository owner
241243
1. Tekton is not mounting my Docker registry credentials, thus the Kaniko build fails with `401: not authenticated`
242244
1. the expose controller[^6] is using Ingress resources by default, but doesn't want to create those on OpenShift[^7]
243245

@@ -255,72 +257,6 @@ APPLICATION STAGING PODS URL
255257
jx-go 0.0.1 1/1 http://jx-go-jx-staging.staging.openshift.example.com
256258
```
257259

258-
### Registry Owner Mismatch
259-
260-
In order to resolve the mismatch between the Docker registry owner and the Git repository owner, we need to change two things in our Jenkins X pipeline (`jenkins-x.yml`)[^8].
261-
262-
1. add an override for the Docker registry owner in the `jenkins-x.yml`, the pipeline of your application.
263-
1. add an override for the `container-build` step of the `build` stage, for both the `release` and `pullrequest` pipelines.
264-
265-
Overriding the pipeline is done by specifying the stage to override under `pipelineConfig.overides`[^8][^9].
266-
267-
When you set `dockerRegistryOwner`, it overrides the value generated elsewhere.
268-
269-
```yaml
270-
dockerRegistryOwner: caladreas
271-
```
272-
273-
The only exception is where the image gets uploaded to via `Kaniko`.
274-
275-
```yaml
276-
- --destination=docker.io/caladreas/jx-go-rhos311-1:${inputs.params.version}
277-
```
278-
279-
The end result will look like this.
280-
281-
!!! example "jenkins-x.yml"
282-
283-
```yaml
284-
dockerRegistryOwner: caladreas
285-
buildPack: go
286-
pipelineConfig:
287-
overrides:
288-
- pipeline: release
289-
stage: build
290-
name: container-build
291-
steps:
292-
- name: container-build
293-
dir: /workspace/source
294-
image: gcr.io/kaniko-project/executor:9912ccbf8d22bbafbf971124600fbb0b13b9cbd6
295-
command: /kaniko/executor
296-
args:
297-
- --cache=true
298-
- --cache-dir=/workspace
299-
- --context=/workspace/source
300-
- --dockerfile=/workspace/source/Dockerfile
301-
- --destination=docker.io/caladreas/jx-go-rhos311-1:${inputs.params.version}
302-
- --cache-repo=docker.io/todo/cache
303-
- --skip-tls-verify-registry=docker.io
304-
- --verbosity=debug
305-
- pipeline: pullrequest
306-
stage: build
307-
name: container-build
308-
steps:
309-
- name: container-build
310-
dir: /workspace/source
311-
image: gcr.io/kaniko-project/executor:9912ccbf8d22bbafbf971124600fbb0b13b9cbd6
312-
command: /kaniko/executor
313-
args:
314-
- --cache=true
315-
- --cache-dir=/workspace
316-
- --context=/workspace/source
317-
- --dockerfile=/workspace/source/Dockerfile
318-
- --destination=docker.io/caladreas/jx-go-rhos311-1:${inputs.params.version}
319-
- --cache-repo=docker.io/todo/cache
320-
- --skip-tls-verify-registry=docker.io
321-
- --verbosity=debug
322-
```
323-
324260
### Missing Docker Credentials
325261

326262
I used Docker hub as my Docker registry, but this applies to any other self-hosted Docker registry.
@@ -471,6 +407,77 @@ PULL REQUEST NAMESPACE APPLICAT
471407
https://bitbucket.openshift.kearos.net/jx/jx-go/pull/1 jx-jx-jx-go-pr-1 http://jx-go.jx-jx-jx-go-pr-1.openshift.example.com
472408
```
473409

410+
## Errata
411+
412+
### Registry Owner Mismatch
413+
414+
It can happen that the docker registry owner is not the same for every application. If this is the case, the application will have to make a workaround after it is imported into Jenkins X (via `jx import` or `jx create quickstart`).
415+
416+
In order to resolve the mismatch between the default Jenkins X installation Docker registry owner and the application's owner, we need to change two things in our Jenkins X pipeline (`jenkins-x.yml`)[^8].
417+
418+
1. add an override for the Docker registry owner in the `jenkins-x.yml`, the pipeline of your application.
419+
1. add an override for the `container-build` step of the `build` stage, for both the `release` and `pullrequest` pipelines.
420+
421+
Overriding the pipeline is done by specifying the stage to override under `pipelineConfig.overides`[^8][^9].
422+
423+
When you set `dockerRegistryOwner`, it overrides the value generated elsewhere.
424+
425+
```yaml
426+
dockerRegistryOwner: caladreas
427+
```
428+
429+
The only exception is where the image gets uploaded to via `Kaniko`.
430+
431+
```yaml
432+
- --destination=docker.io/caladreas/jx-go-rhos311-1:${inputs.params.version}
433+
```
434+
435+
The end result will look like this.
436+
437+
!!! example "jenkins-x.yml"
438+
439+
```yaml
440+
dockerRegistryOwner: caladreas
441+
buildPack: go
442+
pipelineConfig:
443+
overrides:
444+
- pipeline: release
445+
stage: build
446+
name: container-build
447+
steps:
448+
- name: container-build
449+
dir: /workspace/source
450+
image: gcr.io/kaniko-project/executor:9912ccbf8d22bbafbf971124600fbb0b13b9cbd6
451+
command: /kaniko/executor
452+
args:
453+
- --cache=true
454+
- --cache-dir=/workspace
455+
- --context=/workspace/source
456+
- --dockerfile=/workspace/source/Dockerfile
457+
- --destination=docker.io/caladreas/jx-go-rhos311-1:${inputs.params.version}
458+
- --cache-repo=docker.io/todo/cache
459+
- --skip-tls-verify-registry=docker.io
460+
- --verbosity=debug
461+
- pipeline: pullrequest
462+
stage: build
463+
name: container-build
464+
steps:
465+
- name: container-build
466+
dir: /workspace/source
467+
image: gcr.io/kaniko-project/executor:9912ccbf8d22bbafbf971124600fbb0b13b9cbd6
468+
command: /kaniko/executor
469+
args:
470+
- --cache=true
471+
- --cache-dir=/workspace
472+
- --context=/workspace/source
473+
- --dockerfile=/workspace/source/Dockerfile
474+
- --destination=docker.io/caladreas/jx-go-rhos311-1:${inputs.params.version}
475+
- --cache-repo=docker.io/todo/cache
476+
- --skip-tls-verify-registry=docker.io
477+
- --verbosity=debug
478+
```
479+
480+
474481
## References
475482

476483
[^1]: https://kubernetes.io/docs/concepts/storage/volumes/#emptydir

0 commit comments

Comments
 (0)