Skip to content

Commit

Permalink
feat(manifests): Add a postgresql deployment manifest in third-party …
Browse files Browse the repository at this point in the history
…folder (#9581)
  • Loading branch information
zijianjoy authored Jul 12, 2023
1 parent 213dd5a commit 49bfda9
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
15 changes: 15 additions & 0 deletions manifests/kustomize/third-party/postgresql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Build PostgreSQL yaml

```bash
# In this folder of manifests/kustomize/third-party/postgresql
rm -rf build
mkdir buidl
kustomize build ./base -o build
```

## Deploy PostgreSQL container

```bash
# In this folder of manifests/kustomize/third-party/postgresql
kubectl apply -f build
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- pg-deployment.yaml
- pg-pvc.yaml
- pg-service.yaml
- pg-secret.yaml
- pg-serviceaccount.yaml
42 changes: 42 additions & 0 deletions manifests/kustomize/third-party/postgresql/base/pg-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-deployment
labels:
app: postgres
spec:
replicas: 2
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
serviceAccountName: postgresql
containers:
- image: postgres:14.7-alpine3.17
name: postgres
env:
- name: POSTGRES_DB
value: postgres
- name: POSTGRES_USER
value: user
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: root_password
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
ports:
- containerPort: 5432
name: postgres
volumeMounts:
- name: postgres-stateful-data
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres-stateful-data
persistentVolumeClaim:
claimName: postgres-pvc
12 changes: 12 additions & 0 deletions manifests/kustomize/third-party/postgresql/base/pg-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
labels:
app: postgres
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: postgres-secret
type: Opaque
data:
root_password: password
12 changes: 12 additions & 0 deletions manifests/kustomize/third-party/postgresql/base/pg-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: postgres-service
labels:
app: postgres
spec:
ports:
- port: 5432
type: LoadBalancer
selector:
app: postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: postgresql

0 comments on commit 49bfda9

Please sign in to comment.