【发布时间】:2021-06-01 06:43:33
【问题描述】:
我正在研究 Springboot 和 Kubernetes,我有一个非常简单的应用程序可以连接到 Postgres 数据库。我想从 configmap 中获取 datasource 的值,从 secrets 中获取密码作为挂载文件。
配置映射文件:
apiVersion: v1
kind: ConfigMap
metadata:
name: customer-config
data:
application.properties: |
server.forward-headers-strategy=framework
spring.datasource.url=jdbc:postgresql://test/customer
spring.datasource.username=postgres
秘密文件:
apiVersion: v1
kind: Secret
metadata:
name: secret-demo
data:
spring.datasource.password: cG9zdGdyZXM=
部署文件:
spec:
containers:
- name: customerc
image: localhost:8080/customer
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8282
volumeMounts:
- mountPath: /workspace/config/default
name: config-volume
- mountPath: /workspace/secret/default
name: secret-volume
volumes:
- name: config-volume
configMap:
name: customer-config
- name: secret-volume
secret:
secretName: secret-demo
items:
- key: spring.datasource.password
path: password
如果我将 spring.datasource.password 属性从 secret 移动到 configmap,那么它可以正常工作,或者如果我将其值填充为 env 变量,那么它也可以正常工作。 但是我们知道这两种方法都不是安全的方法,有人可以告诉我文件挂载有什么问题吗?
【问题讨论】: