mirror of
https://github.com/furyhawk/cloudy.git
synced 2026-05-23 08:25:57 +00:00
Refactor PostgreSQL deployment and service configuration
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: postgres-deployment
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: postgres
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: postgres
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: postgres:13
|
||||||
|
volumeMounts:
|
||||||
|
- name: postgres-storage
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- containerPort: 5432
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
value: "mysecretpassword"
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
value: "myuser"
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
value: "mydb"
|
||||||
|
- name: PGDATA
|
||||||
|
value: "/var/lib/postgresql/data"
|
||||||
|
volumes:
|
||||||
|
- name: postgres-storage
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: postgres-pvc
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: postgres-pvc
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 5Gi
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: postgres-service
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: postgres
|
||||||
|
ports:
|
||||||
|
- name: postgres
|
||||||
|
port: 5432
|
||||||
|
targetPort: 5432
|
||||||
|
type: ClusterIP
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
# postgresql
|
# postgresql
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
create ns postgresql-svc
|
kubectl create ns postgresql-svc
|
||||||
kubectl config set-context --current --namespace=postgresql-svc
|
kubectl config set-context --current --namespace=postgresql-svc
|
||||||
k apply -f ps-configmap.yaml
|
kubectl apply -f ps-configmap.yaml
|
||||||
k apply -f ps-storage.yaml
|
kubectl apply -f ps-storage.yaml
|
||||||
k get pvc
|
kubectl get pvc
|
||||||
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
|
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
|
||||||
postgres-pv-claim Bound postgres-pv-volume 2Gi RWX manual <unset> 6s
|
postgres-pv-claim Bound postgres-pv-volume 2Gi RWX manual <unset> 6s
|
||||||
|
|
||||||
@@ -30,4 +30,10 @@ kubectl exec -it [pod-name] -- psql -h localhost -U admin --password -p [port]
|
|||||||
kubectl exec -it postgres-84bd99bf45-sf6xq -- psql -h localhost -U admin --password -p 5432 postgresdb
|
kubectl exec -it postgres-84bd99bf45-sf6xq -- psql -h localhost -U admin --password -p 5432 postgresdb
|
||||||
|
|
||||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||||
|
helm repo update
|
||||||
helm install postgresql bitnami/postgresql --create-namespace -n 'postgresql-svc' --set persistence.existingClaim=postgresql-pv-claim --set volumePermissions.enabled=true
|
helm install postgresql bitnami/postgresql --create-namespace -n 'postgresql-svc' --set persistence.existingClaim=postgresql-pv-claim --set volumePermissions.enabled=true
|
||||||
|
|
||||||
|
kubectl delete -f ps-deployment.yaml
|
||||||
|
kubectl delete -f ps-service.yaml
|
||||||
|
kubectl delete -f ps-configmap.yaml
|
||||||
|
kubectl delete -f ps-storage.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user