Skip to content

Commit

Permalink
Update postgres k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
vectornguyen76 committed Nov 27, 2023
1 parent 5d4ed64 commit e17e7cc
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 31 deletions.
12 changes: 6 additions & 6 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,30 @@ Instructions to install the AWS EBS CSI driver in the production environment.

1. **Apply Postgres Configuration for Local**
```
kubectl apply -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml,postgres-pv.yaml
kubectl apply -f postgres-pvc-local.yaml,postgres-statefulset.yaml,postgres-service.yaml
```
Set `storageClassName: standard` in `postgres-pvc.yaml` for local deployment.
Set `storageClassName: standard` in `postgres-statefulset.yaml` for local deployment.

#### EKS Installation

1. **Apply Postgres Configuration for EKS**
```
kubectl apply -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml
kubectl apply -f postgres-pvc-eks.yaml,postgres-statefulset.yaml,postgres-service.yaml
```
Set `storageClassName: gp3` in `postgres-pvc.yaml` for EKS deployment.
Set `storageClassName: "ebs-sc"` in `postgres-statefulset.yaml` for EKS deployment.

#### Local Uninstallation

1. **Remove Postgres in Local**
```
kubectl delete -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml,postgres-pv.yaml
kubectl delete -f postgres-pvc-local.yaml,postgres-statefulset.yaml,postgres-service.yaml
```

#### EKS Uninstallation

1. **Remove Postgres in EKS**
```
kubectl delete -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml
kubectl delete -f postgres-pvc-eks.yaml,postgres-statefulset.yaml,postgres-service.yaml
```

### Deploy Backend
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/image-search-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ spec:
- name: QDRANT_URL
value: "http://qdrant-db.default:6334"
- name: TRITON_SERVER_URL
value: "search-engine-triton-inference-server.default"
value: "search-engine-serving-triton-inference-server.default:8001"
ports:
- containerPort: 7000
21 changes: 21 additions & 0 deletions kubernetes/postgres-pvc-eks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: ebs-sc
provisioner: ebs.csi.aws.com
parameters:
type: gp3
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: ebs-sc
resources:
requests:
storage: 2Gi
12 changes: 12 additions & 0 deletions kubernetes/postgres-pv.yaml → kubernetes/postgres-pvc-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ spec:
hostPath:
path: "/mnt/data/postgres-data" # directory on the host node
type: DirectoryOrCreate
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
requests:
storage: 1Gi
12 changes: 0 additions & 12 deletions kubernetes/postgres-pvc.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: postgres-deployment
labels:
app: postgres
name: postgres
spec:
serviceName: postgres
replicas: 1
selector:
matchLabels:
Expand All @@ -24,17 +23,19 @@ spec:
value: db_user
- name: POSTGRES_PASSWORD
value: db_password
# valueFrom:
# secretKeyRef:
# name: postgresql-secret
# key: password
ports:
- containerPort: 5432
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
subPath: postgres
volumes:
- name: postgres-storage
persistentVolumeClaim:
claimName: postgres-pvc
volumeClaimTemplates:
- metadata:
name: postgres-storage
spec:
accessModes: ["ReadWriteOnce"]
# Remove or adjust storageClassName according to your local setup
storageClassName: "ebs-sc"
resources:
requests:
storage: 2Gi

0 comments on commit e17e7cc

Please sign in to comment.