Add kubernetes deployment support
This commit is contained in:
parent
73d9f2b95c
commit
fe8c807b97
4 changed files with 196 additions and 0 deletions
67
build/kubernetes/api-server-deployment.yaml
Normal file
67
build/kubernetes/api-server-deployment.yaml
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: api-server
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: api-server
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: api-server
|
||||||
|
spec:
|
||||||
|
initContainers:
|
||||||
|
- name: wait-for-psql
|
||||||
|
image: busybox
|
||||||
|
command: ['sh', '-c', 'until nc -z psql-service 5432; do echo waiting for postgres readiness; sleep 2; done;']
|
||||||
|
containers:
|
||||||
|
- name: api-server
|
||||||
|
image: registry.lab.divyam.dev/fastbin-api-server:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
env:
|
||||||
|
- name: DB_DATABASE
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_DATABASE
|
||||||
|
- name: DB_USERNAME
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_USERNAME
|
||||||
|
- name: DB_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_PASSWORD
|
||||||
|
- name: DB_HOST
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_HOST
|
||||||
|
- name: DB_PORT
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_PORT
|
||||||
|
- name: KEYGEN_HOST
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: KEYGEN_HOST
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: api-server-service
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 8080
|
||||||
|
selector:
|
||||||
|
app: api-server
|
||||||
|
type: LoadBalancer
|
||||||
11
build/kubernetes/example.configmap.yaml
Normal file
11
build/kubernetes/example.configmap.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: fastbin-config
|
||||||
|
data:
|
||||||
|
DB_DATABASE: "fastbin"
|
||||||
|
DB_USERNAME: "username"
|
||||||
|
DB_PASSWORD: "password"
|
||||||
|
DB_HOST: "psql-service"
|
||||||
|
DB_PORT: "5432"
|
||||||
|
KEYGEN_HOST: "keygen-service"
|
||||||
30
build/kubernetes/keygen-deployment.yaml
Normal file
30
build/kubernetes/keygen-deployment.yaml
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: keygen
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: keygen
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: keygen
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: keygen
|
||||||
|
image: registry.lab.divyam.dev/fastbin-keygen-service:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: keygen-service
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 8080
|
||||||
|
targetPort: 8080
|
||||||
|
selector:
|
||||||
|
app: keygen
|
||||||
88
build/kubernetes/postgres-deployment.yaml
Normal file
88
build/kubernetes/postgres-deployment.yaml
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: psql-pv
|
||||||
|
spec:
|
||||||
|
capacity:
|
||||||
|
storage: 5Gi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
hostPath:
|
||||||
|
path: /mnt/data/postgres
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: psql-volume-claim
|
||||||
|
labels:
|
||||||
|
type: local
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 2Gi
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: psql-bp
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: psql-bp
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: psql-bp
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: postgres:latest
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_DATABASE
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_USERNAME
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastbin-config
|
||||||
|
key: DB_PASSWORD
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /var/lib/postgresql/data
|
||||||
|
name: psql-storage
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- "-c"
|
||||||
|
- "pg_isready -U $POSTGRES_USER -d $POSTGRES_DB"
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 5
|
||||||
|
volumes:
|
||||||
|
- name: psql-storage
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: psql-volume-claim
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: psql-service
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 5432
|
||||||
|
targetPort: 5432
|
||||||
|
selector:
|
||||||
|
app: psql-bp
|
||||||
Loading…
Reference in a new issue