fabric8:build and fabric8:push in openShift ?

466 views
Skip to first unread message

Torsten Reinhard

unread,
Mar 27, 2020, 7:45:44 AM3/27/20
to fabric8
Hi,

I´m starting to setup my Maven Build with the fabric8-maven-plugin.
The build of my resulting Docker Image is already working, the configuration looks like:

            <plugin>
               
<artifactId>fabric8-maven-plugin</artifactId>
               
<version>4.5-SNAPSHOT</version>
               
<configuration>
                   
<skipBuildPom>false</skipBuildPom>
                   
<skip>false</skip>
                   
<buildStrategy>docker</buildStrategy>
                   
<mode>openshift</mode>
                   
<verbose>true</verbose>
                   
<autoPull>always</autoPull>
                   
<retries>10</retries>
                   
<!-- need to configure that, the auto-detect gave the wrong IP:port - and we have self-signed certs...-->
                   
<access>
                       
<masterUrl>https://oc-cluster.mycompany.net:8443</masterUrl>
                       
<caCertFile>${project.basedir}/mycompany-ca.pem</caCertFile>
                   
</access>
                   
                   
<pullRegistry>pull-ci.mycompany.net</pullRegistry>
                   
<images>
                       
<image>
                           
<name>tam-ci/demo-app-image:%v</name>
                           
<build>
                               
<dockerFile>Dockerfile</dockerFile>
                               
<filter>@</filter>
..
                           
</build>
                       
</image>
                   
</images>
               
</configuration>
               
<executions>
                   
<execution>
                       
<id>build-image</id>
                       
<goals>
                           
<goal>build</goal>
                       
</goals>
                       
<phase>package</phase>
                   
</execution>
                   
<execution>
                       
<id>deploy-image</id>
                       
<goals>
                             
<goal>push</goal>
                       
</goals>
                       
<phase>package</phase>
                       
<configuration>
                           
<pushRegistry>push-tam-ci.bmwgroup.net</pushRegistry>
                           
<mode>kubernetes</mode>
                       
</configuration>
                   
</execution>
                   
               
</executions>
           
</plugin>            



After login and starting the build

oc login https://oc-cluster.mycompany.net
mvnw clean install

it ends up with an image deployed to the openshift internal Registry.

Now: How can I push this image afterwards to an external Registry (Nexus) ?

I wanted to achieve this with fabric8:push - but couldn´t get it working.
I´m getting:

