我正在尝试使用Kubernetes中的配置映射和秘密来为我的任务配置我的业务数据库连接,但是我无法使其工作。
我用数据库密码创建了一个秘密:
apiVersion: v1
kind: Secret
metadata:
name: myapp-database-secret
labels:
app: myapp
data:
myapp-db-password: mypwd-encrypted-in-base64
然后,我更新了SCDF配置图,以将连接属性添加到application.yaml部分:
application.yaml: |-
spring:
cloud:
dataflow:
task:
platform:
kubernetes:
accounts:
default:
limits:
memory: 1024Mi
cpu: 500m
datasource:
url: 'jdbc:mysql://${SCDF_MYSQL_SERVICE_HOST}:${SCDF_MYSQL_SERVICE_PORT}/dataflow'
driverClassName: org.mariadb.jdbc.Driver
username: root
password: ${mysql-root-password}
testOnBorrow: true
validationQuery: "SELECT 1"
myapp:
datasource:
url: 'jdbc:postgresql://myip:myport/mydb'
driverClassName: org.postgresql.Driver
username: myuser
password: ${myapp-db-password}
testOnBorrow: true
validationQuery: "SELECT 1"
然后,我更新了SCDF部署yaml以将密码与卷配合使用(就像SCDF mysql):
volumes:
- name: database
secret:
secretName: scdf-mysql
defaultMode: 420
- name: myapp
secret:
secretName: myapp-database-secret
defaultMode: 420
和
volumeMounts:
- name: database
readOnly: true
mountPath: /etc/secrets/database
- name: myapp
readOnly: true
mountPath: /etc/secrets/myapp
但是似乎缺少了一些东西,因为它不起作用,并且在启动任务时在参数中看不到我的属性。看来我的更新configmap没有考虑在内(即使我重新启动minikube也是如此)
谢谢您的帮助