add pg
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Simple_Not 2023-12-14 19:27:10 +10:00
parent 2c03254dc0
commit 0f455c144d
3 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
labels:
app: postgres
type: Opaque
data:
postgres-root-username: cm9vdA==
postgres-root-password: bXlwYXNzd29yZA==
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-configmap
labels:
app: postgres
data:
postgres-dbname: mydb

View File

@ -0,0 +1,29 @@
---
apiVersion: v1
kind: Namespace
metadata:
labels:
name: pg
name: pg
---
#### https://blog.devgenius.io/how-to-deploy-postgresql-db-server-and-pgadmin-in-kubernetes-a-how-to-guide-57952b4e29a8
# echo -n '<secret>' | base64
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
labels:
app: postgres
type: Opaque
data:
postgres-root-username: YWRtaW4=
postgres-root-password: YWRtaW5p
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-configmap
labels:
app: postgres
data:
postgres-dbname: mainbase

View File

@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
namespace: pg
spec:
selector:
matchLabels:
app: postgres
replicas: 1
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:latest
imagePullPolicy: "IfNotPresent"
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-root-username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-root-password
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
name: postgres-configmap
key: postgres-dbname
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pv-claim
---
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv-volume
labels:
type: local
app: postgres
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/data"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-pv-claim
labels:
app: postgres
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgres
labels:
app: postgres
spec:
ports:
- name: postgres
port: 5432
nodePort: 30432
type: NodePort
selector:
app: postgres