Openshift对于应用构建提供了三种模式

  • 从应用的源代码构建并部署,Openshift通过一个S2I的构建过程编译打包并实现发布,具体可以参考

https://www.cnblogs.com/ericnie/p/9677719.html  

  • 从应用的二进制构建和部署,用户可以指定通过其他工具完成的二进制包,比如war,jar之类,然后openshift将这些文件和基础镜像一起打包发布。
  • 在Openshift之外构建源码和镜像

S2I虽然非常方便,个人认为他的定位是

  • 适用场景是一些没有通过外部的CICD工具的项目,直接在S2I镜像内完成程序的编译以及形成应用镜像的过程,相对比较小巧而且灵活
  • 会把中间的编译依赖包以及其他中间过程打包到同一个运行镜像,这对于一些公司需要符合公司的标准运行镜像,同时只需要一个标准镜像和编译后的二进制以及应用配置这种模式就不太适合了。

链式构建就是主要针对这个问题而出现的,过程如下:

1. 生成Binary的构建

ericdeMacBook-Pro:~ ericnie$ oc new-build s2i-tomcat~https://github.com/ericnie2015/openshift-tomcat --name=builder
--> Found image f000bc5 ( days old) in image stream "openshift/s2i-tomcat" under tag "latest" for "s2i-tomcat" Tomcat Builder
--------------
Platform for building and running JEE applications on Tomcat Tags: builder, tomcat * A source build using source code from https://github.com/ericnie2015/openshift-tomcat will be created
* The resulting image will be pushed to image stream "builder:latest"
* Use 'start-build' to trigger a new build --> Creating resources with label build=builder ...
imagestream "builder" created
buildconfig "builder" created
--> Success
Build configuration "builder" created and build triggered.
Run 'oc logs -f bc/builder' to stream the build progress.

构建完成后看到一个名叫builder的构建和镜像

2.Docker构建生成Runtime Images.

ricdeMacBook-Pro:chainbuilding ericnie$ oc new-build --name=runtime --docker-image=ericnie2017/tomcat:8.5.-jre8 --source-image=builder --source-image-path=/tomcat/webapps/ROOT.war:. --dockerfile=$'FROM ericnie2017/tomcat:8.5.34-jre8\nCOPY ROOT.war /usr/local/tomcat/webapps/myapp.war' --strategy=docker
--> Found Docker image 41a54fe ( weeks old) from Docker Hub for "tomcat:8.5.34-jre8" * An image stream will be created as "tomcat:8.5.34-jre8" that will track the source image
* A Docker build using a predefined Dockerfile will be created
* The resulting image will be pushed to image stream "runtime:latest"
* Every time "tomcat:8.5.34-jre8" changes a new build will be triggered --> Creating resources with label build=runtime ...
imagestream "runtime" created
buildconfig "runtime" created
--> Success
Build configuration "runtime" created and build triggered.
Run 'oc logs -f bc/runtime' to stream the build progress.

构建日志如下

ericdeMacBook-Pro:chainbuilding ericnie$ oc logs -f bc/runtime
Pulling image tomcat@sha256:e7bff3f32561daf3ba91142bca7c5aeaf49c376ee07e0d6b66e3207aa08a343a ...
Pulled / layers, % complete
Pulled / layers, % complete
Pulled / layers, % complete
Pulled / layers, % complete
Pulled / layers, % complete
Extracting
Step / : FROM tomcat@sha256:e7bff3f32561daf3ba91142bca7c5aeaf49c376ee07e0d6b66e3207aa08a343a
---> 41a54fe1f79d
Step / : COPY ROOT.war /usr/local/tomcat/webapps/
---> 265bdbdfd823
Removing intermediate container 2eb535912c60
Step / : ENV "OPENSHIFT_BUILD_NAME" "runtime-1" "OPENSHIFT_BUILD_NAMESPACE" "maven-tomcat"
---> Running in ab63b922af0e
---> a5452c4705d6
Removing intermediate container ab63b922af0e
Step / : LABEL "io.openshift.build.name" "runtime-1" "io.openshift.build.namespace" "maven-tomcat"
---> Running in 95e2f78a51c7
---> 5a76fcaecd2a
Removing intermediate container 95e2f78a51c7
Successfully built 5a76fcaecd2a
Pushing image 172.30.1.1:/maven-tomcat/runtime:latest ...
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Pushed / layers, % complete
Push successful

3.生成新的应用

