Add build.sh and db-deployment.yaml
This commit is contained in:
parent
e61a76e0fb
commit
7e4a5c1082
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
usage() {
|
||||
printf "$0 usage: \n -x: down\n -d \$DOMAIN: domain\n -t: tests\n -i integration\n" $0
|
||||
exit 0
|
||||
}
|
||||
|
||||
domain=
|
||||
|
||||
while getopts ":hd:b" arg; do
|
||||
case $arg in
|
||||
d) domain=${OPTARG} ;;
|
||||
b) build=Y ;;
|
||||
h | *) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
export API=data/sample-api-users
|
||||
docker build $API -f $API/Dockerfile.prod -t api:prod
|
||||
export CLIENT=data/sample-client-users
|
||||
docker build $CLIENT -f $CLIENT/Dockerfile -t client:prod
|
||||
export DB=data/db
|
||||
docker build $DB -f $DB/Dockerfile -t db:prod
|
|
@ -0,0 +1,103 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
ports:
|
||||
- port: 5432
|
||||
selector:
|
||||
app: postgres
|
||||
tier: postgres
|
||||
clusterIP: None
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: postgres-pv
|
||||
labels:
|
||||
type: local
|
||||
spec:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
volumeMode: Filesystem
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
storageClassName: manual
|
||||
# TODO: change hostPath (short.slc.ar/YkdtaD)
|
||||
hostPath:
|
||||
path: /tmp/minikube/postgres
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: postgres-pv-claim
|
||||
labels:
|
||||
app: api
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: manual
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: postgres-secrets
|
||||
type: Opaque
|
||||
data:
|
||||
username: dXNlcm5hbWU=
|
||||
password: cGFzc3dvcmQxMjM0
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: api-db
|
||||
labels:
|
||||
app: api
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: api
|
||||
tier: postgres
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: api
|
||||
tier: postgres
|
||||
spec:
|
||||
containers:
|
||||
- image: db:prod
|
||||
name: postgres
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secrets
|
||||
key: password
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
- name: POSTGRES_DB
|
||||
value: db
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secrets
|
||||
key: username
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
name: postgres
|
||||
volumeMounts:
|
||||
- name: postgres-pv-storage
|
||||
mountPath: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- name: postgres-pv-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: postgres-pv-claim
|
Loading…
Reference in New Issue