我尝试了解 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。结果如下所示:anyuid
anyuid
default
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 操作系统?
感谢您的任何帮助。