【发布时间】:2021-04-25 06:40:11
【问题描述】:
我在 kubernetes 中有一个配置文件作为机密文件,我想将它挂载到容器内的特定位置。问题是在容器内创建的卷是一个文件夹,而不是其中包含机密内容的文件。有什么办法解决吗? 我的部署如下所示:
kind: Deployment
apiVersion: apps/v1
metadata:
name: jetty
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: jetty
template:
metadata:
labels:
app: jetty
spec:
containers:
- name: jetty
image: quay.io/user/jetty
ports:
- containerPort: 8080
volumeMounts:
- name: config-properties
mountPath: "/opt/jetty/config.properties"
subPath: config.properties
- name: secrets-properties
mountPath: "/opt/jetty/secrets.properties"
- name: doc-path
mountPath: /mnt/storage/
resources:
limits:
cpu: '1000m'
memory: '3000Mi'
requests:
cpu: '750m'
memory: '2500Mi'
volumes:
- name: config-properties
configMap:
name: jetty-config-properties
- name: secrets-properties
secret:
secretName: jetty-secrets
- name: doc-path
persistentVolumeClaim:
claimName: jetty-docs-pvc
imagePullSecrets:
- name: rcc-quay
【问题讨论】:
-
是否检查过它不适用于秘密。
-
只能挂载目录。如果您使用它是否有效?只挂载 ConfigMap?还是那个目录上已经有其他东西了?
-
我需要挂载多个配置文件,其中一些具有密码和哈希值,其他配置文件进入 ConfigMap。 configmaps 与 subPath 配合得很好,但 secrets 不起作用。
标签: kubernetes volumes kubernetes-secrets