[错误摘要]
我是RedHat OpenShift的新手。
OpenShift Pod status CrashLoopBackOff.
Pod日志显示“ID :无法找到用户ID 1000660000的名称”和“java.io.FileNotFoundException:.(权限被拒绝)”。我试图通过更改UID来解决这个问题,但是它不起作用。
如果原因不是UID,它可能是访问pvc。有什么办法检查和改变pvc吗?
[错误复制(使用OpenShift网络控制台和终端)]
1.创建OpenShift集群和项目。
2.从外部注册表添加容器映像并创建部署。
(同时创建应用程序和组件)
这时,吊舱正在运行。
3.打开部署页面并将Pod号更改为0。
4.删除现有的容器卷。
5.增加存储和创建PVC。
6.将Pod号改为1。
7.吊舱不运行,吊舱状态为CrashLoopBackOff。
8.按以下命令创建服务帐户“awag-sa”。
oc create sa awag-sa
oc adm policy add-scc-to-user anyuid-z awag-sa9.为修补serviceAccount创建补丁yaml文件“补丁-file.yaml”
spec:
template:
spec:
serviceAccountName: awag-sa10.按以下命令将yaml文件修补为部署
kubectl patch deployment nexus3-comp --patch "$(cat patch-file.yaml)"11.检查部署yaml文件(OpenShift web控制台)是否正确修改了spec.template.spec.serviceAccountName。但豆荚状态仍然是CrashLoopBackOff。
…
spec:
replicas: 0
selector:
matchLabels:
app: nexus3-comp
template:
metadata:
creationTimestamp: null
labels:
app: nexus3-comp
deploymentconfig: nexus3-comp
annotations:
openshift.io/generated-by: OpenShiftWebConsole
spec:
restartPolicy: Always
serviceAccountName: awag-sa
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
securityContext: {}
containers:
- name: nexus3-comp
…发布于 2021-07-10 14:42:30
OpenShift将使用“随机”UID --相对于您的项目/名称空间,有一个注释告诉您向您的项目分配了哪个UID。除非另有配置,否则容器将以该UID的形式运行。
如果您的应用程序在某种程度上需要从UID到用户名的getpwnam /解析,那么需要使用use包装器。
确保它安装在您的Dockerfile中
apt-get install libnss-wrapper
yum install nss_wrapper然后,在您的入口点加载您自己的密码/组:
RUNTIME_USER=${RUNTIME_USER:-nexus}
RUNTIME_GROUP=${RUNTIME_GROUP:-$RUNTIME_USER}
RUNTIME_HOME=${RUNTIME_HOME:-/tmp}
echo Setting up nsswrapper mapping `id -u` to $RUNTIME_GROUP
(
grep -v ^$RUNTIME_USER /etc/passwd
echo "$RUNTIME_USER:x:`id -u`:`id -g`:$RUNTIME_USER:$RUNTIME_HOME:/usr/sbin/nologin"
) >/tmp/java-passwd
(
grep -v ^$RUNTIME_GROUP /etc/group
echo "$RUNTIME_GROUP:x:`id -g`:"
) >/tmp/java-group
export NSS_WRAPPER_PASSWD=/tmp/java-passwd
export NSS_WRAPPER_GROUP=/tmp/java-group
export LD_PRELOAD=/usr/lib/libnss_wrapper.so
# or /usr/lib64/libnss_wrapper.so, on EL x86_64
[rest of your entrypoint.sh -- eg: exec $@]编辑:实际上,nexus并不在意--尽管以前的注释仍然适用,如果一个容器崩溃了,抱怨缺少了UID。
我不能复制你收到的信息。据我所见,nexus将首先崩溃,无法写入日志。然后是它的数据。修正了两次添加一个卷:
oc create deploy nexus --image=sonatype/nexus3
oc edit deploy/nexus
[...]
volumeMounts:
- mountPath: /opt/sonatype/nexus3/log
name: empty
subPath: log
- mountPath: /nexus-data
name: empty
subPath: data
...
volumes:
- emptyDir: {}
name: empty现在,在您的例子中,/nexus-数据应该存储在PVC中,而不是一些emptyDir中。无论哪种方式,添加这两个卷都解决了这个问题:
# oc logs -f nexus-f7c577ff9-pqmdc
id: cannot find name for user ID 1000230000
2021-07-10 16:36:48,155+0000 INFO [FelixStartLevel] *SYSTEM org.sonatype.nexus.pax.logging.NexusLogActivator - start
2021-07-10 16:36:49,184+0000 INFO [FelixStartLevel] *SYSTEM org.sonatype.nexus.features.internal.FeaturesWrapper - Fast FeaturesService starting
2021-07-10 16:36:53,004+0000 INFO [FelixStartLevel] *SYSTEM ROOT - bundle org.apache.felix.scr:2.1.26 (63) Starting with globalExtender setting: false
2021-07-10 16:36:53,038+0000 INFO [FelixStartLevel] *SYSTEM ROOT - bundle org.apache.felix.scr:2.1.26 (63) Version = 2.1.26
...发布于 2021-07-12 05:42:32
※被提问者回答
我需要更改部署的volumeMounts设置。
volumeMounts:
- name: nexus-data-pvc
mountPath: /nexus-data
subPath: data
- name: nexus-data-pvc
mountPath: /opt/sonatype/nexus3/log
subPath: loghttps://stackoverflow.com/questions/68328336
复制相似问题