2.9. 示例应用程序

odo 提供与 OpenShift 组件类型目录中列出的语言或运行时的部分兼容性。例如:

NAME        PROJECT       TAGS
dotnet      openshift     2.0,latest
httpd       openshift     2.4,latest
java        openshift     8,latest
nginx       openshift     1.10,1.12,1.8,latest
nodejs      openshift     0.10,4,6,8,latest
perl        openshift     5.16,5.20,5.24,latest
php         openshift     5.5,5.6,7.0,7.1,latest
python      openshift     2.7,3.3,3.4,3.5,3.6,latest
ruby        openshift     2.0,2.2,2.3,2.4,latest
wildfly     openshift     10.0,10.1,8.1,9.0,latest
注意

对于 odo,Java 和 Node.js 是官方支持的组件类型。运行 odo catalog list components 来验证官方支持的组件类型。

要通过 web 访问该组件,请使用 odo url create 创建一个 URL。

2.9.1. Git 软件仓库示例

2.9.1.1. httpd

这个示例在 CentOS 7 上使用 httpd 构建并提供静态内容。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请查看 Apache HTTP 服务器容器镜像存储库

$ odo create httpd --git https://github.com/openshift/httpd-ex.git

2.9.1.2. java

这个示例在 CentOS 7 上构建并运行 fat JAR Java 应用程序。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请参见 Java S2I Builder image

$ odo create java --git https://github.com/spring-projects/spring-petclinic.git

2.9.1.3. nodejs

在 CentOS 7 中构建并运行 Node.js 应用程序。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请参见 Node.js 8 container image

$ odo create nodejs --git https://github.com/openshift/nodejs-ex.git

2.9.1.4. Perl

这个示例在 CentOS 7 中构建并运行 Perl 应用程序。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请查看 Perl 5.26 容器镜像

$ odo create perl --git https://github.com/openshift/dancer-ex.git

2.9.1.5. php

这个示例在 CentOS 7 中构建并运行 PHP 应用程序。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请参见 PHP 7.1 Docker image

$ odo create php --git https://github.com/openshift/cakephp-ex.git

2.9.1.6. Python

这个示例在 CentOS 7 中构建并运行 Python 应用程序。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请查看 Python 3.6 容器镜像

$ odo create python --git https://github.com/openshift/django-ex.git

2.9.1.7. Ruby

这个示例在 CentOS 7 中构建并运行 Ruby 应用程序。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请参见 Ruby 2.5 container image

$ odo create ruby --git https://github.com/openshift/ruby-ex.git

2.9.1.8. WildFly

这个示例在 CentOS 7 中构建并运行 WildFly 应用程序。有关使用这个构建器镜像的更多信息,包括 OpenShift Container Platform 的注意事项,请 查看 Wilfly - OpenShift 的 CentOS Docker 镜像

$ odo create wildfly --git https://github.com/openshift/openshift-jee-sample.git

2.9.2. 二进制示例

2.9.2.1. java

Java 可以用来部署二进制工件,如下:

$ git clone https://github.com/spring-projects/spring-petclinic.git
$ cd spring-petclinic
$ mvn package
$ odo create java test3 --binary target/*.jar
$ odo push

2.9.2.2. WildFly

WildFly 可以用来部署二进制应用程序,如下:

$ git clone https://github.com/openshiftdemos/os-sample-java-web.git
$ cd os-sample-java-web
$ mvn package
$ cd ..
$ mkdir example && cd example
$ mv ../os-sample-java-web/target/ROOT.war example.war
$ odo create wildfly --binary example.war