3.3. 验证
以下验证步骤使用 openshift-helloworld 示例应用程序。
显示与当前 OpenShift 项目关联的 pod 列表:
oc get podsNAME READY STATUS RESTARTS AGE openshift-helloworld-1-build 0/1 Completed 0 11m openshift-helloworld-1-deploy 0/1 Completed 0 10m openshift-helloworld-1-gzzrx 1/1 Running 0 10m要获取应用程序的 pod 的日志输出,请使用
oc logs -f命令及其名称。以下示例使用openshift-helloworld-1-gzzrxpod 名称,它与以应用程序名称作为前缀的最新 pod 对应:oc logs -f openshift-helloworld-1-gzzrxStarting the Java application using /opt/jboss/container/java/run/run-java.sh ... INFO exec -a "java" java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:MaxRAMPercentage=50.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -cp "." -jar /deployments/quarkus-run.jar __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2024-09-17 10:23:25,254 INFO [io.quarkus] (main) getting-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.20.0.redhat-00002) started in 0.653s. Listening on: http://0.0.0.0:8080 2024-09-17 10:23:25,281 INFO [io.quarkus] (main) Profile prod activated. 2024-09-17 10:23:25,281 INFO [io.quarkus] (main) Installed features: [cdi, kubernetes, rest, smallrye-context-propagation, vertx]获取服务列表:
oc get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE openshift-helloworld ClusterIP 172.30.64.57 <none> 80/TCP 14m获取用于测试应用的 URL。为此,请在构建应用程序前设置
application.properties文件中的quarkus.openshift.route.expose=true属性来确保您已公开 OpenShift Container Platform 路由。oc get routesNAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD openshift-helloworld openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com openshift-helloworld http None注意请注意,路由现在侦听端口 80,不再在端口 8080 上。
您可以使用
curl和oc get routes的完整 URL 输出(即 "\http://openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com")来测试本示例中演示的应用或终端。例如:
curl http://openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com。