0

我尝试了解 Open Shift,它是如何工作的,如何运行应用程序,构建图像等。

从我认为相当简单的东西开始,我决定基于这个图像运行一个纯 centos7 操作系统的 pod。我在本地安装minishift v1.11.0+4459917,我创建了一个新项目,并执行命令: oc new-app openshift/base-centos7在这个项目中。结果,我收到以下消息:

--> Found Docker image bb81a09 (11 months old) from Docker Hub for "openshift/base-centos7"

    * An image stream will be created as "pon3:latest" that will track this image
    * This image will be deployed in deployment config "pon3"
    * The image does not expose any ports - if you want to load balance or send traffic to this component
      you will need to create a service with 'expose dc/pon3 --port=[port]' later
    * WARNING: Image "openshift/base-centos7" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources ...
    imagestream "pon3" created
    deploymentconfig "pon3" created
--> Success
    Run 'oc status' to view your app.

正如我在警告中看到的那样,此图像以 root 身份运行,这显然不是一个好习惯,但它可以解决,如此此处所述。我尝试了这两种方法——我用 scc 创建了一个新的服务帐户,并将 scc 分配给了sa。不幸的是,我仍然无法运行基于此图像的 pod。结果如下所示:anyuidanyuiddefault

oc get pods

mycentos-1-deploy         1/1       Running            0          32s
mycentos-1-p1vh5          0/1       CrashLoopBackOff   1          30s

我尝试以这种方式进行故障排除:

oc logs -p mycentos-1-p1vh5

This image serves as the base image for all OpenShift v3 S2I builder images.
It provides all essential libraries and development tools needed to
successfully build and run an application.

To use this image as a base image, you need to have 's2i/bin' directory in the
same directory as your S2I image Dockerfile. This directory should contain S2I
scripts.

This base image also provides the default user you should use to run your
application. Your Dockerfile should include this instruction after you finish
installing software:

USER default

The default directory for installing your application sources is
'/opt/app-root/src' and the WORKDIR and HOME for the 'default' user is set
to this directory as well. In your S2I scripts, you don't have to use absolute
path, but rather rely on the relative path.

To learn more about S2I visit: https://github.com/openshift/source-to-image

此外,我尝试进行故障排除,oc adm diagnostics但老实说,我没有看到与此问题相关的任何内容。

我显然在这里遗漏了一些东西。有人可以给我一个提示,应该如何处理,或者我该如何解决这个问题?是否有不同的方式来运行纯 centos 操作系统?

感谢您的任何帮助。

4

1 回答 1

1

您需要使用要部署的映像oc new-app才能在其中包含实际的应用程序。该openshift/base-centos7映像是仅在其上构建其他映像的基础映像,并且其中没有应用程序。

如果您只想启动一个容器并提供一个 shell 环境,您可以在其中使用该oc run命令。

OpenShift 不像传统的 VPS,您只需启动永久的 shell 环境,然后您可以访问这些环境来手动设置您的应用程序。这个想法是您将应用程序构建到映像中并部署应用程序。

我建议你去阅读:

并完成以下练习:

了解有关 OpenShift 是什么以及如何使用它的更多信息。

于 2018-01-23T00:14:57.647 回答