本文介绍了如何将多个文件/秘密安装到kubernetes的公共目录中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同文件创建的多个机密.我想将它们全部存储在公用目录/var/secrets/中.不幸的是,我无法执行此操作,因为kubernetes会在pod验证步骤中抛出无效值:"/var/secret":必须唯一错误.以下是我的广告连播定义的示例.

I've multiple secrets created from different files. I'd like to store all of them in common directory /var/secrets/. Unfortunately, I'm unable to do that because kubernetes throws 'Invalid value: "/var/secret": must be unique error during pod validation step. Below is an example of my pod definition.

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: alpine-secret
  name: alpine-secret
spec:
  containers:
  - command:
    - sleep
    - "3600"
    image: alpine
    name: alpine-secret
    volumeMounts:
    - name: xfile
      mountPath: "/var/secrets/"
      readOnly: true
    - name: yfile
      mountPath: "/var/secrets/"
      readOnly: true
  volumes:
  - name: xfile
    secret:
      secretName: my-secret-one
  - name: yfile
    secret:
      secretName: my-secret-two

如何将来自多个机密的文件存储在同一目录中?

How can I store files from multiple secrets in the same directory?

推荐答案

预计的数量

您可以使用投影量在同一目录中有两个秘密

Projected Volume

You can use a projected volume to have two secrets in the same directory

示例

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: alpine-secret
  name: alpine-secret
spec:
  containers:
  - command:
    - sleep
    - "3600"
    image: alpine
    name: alpine-secret
    volumeMounts:
    - name: xyfiles
      mountPath: "/var/secrets/"
      readOnly: true
  volumes:
  - name: xyfiles
    projected:
      sources:
      - secret:
          name: my-secret-one
      - secret:
          name: my-secret-two

这篇关于如何将多个文件/秘密安装到kubernetes的公共目录中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 10:06