ericdeMacBook-Pro:chainbuilding ericnie$ oc new-app runtime --name=tomcat-app
--> Found image 5a76fca (About a minute old) in image stream "maven-tomcat/runtime" under tag "latest" for "runtime" * This image will be deployed in deployment config "tomcat-app"
* Port /tcp will be load balanced by service "tomcat-app"
* Other containers can access this service through the hostname "tomcat-app"
* WARNING: Image "maven-tomcat/runtime:latest" runs as the 'root' user which may not be permitted by your cluster administrator --> Creating resources ...
imagestreamtag "tomcat-app:latest" created
deploymentconfig "tomcat-app" created
service "tomcat-app" created
--> Success
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose svc/tomcat-app'
Run 'oc status' to view your app.

创建Route后访问,根目录页面

myapp目录下页面

OpenShift应用镜像构建(2) - 链式构建的更多相关文章

  1. Kafka+kylin——kylin2.5.0流式构建

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/a_drjiaoda/article/d ...

  2. 001/Go语言构建区块链(mooc)

    1.区块链发展与现状 视频地址:https://www.imooc.com/video/17452 注意: 比特币与以太坊最大的区别在于: 以太坊引入了对图灵完美智能合约的支持,人们可以将任何业务逻辑 ...

  3. Gradle学习系列之四——增量式构建

    在本系列的上篇文章中,我们讲到了如何读懂Gradle的语法,在本篇文章中,我们将讲到增量式地构建项目. 请通过以下方式下载本系列文章的Github示例代码: git clone https://git ...

  4. WebApi 插件式构建方案

    WebApi 插件式构建方案 WebApi 插件式构建方案 公司要推行服务化,不可能都整合在一个解决方案内,因而想到了插件式的构建方案.最终定型选择基于 WebApi 构建服务化,之所以不使用 WCF ...

  5. WebApi 插件式构建方案:重写的控制器获取工厂

    body { border: 1px solid #ddd; outline: 1300px solid #fff; margin: 16px auto; } body .markdown-body ...

  6. WebApi 插件式构建方案:IOC 容器初始化

    body { border: 1px solid #ddd; outline: 1300px solid #fff; margin: 16px auto; } body .markdown-body ...

  7. .Net Core 商城微服务项目系列(十):使用SkyWalking构建调用链监控(2019-02-13 13:25)

    SkyWalking的安装和简单使用已经在前面一篇介绍过了,本篇我们将在商城中添加SkyWalking构建调用链监控. 顺带一下怎么把ES设置为Windows服务,cd到ES的bin文件夹,运行ela ...

  8. 构建ROP链实现远程栈溢出

    通常情况下栈溢出可能造成的后果有两种,一类是本地提权另一类则是远程执行任意命令,通常C/C++并没有提供智能化检查用户输入是否合法的功能,同时程序编写人员在编写代码时也很难始终检查栈是否会发生溢出,这 ...

  9. LFS(Linux From Scratch)构建过程全记录(五):交叉工具链的构建

    写在前面 本文将详细讲述如何构建工具链 前置知识 在LFS-BOOK中,我们需要学习一些关于"交叉编译"的内容,详见书本 安装Binutils-2.39 我们cd到sources文 ...

随机推荐

  1. JVM 核心机制(类加载器、自定义文件系统类加载器、网络自定义类加载器

  2. HDU-2389

    Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Ot ...

  3. [转]6个HelloWorld

    原文地址:点击打开链接 转这个帖子,是因为看了这个帖子使我明白了一个道理:一旦你发散自己的思维,激发自己的创意,就会发现原来编程是这么的好玩. 原文标题为<6个变态的C语言Hello World ...

  4. redis之(十五)redis的集群中的哨兵角色

    一:redis集群的哨兵的目的是什么?. (1)监控主redis和从redis数据库是否正常运行 (2)主redis出现故障,自动将其中一台从redis升级为主redis.将原先的主redis转变成从 ...

  5. Largest Number——STL的深层理解

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  6. Go语言的基准测试简单示例

    测试了三个从数字转换为字符的性能, 高手的感觉.... package listing28_test import ( "fmt" "testing" &quo ...

  7. HDU 4348.To the moon SPOJ - TTM To the moon -可持久化线段树(带修改在线区间更新(增减)、区间求和、查询历史版本、回退到历史版本、延时标记不下放(空间优化))

    To the moon Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  8. 转:攻击JavaWeb应用[1]-javaEE基础

    http://www.cnblogs.com/oh3o/p/3224562.html JSP: 全名为java server page,其根本是一个简化的Servlet. Servlet:Servle ...

  9. Java Eclipse插件

    EasyExplore 快速打开文件所在目录1 http://sourceforge.net/projects/easystruts/ OpenExplorer 快速打开文件所在目录2 https:/ ...

  10. ARP扫描工具arp-scan

    ARP扫描工具arp-scan   arp-scan是Kali Linux自带的一款ARP扫描工具.该工具可以进行单一目标扫描,也可以进行批量扫描.批量扫描的时候,用户可以通过CIDR.地址范围或者列 ...