mirror of
https://github.com/Dannecron/netology-devops.git
synced 2025-12-25 15:22:37 +03:00
121 lines
2.7 KiB
YAML
121 lines
2.7 KiB
YAML
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: postgres-config
|
|
labels:
|
|
app: postgres
|
|
data:
|
|
POSTGRES_DB: news
|
|
POSTGRES_USER: db_user
|
|
POSTGRES_PASSWORD: db_passwd
|
|
PGDATA: /var/lib/postgresql/data
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolume
|
|
metadata:
|
|
name: postgres-pv-volume # Sets PV's name
|
|
labels:
|
|
type: local # Sets PV's type to local
|
|
app: postgres
|
|
spec:
|
|
storageClassName: manual
|
|
capacity:
|
|
storage: 1Gi # Sets PV Volume
|
|
accessModes:
|
|
- ReadWriteMany
|
|
hostPath:
|
|
path: "/mnt/pgsql_data"
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: postgres-pv-claim # Sets name of PVC
|
|
labels:
|
|
app: postgres
|
|
spec:
|
|
storageClassName: manual
|
|
accessModes:
|
|
- ReadWriteMany # Sets read and write access
|
|
resources:
|
|
requests:
|
|
storage: 1Gi # Sets volume size
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
labels:
|
|
app: testing-app
|
|
db-kind: postgresql
|
|
name: testing-db
|
|
namespace: default
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
db-kind: postgresql
|
|
serviceName: postgres
|
|
replicas: 1
|
|
podManagementPolicy: "Parallel"
|
|
updateStrategy:
|
|
type: "RollingUpdate"
|
|
template:
|
|
metadata:
|
|
labels:
|
|
db-kind: postgresql
|
|
spec:
|
|
terminationGracePeriodSeconds: 60
|
|
containers:
|
|
- name: postgres
|
|
image: postgres:13-alpine # Sets Image
|
|
imagePullPolicy: "IfNotPresent"
|
|
ports:
|
|
- containerPort: 5432 # Exposes container port
|
|
envFrom:
|
|
- configMapRef:
|
|
name: postgres-config
|
|
volumeMounts:
|
|
- mountPath: /var/lib/postgresql/data
|
|
name: postgredb
|
|
volumes:
|
|
- name: postgredb
|
|
persistentVolumeClaim:
|
|
claimName: postgres-pv-claim
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
labels:
|
|
app: testing-app
|
|
name: testing-app
|
|
namespace: default
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: testing-app
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: testing-app
|
|
spec:
|
|
terminationGracePeriodSeconds: 30
|
|
containers:
|
|
- image: dannecron/netology-devops-k8s-app:frontend-latest
|
|
imagePullPolicy: Always
|
|
name: netology-frontend
|
|
volumeMounts:
|
|
- mountPath: "/static"
|
|
name: test-shared-volume
|
|
- image: dannecron/netology-devops-k8s-app:backend-latest
|
|
imagePullPolicy: Always
|
|
name: netology-backend
|
|
env:
|
|
- name: DATABASE_URL
|
|
value: "postgres://db_user:db_passwd@postgres:5432/news"
|
|
volumeMounts:
|
|
- mountPath: "/static"
|
|
name: test-shared-volume
|
|
volumes:
|
|
- name: test-shared-volume
|
|
emptyDir: {}
|