Skip to content

Commit a3026bd

Browse files
therepanicdsyer
authored andcommitted
Add Kubernetes support
1 parent 50866de commit a3026bd

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

k8s/db.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: demo-db
6+
type: servicebinding.io/postgresql
7+
stringData:
8+
type: "postgresql"
9+
provider: "postgresql"
10+
host: "demo-db"
11+
port: "5432"
12+
database: "petclinic"
13+
username: "user"
14+
password: "pass"
15+
16+
---
17+
apiVersion: v1
18+
kind: Service
19+
metadata:
20+
name: demo-db
21+
spec:
22+
ports:
23+
- port: 5432
24+
selector:
25+
app: demo-db
26+
27+
---
28+
apiVersion: apps/v1
29+
kind: Deployment
30+
metadata:
31+
name: demo-db
32+
labels:
33+
app: demo-db
34+
spec:
35+
selector:
36+
matchLabels:
37+
app: demo-db
38+
template:
39+
metadata:
40+
labels:
41+
app: demo-db
42+
spec:
43+
containers:
44+
- image: postgres:17
45+
name: postgresql
46+
env:
47+
- name: POSTGRES_USER
48+
valueFrom:
49+
secretKeyRef:
50+
name: demo-db
51+
key: username
52+
- name: POSTGRES_PASSWORD
53+
valueFrom:
54+
secretKeyRef:
55+
name: demo-db
56+
key: password
57+
- name: POSTGRES_DB
58+
valueFrom:
59+
secretKeyRef:
60+
name: demo-db
61+
key: database
62+
ports:
63+
- containerPort: 5432
64+
name: postgresql
65+
livenessProbe:
66+
tcpSocket:
67+
port: postgresql
68+
readinessProbe:
69+
tcpSocket:
70+
port: postgresql
71+
startupProbe:
72+
tcpSocket:
73+
port: postgresql

k8s/petclinic.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: petclinic
6+
spec:
7+
type: NodePort
8+
ports:
9+
- port: 80
10+
targetPort: 8080
11+
selector:
12+
app: petclinic
13+
14+
---
15+
apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
name: petclinic
19+
labels:
20+
app: petclinic
21+
spec:
22+
replicas: 1
23+
selector:
24+
matchLabels:
25+
app: petclinic
26+
template:
27+
metadata:
28+
labels:
29+
app: petclinic
30+
spec:
31+
containers:
32+
- name: workload
33+
image: dsyer/petclinic
34+
env:
35+
- name: SPRING_PROFILES_ACTIVE
36+
value: postgres
37+
- name: SERVICE_BINDING_ROOT
38+
value: /bindings
39+
- name: SPRING_APPLICATION_JSON
40+
value: |
41+
{
42+
"management.endpoint.health.probes.add-additional-paths": true
43+
}
44+
ports:
45+
- name: http
46+
containerPort: 8080
47+
livenessProbe:
48+
httpGet:
49+
path: /livez
50+
port: http
51+
readinessProbe:
52+
httpGet:
53+
path: /readyz
54+
port: http
55+
volumeMounts:
56+
- mountPath: /bindings/secret
57+
name: binding
58+
readOnly: true
59+
volumes:
60+
- name: binding
61+
projected:
62+
sources:
63+
- secret:
64+
name: demo-db

0 commit comments

Comments
 (0)