Skip to content

Commit d71c737

Browse files
committed
using secrets
1 parent 2415212 commit d71c737

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

springboot-jpa.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
kind: Secret
2+
apiVersion: v1
3+
metadata:
4+
name: mysql-connection-secret
5+
data:
6+
password: c2FraWxh
7+
---
18
apiVersion: v1
29
kind: Service
310
metadata:
@@ -30,7 +37,10 @@ spec:
3037
image: aballaci/mysql-5.7-sakila:latest
3138
env:
3239
- name: MYSQL_ROOT_PASSWORD
33-
value: sakila
40+
valueFrom:
41+
secretKeyRef:
42+
name: mysql-connection-secret
43+
key: password
3444
livenessProbe:
3545
exec:
3646
command: ["mysqladmin", "ping"]
@@ -40,7 +50,7 @@ spec:
4050
readinessProbe:
4151
exec:
4252
# Check we can execute queries over TCP (skip-networking is off).
43-
command: ["mysql", "-h", "127.0.0.1", "-psakila", "-e", "SELECT 1"]
53+
command: ["mysql", "-psakila", "-h", "127.0.0.1", "-e", "SELECT 1"]
4454
initialDelaySeconds: 5
4555
periodSeconds: 2
4656
timeoutSeconds: 1
@@ -74,14 +84,19 @@ spec:
7484
spec:
7585
containers:
7686
- name: springboot-jpa
77-
image: aballaci/springboot-sakila-jpa:v1
87+
image: aballaci/springboot-sakila-jpa:v2
7888
resources:
7989
requests:
8090
cpu: 100m
8191
memory: 100Mi
8292
env:
8393
- name: MYSQL_HOST
8494
value: mysql
95+
- name: MYSQL_ROOT_PASSWORD
96+
valueFrom:
97+
secretKeyRef:
98+
name: mysql-connection-secret
99+
key: password
85100
ports:
86101
- containerPort: 8080
87102
initContainers:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
spring.jpa.hibernate.ddl-auto=none
22
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/sakila
33
spring.datasource.username=root
4-
spring.datasource.password=sakila
4+
spring.datasource.password=${MYSQL_ROOT_PASSWORD}

0 commit comments

Comments
 (0)