Work with cleardb/mysql as it provides clean username/password for JDBC

This commit is contained in:
Dr Nic Williams 2018-11-05 14:20:19 +10:00
parent c0641aa828
commit 9ed2654792
3 changed files with 33 additions and 9 deletions

View File

@ -3,4 +3,19 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
java -jar -Dspring.profiles.active="in-memory" spring-music.jar
if [[ "${DATABASE_JDBC_URL:-X}" == "X" ]]; then
java -jar -Dspring.profiles.active="in-memory" spring-music.jar
else
if [[ "${DATABASE_JDBC_URL}" =~ "jdbc:mysql" ]]; then
java -jar -Dspring.profiles.active=mysql \
-Dspring.datasource.url=${DATABASE_JDBC_URL} \
-Dspring.datasource.username=${DATABASE_USERNAME} \
-Dspring.datasource.password=${DATABASE_PASSWORD} \
-Dspring.datasource.driver-class-name=com.mysql.jdbc.Driver \
spring-music.jar
else
echo "ERROR: unknown \$DATABASE_JDBC_URL protocol; currently supporting jdbc:mysql://"
echo "-- \$DATABASE_JDBC_URL: $DATABASE_JDBC_URL"
exit 1
fi
fi

View File

@ -23,11 +23,7 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- java
- -jar
- -Dspring.profiles.active={{ .Values.database.springprofile }}
- build/libs/spring-music.jar
command: ['/app/start.sh']
ports:
- name: http
containerPort: 8080
@ -38,6 +34,21 @@ spec:
secretKeyRef:
name: {{ template "app-with-binding.fullname" . }}-db-secret
key: uri
- name: DATABASE_JDBC_URL
valueFrom:
secretKeyRef:
name: {{ template "app-with-binding.fullname" . }}-db-secret
key: jdbcUrl
- name: DATABASE_USERNAME
valueFrom:
secretKeyRef:
name: {{ template "app-with-binding.fullname" . }}-db-secret
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "app-with-binding.fullname" . }}-db-secret
key: password
livenessProbe:
httpGet:
path: /

View File

@ -6,11 +6,9 @@ replicaCount: 1
database:
instance: app-db
# springprofile: postgres
springprofile: in-memory
image:
repository: mxplusb/spring-music
repository: drnic/spring-music
tag: latest
pullPolicy: IfNotPresent