I'm trying to use configmaps and secrets in Kubernetes to configure my business database connection for my task but I couldn't make it work.
I created a secret with my database password :
apiVersion: v1
kind: Secret
metadata:
name: myapp-database-secret
labels:
app: myapp
data:
myapp-db-password: mypwd-encrypted-in-base64
Then I updated the SCDF configmap to add my connection properties in application.yaml section :
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"
Then I updated the SCDF deployment yaml to use the secret with a volume (just like SCDF mysql) :
volumes:
- name: database
secret:
secretName: scdf-mysql
defaultMode: 420
- name: myapp
secret:
secretName: myapp-database-secret
defaultMode: 420
and
volumeMounts:
- name: database
readOnly: true
mountPath: /etc/secrets/database
- name: myapp
readOnly: true
mountPath: /etc/secrets/myapp
But it seems that something is missing because it's not working and I don't see my properties in the arguments when I launch the task. It looks like my updated configmap is not taking into account (even if I restart minikube)
Thank you for your help