Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry is not setup in oc:build #1537

Closed
luidoc opened this issue Jun 6, 2022 · 4 comments · Fixed by #1648
Closed

Registry is not setup in oc:build #1537

luidoc opened this issue Jun 6, 2022 · 4 comments · Fixed by #1648
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation
Milestone

Comments

@luidoc
Copy link

luidoc commented Jun 6, 2022

Description
When using external registry in oc:build, in the push phase it fails.
My pom:

.....
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
	            <groupId>org.eclipse.jkube</groupId>
	            <artifactId>openshift-maven-plugin</artifactId>
	            <version>1.8.0</version>
                <configuration>
                    <images>
                        <image>
                            <registry>harbor.xyz.local</registry>
                            <name>luis/myapp:0.0.1</name>
                            <build>
                                <from>${application.runtime.image}</from>
                                <assembly>
.....

And executing mvn clean package oc:resource oc:build -DskipTests :

....
[INFO] oc: Getting image source signatures
[INFO] oc: Copying blob sha256:dff9f8de74c048baca326e1d79db28e7615e8e96497c630177c53e61bbd2f906
[INFO] oc: Copying blob sha256:e34e3bdec2768c1b351fdcc47094e9e345a7e1c2115d667549e76a02ed282d3c
[INFO] oc: Copying blob sha256:c971a8c0a1b199299576af478d1766c8b8e91a15cc1852bdb99df4bb8ed3bedb
[INFO] oc: Copying blob sha256:c2471240f28cd9479bc869dfce3c5f3324bb0b711e6593389ce79dc70823d29f
[INFO] oc: Copying config sha256:b1db12c62076cbee16adaab139179bd11efa87b271f9f628efee84c409c60d24
[INFO] oc: Writing manifest to image destination
[INFO] oc: Storing signatures
[INFO] oc: --> b1db12c6207
[INFO] oc: Successfully tagged temp.builder.openshift.io/default/myapp-s2i-1:f3d2dbef
[INFO] oc: b1db12c62076cbee16adaab139179bd11efa87b271f9f628efee84c409c60d24
[INFO] oc:
[INFO] oc: Pushing image luis/myapp:0.0.1 ...
[INFO] oc: Getting image source signatures
[INFO] oc: Warning: Push failed, retrying in 5s ...
....

If I include the name of the registry in the name of the image, it works correctly.

.....
      <build>
           <plugins>
              <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
	      </plugin>
	      <plugin>
	             <groupId>org.eclipse.jkube</groupId>
	             <artifactId>openshift-maven-plugin</artifactId>
	             <version>1.8.0</version>
                     <configuration>
                        <images>
                           <image>
                              <name>harbor.xyz.local/luis/myapp:0.0.1</name>
                                <build>
                                     <from>${application.runtime.image}</from>
                                     <assembly>
.....

[INFO] oc: Getting image source signatures
[INFO] oc: Copying blob sha256:dff9f8de74c048baca326e1d79db28e7615e8e96497c630177c53e61bbd2f906
[INFO] oc: Copying blob sha256:e34e3bdec2768c1b351fdcc47094e9e345a7e1c2115d667549e76a02ed282d3c
[INFO] oc: Copying blob sha256:c971a8c0a1b199299576af478d1766c8b8e91a15cc1852bdb99df4bb8ed3bedb
[INFO] oc: Copying blob sha256:b587f03e7d96e1a4546612c109586ba9017877afc602491d57dd26513da71979
[INFO] oc: Copying config sha256:f2f5383ee336ff68ec77d98532a3fdc1e6cfea2de7716d2782fc81876fe814e5
[INFO] oc: Writing manifest to image destination
[INFO] oc: Storing signatures
[INFO] oc: --> f2f5383ee33
[INFO] oc: Successfully tagged temp.builder.openshift.io/default/myapp-s2i-1:4ae7441f
[INFO] oc: f2f5383ee336ff68ec77d98532a3fdc1e6cfea2de7716d2782fc81876fe814e5
[INFO] oc:
[INFO] oc: Pushing image harbor.xyz.local/luis/myapp:0.0.1 ...
[INFO] oc: Getting image source signatures
[INFO] oc: Copying blob sha256:4752687a61a97d6f352ae62c381c87564bcb2f5b6523a05510ca1fb60d640216
[INFO] oc: Copying blob sha256:b587f03e7d96e1a4546612c109586ba9017877afc602491d57dd26513da71979
[INFO] oc: Copying blob sha256:4d750aed4cb7494f8538216f6084a57d3d1c35d58fdc0bf6f85974f064326905
[INFO] oc: Copying blob sha256:0344366a246a0f7590c2bae4536c01f15f20c6d802b4654ce96ac81047bc23f3
[INFO] oc: Copying config sha256:f2f5383ee336ff68ec77d98532a3fdc1e6cfea2de7716d2782fc81876fe814e5
[INFO] oc: Writing manifest to image destination
[INFO] oc: Storing signatures
[INFO] oc: Successfully pushed harbor.xyz.local/luis/myapp@sha256:0c20db2f81c955ade15382b6279385e7acf076017ead8f5517f587c9043748eb
[INFO] oc: Push successful

The documentation clearly indicates that an external registry can be specified: https://www.eclipse.org/jkube/docs/openshift-maven-plugin#registry

_If an image name doesn’t contain a registry, then by default the default Docker registry docker.io is used for push and pull operations. But this can be overwritten through various means:

If the configuration contains a subelement this registry is used.

Otherwise, a global configuration element is evaluated which can be also provided as system property via -Djkube.docker.registry._

Executing mvn clean package oc:resource oc:build -DskipTests -Djkube.docker.registry=harbor.xyz.local doesn't work either

Info
Eclipse JKube version : 1.8.0

Maven version (mvn -v) : Apache Maven 3.8.5

Red Hat OpenShift setup and version : 4.10.13

@sunix
Copy link
Member

sunix commented Jun 27, 2022

OK @luidoc thanks for submitting this. We will investigate that problem.
@rohanKanojia @manusa For me, the behaviour works well with the kubernetes-maven-plugin but maybe it is not clear how it should work with the openshift-mavent-plugin and the s2i strategy.

@sunix sunix added bug Something isn't working documentation Improvements or additions to documentation labels Jun 27, 2022
@rohanKanojia
Copy link
Member

@luidoc : Thanks for reporting, I can reproduce this issue.

You're right we don't seem to be considering registry provided in ImageConfiguration while doing S2I builds. We need to add logic here to append configured registry to applicableImageConfig here:

https://github.com/eclipse/jkube/blob/594d29d641ec1f3fc9780da092adb50e65418a95/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildService.java#L136

Somewhat similar to what's done here:

https://github.com/eclipse/jkube/blob/594d29d641ec1f3fc9780da092adb50e65418a95/jkube-kit/build/service/docker/src/main/java/org/eclipse/jkube/kit/build/service/docker/RegistryService.java#L59-L62

@manusa
Copy link
Member

manusa commented Jul 12, 2022

For completeness:

When using the OpenShift Maven/Gradle Plugin the push is performed from the cluster, so you need to use follow the process described in the following video: https://www.youtube.com/watch?v=zAIARZ-efxk&t=36s

Currently, our documentation for this is very poor in this aspect and should be improved.

Hi @luidoc could you provide a little more context about your scenario and current workflow. For Example: I'm running this pipeline in a private OpenShift cluster and pushing my image to a private registry accessible by this cluster. This cluster won't allow using its internal registry for image publication...

@luidoc
Copy link
Author

luidoc commented Jul 12, 2022

I'm running this pipeline from a jenkins job, in a private OpenShift cluster and i need to push my image to a harbor private registry accessible by this cluster. There is a secret in the project that allows you to push to my private harbor. This cluster won't allow using its internal registry for image publication, and i also don't want my images to be saved in openshift's private registry.

@manusa manusa added this to the 1.9.0 milestone Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
4 participants