[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:4.5-SNAPSHOT:push (default-cli) on project demo-app-image:
Execution default-cli of goal io.fabric8:fabric8-maven-plugin:4.5-SNAPSHOT:push failed: Service hub created without a docker access to a docker daemon -> [Help 1]
[ERROR]


When looking into the code, I saw that the "pushRegistry" (docker.push.registry) is only considered when the plugin is in "Jib" Mode.

When building the image already inside openshift (and not locally) - does it make sense at all to separate the build and push goals?

Thanx for any answers or an working example

Thanx, Torsten

Rohan Kumar

unread,
Mar 27, 2020, 11:46:02 AM3/27/20
to Torsten Reinhard, fabric8
Hi Tosten,

I was able to reproduce your issue. I think it might be a regression because of changes introduced with JIB support. I can reproduce your issue with 4.5-SNAPSHOT but not with 4.3.1. Could you please roll back to 4.3.1 and see if the issue gets resolved or not?

Also, Could you please file a bug on our repository? We will prioritize this and fix this in the coming sprint.

शुक्र, 27 मार्च 2020 को 5:15 pm बजे को Torsten Reinhard <tosc...@gmail.com> ने लिखा:
--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fabric8/c75bf6e2-6806-4728-81d1-1b484d964018%40googlegroups.com.


--
---
Rohan Kumar roh...@redhat.com
IRC:  Rohaan

Torsten Reinhard

unread,
Mar 30, 2020, 4:15:36 AM3/30/20
to fabric8
Hi, 

as recommended, I switched back to 4.3.1, but when
running the Maven build on Jenkins (executed on a slave running in openShift)
I still see
22:39:53 [ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:4.3.1:push (build-image) on project demo-app-image: Execution build-image of goal io.fabric8:fabric8-maven-plugin:4.3.1:push failed: No <dockerHost> given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured -> [Help 1]


When executed locally ($ mvn clean install) I get

[INFO] F8: Successfully built 42dc2e6f2834
[INFO] F8:
[INFO] F8: Pushing image docker-registry.default.svc:5000/tam-ci/demo-app-image:1.0.0-SNAPSHOT ...
[INFO] F8: Pushed 8/8 layers, 100% complete
...
[INFO] F8: ImageStream demo-app-image written to D:\Projekte\TAM\demo-app\demo-app-image\target\demo-app-image-is.yml
[INFO]
[INFO] --- fabric8-maven-plugin:4.3.1:push (build-image) @ demo-app-image ---
[INFO] F8> Generators:
[INFO] F8>  - quarkus
...
[INFO] F8>  - webapp
[DEBUG] F8> REQUEST GET /version HTTP/1.1
Accept: */*
Content-Type: application/json
Host: 127.0.0.1:1
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_202)
Accept-Encoding: gzip,deflate

[DEBUG] F8> RESPONSE HTTP/1.1 200 OK
Api-Version: 1.39
Content-Length: 560
Content-Type: application/json
Date: Mon, 30 Mar 2020 08:01:39 GMT
Docker-Experimental: false
Ostype: linux
Server: Docker/18.09.2 (linux)

[INFO] F8> Credentials helper reply for "docker-credential-wincred" is 0.6.0
[DEBUG] F8> AuthConfig: credentials from credential helper/store docker-credential-wincred version 0.6.0
[DEBUG] F8> AuthConfig: credentials from ~/.docker/config.json
[DEBUG] F8> REQUEST GET /v1.39/images/push-tam-ci.mycompany.net%2Ftam-ci%2Fdemo-app-image%3A1.0.0-SNAPSHOT/json HTTP/1.1
Accept: */
*
Content-Type: application/json
Host: 127.0.0.1:1
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_202)
Accept-Encoding: gzip,deflate

[DEBUG] F8> RESPONSE HTTP/1.1 404 Not Found
Api-Version: 1.39
Content-Length: 169
Content-Type: application/json
Date: Mon, 30 Mar 2020 08:01:39 GMT
Docker-Experimental: false
Ostype: linux
Server: Docker/18.09.2 (linux)

[DEBUG] F8> RESPONSE {"message":"no such image: push-tam-ci.mycompany.net/tam-ci/demo-app-image:1.0.0-SNAPSHOT: No such image: push-tam-ci.mycompany.net/tam-ci/demo-app-image:1.0.0-SNAPSHOT"}
linux
Server: Docker/18.09.2 (linux)

[DEBUG] F8> REQUEST POST /v1.39/images/tam-ci%2Fdemo-app-image%3A1.0.0-SNAPSHOT/tag?force=0&repo=push-tam-ci.mycompany.net%2Ftam-ci%2Fdemo-app-image&tag=1.0.0-SNAPSHOT HTTP/1.1
Accept: */*
Content-Type: application/json
Content-Length: 0
Host: 127.0.0.1:1
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_202)
Accept-Encoding: gzip,deflate

[DEBUG] F8> RESPONSE HTTP/1.1 404 Not Found
Api-Version: 1.39
Content-Length: 66
Content-Type: application/json
Date: Mon, 30 Mar 2020 08:01:39 GMT
Docker-Experimental: false
Ostype: linux
Server: Docker/18.09.2 (linux)

[DEBUG] F8> RESPONSE {"message":"No such image: tam-ci/demo-app-image:1.0.0-SNAPSHOT"}
tent-Type: application/json
Date: Mon, 30 Mar 2020 08:01:39 GMT
Docker-Experimental: false
Ostype: linux
Server: Docker/18.09.2 (linux)

[ERROR] F8> Unable to add tag [push-tam-ci.mycompany.net/tam-ci/demo-app-image:1.0.0-SNAPSHOT] to image [tam-ci/demo-app-image:1.0.0-SNAPSHOT] : {"message":"No such image: tam-ci/demo-app-image:1.0.0-SNAPSHOT"} (Not Found: 404) [{"message":"No such image: tam-ci/demo-app-image:1.0.0-SNAPSHOT"} (Not Found: 404)]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:36 min
[INFO] Finished at: 2020-03-30T10:01:40+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:4.3.1:push (build-image) on project demo-app-image: Unable to add tag [push-tam-ci.mycompany.net/tam-ci/demo-app-image:1.0.0-SNAPSHOT] to image [tam-ci/demo-app-image:1.0.0-SNAPSHOT] : {"message":"No such image: tam-ci/demo-app-image:1.0.0-SNAPSHOT"} (Not Found: 404) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

What´s missing?
Do I need to set "useOpenShiftAuth" in the <authConfig> like mentioned somewhere in the documentation?
Do I need to add something locally to my ~/.m2/settings?

My expectation is that pushing the image will happen in openShift (where the build was executed and pushed to the internal registry). is that right?

thanx for any help, I really need to get this running soon - but it looks lke it´s far away from "zero-config".

Best regards,
Torsten

Torsten Reinhard

unread,
Mar 30, 2020, 4:28:13 AM3/30/20
to fabric8
Reply all
Reply to author
Forward
0 new messages