首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Kubernetes的多个hostPath volumeMounts :只有一个有效

使用Kubernetes的多个hostPath volumeMounts :只有一个有效
EN

Stack Overflow用户
提问于 2020-06-09 17:51:42
回答 2查看 125关注 0票数 0

我的pod规范文件

代码语言:javascript
复制
  - name: temp1-cont
    image: temp1-img:v2
    env:
      - name: CONFIG_MODE
        value: "manager"
    securityContext:
      privileged: true
    volumeMounts:
      - mountPath: /bin/tipc-config
        name: tipc-vol
    volumeMounts:
      - mountPath: /etc/
        name: config-vol
    resources:
      limits:
        cpu: 100m
        memory: "100Mi"
      requests:
        cpu: 100m
        memory: "100Mi"
    command: ["/etc/init.d/docker-init"]
  volumes:
    - name: tipc-vol
      hostPath:
        path: /opt/tipc-config
        type: FileOrCreate
    - name: config-vol
      hostPath:
        path: /opt/config/
        type: DirectoryOrCreate

我使用两个hostPath卷,即tipc-vol和config-vol,但是当我创建pod时,只挂载了一个卷,顺便说一下,这是容器上挂载的最后一个卷

代码语言:javascript
复制
  temp1-cont:
    Container ID:
    Image:         temp1-img:v2
    Image ID:
    Port:          <none>
    Host Port:     <none>
    Command:
      /etc/init.d/docker-init
    State:          Running
      Started:      Tue, 09 Jun 2020 09:36:57 +0000
    Ready:          False
    Restart Count:  0
    Limits:
      cpu:     100m
      memory:  100Mi
    Requests:
      cpu:     100m
      memory:  100Mi
    Environment:
      CONFIG_MODE:  manager
    Mounts:
      /etc/ from config-vol (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-g2ltz (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  tipc-vol:
    Type:          HostPath (bare host directory volume)
    Path:          /opt/tipc-config
    HostPathType:  FileOrCreate
  config-vol:
    Type:          HostPath (bare host directory volume)
    Path:          /opt/config/
    HostPathType:  DirectoryOrCreate
  default-token-g2ltz:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-g2ltz
    Optional:    false
QoS Class:       Guaranteed

在k8s文档中,没有提到这样的内容。我正在尝试测试我的应用程序,所以我使用的是hostVolume而不是持久卷。任何帮助都将不胜感激。提前谢谢。

EN

回答 2

Stack Overflow用户

发布于 2020-06-09 18:06:46

如下所示更新pod卷挂载

代码语言:javascript
复制
      volumeMounts:
      - mountPath: /bin/tipc-config
        name: tipc-vol
      - mountPath: /etc/
        name: config-vol

所以,你的pod yaml将会是

代码语言:javascript
复制
 - name: temp1-cont
    image: temp1-img:v2
    env:
      - name: CONFIG_MODE
        value: "manager"
    securityContext:
      privileged: true
    volumeMounts:
      - mountPath: /bin/tipc-config
        name: tipc-vol
      - mountPath: /etc/
        name: config-vol
    resources:
      limits:
        cpu: 100m
        memory: "100Mi"
      requests:
        cpu: 100m
        memory: "100Mi"
    command: ["/etc/init.d/docker-init"]
  volumes:
    - name: tipc-vol
      hostPath:
        path: /opt/tipc-config
        type: FileOrCreate
    - name: config-vol
      hostPath:
        path: /opt/config/
        type: DirectoryOrCreate
票数 3
EN

Stack Overflow用户

发布于 2020-06-09 18:08:15

卸下第二个volumeMounts:。所以下面应该是可行的

代码语言:javascript
复制
volumeMounts:
  - mountPath: /bin/tipc-config
    name: tipc-vol
  - mountPath: /etc/
    name: config-vol
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62279762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档