【问题标题】:Openshift : Fabric deployment fails with while building imageOpenshift:构建映像时,Fabric 部署失败
【发布时间】:2018-05-15 09:27:36
【问题描述】:

我正在尝试使用 Fabric8 Maven 插件部署示例项目。 https://github.com/jbossdemocentral/katacoda-fuse-getting-started.git

我在远程机器上有一个启动并正在运行的 Openshift 环境,我正在使用“oc login .....”连接到它

本地开发机器设置:有 docker、maven。 oc 已安装。

  OS: Mac OS
  > docker version
  Client:
  Version:      1.11.2
  API version:  1.23
  Go version:   go1.5.4
  Git commit:   b9f10c9
  Built:        Wed Jun  1 21:20:08 2016
  OS/Arch:      darwin/amd64

 Server:
 Version:      18.05.0-ce
 API version:  1.37
 Go version:   go1.10.1
 Git commit:   f150324
 Built:        Wed May  9 22:20:42 2018
 OS/Arch:      linux/amd64

>> oc version
oc v3.9.25
kubernetes v1.9.1+a0ce1bc657

当我从命令提示符运行示例项目“mvn fabric8:deploy”时,构建失败并显示

Error Logs:


      [DEBUG] Trying to configure client from Kubernetes config...
      [DEBUG] Found for Kubernetes config at: [/Users/apiteam/.kube/config].
      [WARNING] F8: Cannot access cluster for detecting mode: Unknown host placholder.openshiftenv.com
     [INFO] F8: Building Docker image in Kubernetes mode
     [INFO] F8: spring-boot: Using fat jar packaging as the spring boot plugin is using `repackage` goal execution
     [INFO] F8: Running generator spring-boot
     [INFO] F8: spring-boot: Using Docker image jboss-fuse-6/fis-java-openshift:2.0 as base / builder
     [ERROR] F8: I/O Error executing build for image [fuse/fuse-camel-sb-rest:snapshot-180515-144114-0343] "spring-boot":io.fabric8.maven.docker.access.DockerAccessException: Unable to pull 'jboss-fuse-6/fis-java-openshift:2.0'
     [INFO] ------------------------------------------------------------------------
     [INFO] BUILD FAILURE
     [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 01:22 min
      [INFO] Finished at: 2018-05-15T14:42:21+05:30
      [INFO] Final Memory: 52M/400M
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:3.1.80.redhat-000010:build (default) on project fuse-camel-sb-rest: I/O Error executing build for image [fuse/fuse-camel-sb-rest:snapshot-180515-144114-0343] "spring-boot":io.fabric8.maven.docker.access.DockerAccessException: Unable to pull 'jboss-fuse-6/fis-java-openshift:2.0': Get https://registry-1.docker.io/v2/jboss-fuse-6/fis-java-openshift/manifests/2.0: Get https://auth.docker.io/token?scope=repository%3Ajboss-fuse-6%2Ffis-java-openshift%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) (Internal Server Error: 500) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:fabric8-maven-plugin:3.1.80.redhat-000010:build (default) on project fuse-camel-sb-rest: I/O Error executing build for image [fuse/fuse-camel-sb-rest:snapshot-180515-144114-0343] "spring-boot":io.fabric8.maven.docker.access.DockerAccessException: Unable to pull 'jboss-fuse-6/fis-java-openshift:2.0'
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:352)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:197)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: I/O Error executing build for image [fuse/fuse-camel-sb-rest:snapshot-180515-144114-0343] "spring-boot":io.fabric8.maven.docker.access.DockerAccessException: Unable to pull 'jboss-fuse-6/fis-java-openshift:2.0'
    at io.fabric8.maven.plugin.mojo.build.BuildMojo.buildAndTag(BuildMojo.java:242)
    at io.fabric8.maven.docker.BuildMojo.executeInternal(BuildMojo.java:47)
    at io.fabric8.maven.plugin.mojo.build.BuildMojo.executeInternal(BuildMojo.java:218)
    at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:193)
    at io.fabric8.maven.plugin.mojo.build.BuildMojo.execute(BuildMojo.java:201)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 24 more
Caused by: io.fabric8.maven.docker.access.DockerAccessException: Unable to pull 'jboss-fuse-6/fis-java-openshift:2.0'
    at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.pullImage(DockerAccessWithHcClient.java:369)
    at io.fabric8.maven.docker.AbstractDockerMojo.checkImageWithAutoPull(AbstractDockerMojo.java:439)
    at io.fabric8.maven.docker.AbstractBuildSupportMojo.autoPullBaseImage(AbstractBuildSupportMojo.java:110)
    at io.fabric8.maven.docker.AbstractBuildSupportMojo.buildImage(AbstractBuildSupportMojo.java:63)
    at io.fabric8.maven.docker.BuildMojo.buildAndTag(BuildMojo.java:56)
    at io.fabric8.maven.plugin.mojo.build.BuildMojo.buildAndTag(BuildMojo.java:235)
    ... 30 more
Caused by: io.fabric8.maven.docker.access.hc.http.HttpRequestException: Get https://registry-1.docker.io/v2/jboss-fuse-6/fis-java-openshift/manifests/2.0: Get https://auth.docker.io/token?scope=repository%3Ajboss-fuse-6%2Ffis-java-openshift%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) (Internal Server Error: 500)
    at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate$StatusCodeCheckerResponseHandler.handleResponse(ApacheHttpClientDelegate.java:177)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
    at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.post(ApacheHttpClientDelegate.java:97)
    at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.pullImage(DockerAccessWithHcClient.java:366)
    ... 35 more
[ERROR] 
[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

我按照 Redhat 站点中的说明使用 docker、oc 设置本地环境,并通过 oc login 从本地计算机访问 Openshift 环境。另外,我对远程运行的 openshift 环境了解不多,我只有 openshift 控制台和从本地机器连接的令牌。

所以,现在我的问题是

  1. 在本地机器上使用fabric8是否需要任何额外的设置?

  2. 如前所述,我不知道是否在 openshift 平台上安装了 fabric8。是否必须在 openshift 设置中使用 fabric8,或者 openshift 开箱即用。

  3. 我检查了 openshift 控制台,它有“jboss-fuse-6/fis-java-openshift:2.0”图像流。我是否需要获取 openshift 平台的 docker 内部存储库 url,是否需要在源代码中的某个地方进行配置?在日志“https://registry-1.docker.io/v2/jboss-fuse-6/fis-java-openshift/manifests/2.0”中,这是从哪里来的——我似乎在源代码中找不到这个配置。 fabric8 会自动连接到 openshift env 的内部 docker 注册表吗?

  4. 运行“mvn fabric8:deploy”时,我的理解是“项目在本地编译,本地docker连接到Openshift环境并拉取基础镜像(本例中为'jboss-fuse-6/fis -java-openshift:2.0') 到本地机器并构建最终映像并部署到 openshift 环境”。这是正确的还是 - 它是另一个,即 springboot jar,docker 图像是在 openshift 平台内构建并部署的?

  5. 我在 openshift 中的个人资料是否也需要访问内部 Openshift 注册表才能拉取 docker 映像?

有人可以澄清疑问并帮助解决问题吗?

【问题讨论】:

    标签: maven docker openshift fabric8 openshift-3


    【解决方案1】:
    1. 如果您使用 OpenShift 和 fabric8 s2i 构建,本地设置不是 必需的。所有构建和部署都在 OpenShift 中运行。错误 显示OpenShift不能拉 jboss-fuse-6/fis-java-openshift:2.0 图片。
    2. AFAIK,OpenShift 不提供 fabric8。
    3. 此图片托管在redhat container registry,非官方 码头登记处。换句话说,该图像位于 registry.access.redhat.com/jboss-fuse-6/fis-java-openshift,不是 registry-1.docker.io/v2/jboss-fuse-6/fis-java-openshift。 您需要开启docker引擎才能访问redhat registry,例如请参考this
    4. 如果您正在运行 s2i 构建,则不是您想的那样。
    5. 不需要,对于 s2i 构建或 docker 构建。

    【讨论】:

    • 感谢您的及时回复。所以wrt 2,需要在Openshift上安装fabric8吗?对于 #3,构建如何尝试达到“registry-1.docker.io/v2/jboss-fuse-6/fis-java-openshift/…”?
    • 如果您只在 OpenShift 中使用 fabric8 maven 插件 (fmp),则不需要在 OpenShift 集群上进行额外设置。 Fmp 通过本地 openshift 客户端工具 (oc) 与 OpenShift 协同工作。
    • 如果你没有在 docker config 中指定任何注册表,docker 引擎会尝试只从registry-1.docker.io/v2 拉取镜像。
    【解决方案2】:

    mvn package fabric8:build 有效。

                        <registry>registry.access.redhat.com</registry>
                        <authConfig>
                          <username>registry-username</username>
                          <password>registry-password</password>
                        </authConfig>
    
                    </configuration>
    

    【讨论】:

    • 请添加不仅仅是一个小代码 sn-p 作为答案。还请解释您的代码将如何帮助解决最初提出的问题(顺便说一句,这似乎与上述不一定能解决的错误有关)。
    猜你喜欢
    • 1970-01-01
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 2017-08-06
    • 2021-03-04
    • 2019-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多