简体   繁体   English

ConfigMap 被挂载为文件夹而不是文件

[英]ConfigMap being mounted as a folder instead of file

I have a problem mounting 2 files in a pod, one is being treated as a directory for some reason (maybe stupid one, but I looked and looked, couldn't find a solution).我在 pod 中安装 2 个文件时遇到问题,由于某种原因,一个文件被视为目录(可能是愚蠢的,但我看了又看,找不到解决方案)。

in my config folder there's 2 files:在我的config文件夹中有 2 个文件:

config
|- log4j.properties
|- server.main.properties

Running StatefulSet , here's the Volumes part of the manifest file:运行StatefulSet ,这是清单文件的 Volumes 部分:

containers:
 ...
      volumeMounts:
        - mountPath: /usr/local/confluent/config/log4j.properties
          name: log4j-properties
          subPath: log4j.properties
        - mountPath: /usr/local/confluent/config/server.properties
          name: server-properties
          subPath: server.properties
  restartPolicy: Always
  volumes:
    - name: log4j-properties
      configMap:
        name: log4j-properties
        defaultMode: 0777
    - name: server-properties
      configMap:
        name: server-properties
        defaultMode: 0777
volumeClaimTemplates:
- metadata:
    name: confluent-persistent-storage
  spec:
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 1Gi

Created ConfigMaps:创建的 ConfigMap:

kubectl create configmap server-properties --from-file=config/server.main.properties
kubectl create configmap log4j-properties --from-file=config/log4j.properties

kubectl describe pod gives mounted volumes as: kubectl describe pod将挂载的卷提供为:

    Volumes:
  confluent-persistent-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  confluent-persistent-storage-confluent-0
    ReadOnly:   false
  server-properties:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      server-properties
    Optional:  false
  log4j-properties:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      log4j-properties
    Optional:  false

It's being initialized for 5-6 minutes and in logs I can see that server.properties is not a file, but a folder, and when I exec into pod, I can see that the actual folder is been created instead of file.. What am I doing wrong here?它被初始化了 5-6 分钟,在日志中我可以看到 server.properties 不是一个文件,而是一个文件夹,当我执行到 pod 时,我可以看到创建了实际的文件夹而不是文件。什么我在这里做错了吗?

subPath: server.properties子路径:server.properties

Wouldn't you want to use it as below?你不想像下面那样使用它吗?

subPath: server.main.properties子路径:server.main.properties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM