在IBM Cloud Kubernetes中创建安装PVC时,仅读取错误



我正在尝试将nexus3部署在IBM云服务中。我遇到了这个错误,可能是因为PVC仅针对该用户读取。例如,我在Postgres中遇到了这个问题,但我不记得如何解决它:

mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied
mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to No such file or directory
Warning:  Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
Warning:  Forcing option -XX:LogFile=/tmp/jvm.log
Unable to update instance pid: Unable to create directory /nexus-data/instances
/nexus-data/log/karaf.log (No such file or directory)
Unable to update instance pid: Unable to create directory /nexus-data/instances

这些是PVC和POD YAML:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexus-pvc
  annotations:
    volume.beta.kubernetes.io/storage-class: "ibmc-file-retain-bronze"
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
apiVersion: v1
kind: Pod
metadata:
  name: nexus
  labels:
    name: nexus
spec:
  containers:
    - name: nexus
      image: sonatype/nexus3
      ports:
        - containerPort: 8081
      volumeMounts:
        - name: nexus-data
          mountPath: /nexus-data
        - name: tz-config
          mountPath: /etc/localtime
  volumes:
  - name: nexus-data
    persistentVolumeClaim:
      claimName: nexus-pvc
  - name: tz-config
    hostPath:
      path: /usr/share/zoneinfo/Europe/Madrid

nexus3 dockerfile的结构使其作为非root用户运行。但是,NFS文件存储需要root用户访问和写入。有几种解决此问题的方法。首先,您可以重组码头文件,以临时添加非根用户以扎根并更改音量安装权限。以下是这样的说明:https://console.bluemix.net/docs/containers/cs_storage.html#nonroot

另一个选项是运行initcontainer(https://kubernetes.io/docs/conepts/workloads/pods/init-containers/(,该选项在主要容器运行之前更改安装路径所有权。Initcontainer看起来像这样:

initContainers:
      - name: permissionsfix
        image: ubuntu:latest
        command: ["/bin/sh", "-c"]
        args:
          - >
            chown 1000:1000 /mount;
        volumeMounts:
        - name: volume
          mountPath: /mount

文件存储有这些权限问题。而不是使用基于文件的卷,而是使用基于块的卷。

安装块存储插件并更新您的资源以使用新可用的存储类。用法的一个示例:

storage:
  type: persistent-claim
  size: 100Gi
  deleteClaim: false
  class: "ibmc-block-retain-bronze"

相关内容

  • 没有找到相关文章

最新更新