Skip to content

Commit

Permalink
Add Kubernetes support
Browse files Browse the repository at this point in the history
  • Loading branch information
panic08 authored and dsyer committed Nov 8, 2024
1 parent 50866de commit a3026bd
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
73 changes: 73 additions & 0 deletions k8s/db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
apiVersion: v1
kind: Secret
metadata:
name: demo-db
type: servicebinding.io/postgresql
stringData:
type: "postgresql"
provider: "postgresql"
host: "demo-db"
port: "5432"
database: "petclinic"
username: "user"
password: "pass"

---
apiVersion: v1
kind: Service
metadata:
name: demo-db
spec:
ports:
- port: 5432
selector:
app: demo-db

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-db
labels:
app: demo-db
spec:
selector:
matchLabels:
app: demo-db
template:
metadata:
labels:
app: demo-db
spec:
containers:
- image: postgres:17
name: postgresql
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: demo-db
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: demo-db
key: password
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: demo-db
key: database
ports:
- containerPort: 5432
name: postgresql
livenessProbe:
tcpSocket:
port: postgresql
readinessProbe:
tcpSocket:
port: postgresql
startupProbe:
tcpSocket:
port: postgresql
64 changes: 64 additions & 0 deletions k8s/petclinic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
apiVersion: v1
kind: Service
metadata:
name: petclinic
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
selector:
app: petclinic

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: petclinic
labels:
app: petclinic
spec:
replicas: 1
selector:
matchLabels:
app: petclinic
template:
metadata:
labels:
app: petclinic
spec:
containers:
- name: workload
image: dsyer/petclinic
env:
- name: SPRING_PROFILES_ACTIVE
value: postgres
- name: SERVICE_BINDING_ROOT
value: /bindings
- name: SPRING_APPLICATION_JSON
value: |
{
"management.endpoint.health.probes.add-additional-paths": true
}
ports:
- name: http
containerPort: 8080
livenessProbe:
httpGet:
path: /livez
port: http
readinessProbe:
httpGet:
path: /readyz
port: http
volumeMounts:
- mountPath: /bindings/secret
name: binding
readOnly: true
volumes:
- name: binding
projected:
sources:
- secret:
name: demo-db

0 comments on commit a3026bd

Please sign in to comment.