繁体   English   中英

无法将卷装入 kube.netes 中的 pod

[英]Unable to mount a volume into a pod in kubernetes

我有一个 pod,它正在使用 Boto 查询 AWS 服务。 此 pod 在 EKS 中的 kube.netes 集群中运行。

在真实集群上运行时,我们使用 ServiceAccount/Role/RoleBinding 来授予 Pod 获取 IAM 角色的权限。

但是当我使用kind在本地运行它时,我希望它使用我的~/.aws目录中的凭据。

所以我按如下方式安装卷:

    volumes:
    - hostPath:
        path: /var/run/datadog
        type: ""
      name: dsdsocket
    - hostPath:
        path: /Users/me/.aws
        type: DirectoryOrCreate
      name: aws

并在 pod 中使用它们,如下所示:

      volumeMounts:
      - mountPath: /var/run/datadog
        name: dsdsocket
        readOnly: true
      - mountPath: /root/.aws
        name: aws
        readOnly: true

我检查过~/.aws/credentials

但是该目录在 pod 中显示为空:

root@the_pod:/app# ls -al /root/.aws
total 8
drwxr-xr-x 2 root root 4096 Apr 12 19:33 .
drwx------ 1 root root 4096 May  9 17:22 ..

注意:我也尝试在~/.aws/credentials中安装实际的凭证文件,但它也没有安装。

任何想法我做错了什么?

我想您在创建 kind 集群时需要使用 额外的挂载,它用于将主机上的存储传递到 kind 节点以持久保存数据、通过代码挂载等。

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  # add a mount from /path/to/my/files on the host to /files on the node
  extraMounts:
  - hostPath: /path/to/my/files/
    containerPath: /files
    # optional: if set, the mount is read-only.
    # default false
    readOnly: true
    propagation: HostToContainer

使用自定义配置文件创建种类集群:

$ kind create cluster --config=kind-config.yaml

暂无
暂无

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

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