From 57aa50683f32f0e860fa3357456b279becdeeb98 Mon Sep 17 00:00:00 2001 From: Bob Ong Date: Fri, 5 Jul 2024 19:54:28 +0800 Subject: [PATCH] [deployment] add Digitalocean k8s Deploy Config for postgresql --- .../elasticsearch-deployment.yaml | 3 +- .../kibana-deployment.yaml | 0 .../postgresql-deployment.yaml | 90 +++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) rename kube/{elasticsearch => base-components}/elasticsearch-deployment.yaml (98%) rename kube/{elasticsearch => base-components}/kibana-deployment.yaml (100%) create mode 100644 kube/base-components/postgresql-deployment.yaml diff --git a/kube/elasticsearch/elasticsearch-deployment.yaml b/kube/base-components/elasticsearch-deployment.yaml similarity index 98% rename from kube/elasticsearch/elasticsearch-deployment.yaml rename to kube/base-components/elasticsearch-deployment.yaml index 30c1add..25bd918 100644 --- a/kube/elasticsearch/elasticsearch-deployment.yaml +++ b/kube/base-components/elasticsearch-deployment.yaml @@ -58,7 +58,7 @@ spec: - name: es-data persistentVolumeClaim: claimName: es-pvc - - name: elasticsearch-config + - name: elasticsearch-,.ujv config configMap: name: elasticsearch-config --- @@ -97,7 +97,6 @@ spec: resources: requests: storage: 80Gi - --- # Elasticsearch Service apiVersion: v1 diff --git a/kube/elasticsearch/kibana-deployment.yaml b/kube/base-components/kibana-deployment.yaml similarity index 100% rename from kube/elasticsearch/kibana-deployment.yaml rename to kube/base-components/kibana-deployment.yaml diff --git a/kube/base-components/postgresql-deployment.yaml b/kube/base-components/postgresql-deployment.yaml new file mode 100644 index 0000000..25c9e9f --- /dev/null +++ b/kube/base-components/postgresql-deployment.yaml @@ -0,0 +1,90 @@ +# Persistent Volume +apiVersion: v1 +kind: PersistentVolume +metadata: + name: postgres-pv +spec: + capacity: + storage: 80Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: do-block-storage + hostPath: + path: /mnt/data/postgres +--- +# Persistent Volume Claim +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: postgres-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 80Gi + volumeName: postgres-pv + storageClassName: do-block-storage +--- +# Postgresql deployment +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres +spec: + replicas: 1 + selector: + matchLabels: + app: postgres + template: + metadata: + labels: + app: postgres + spec: + containers: + - name: postgres + image: postgres:13 + ports: + - containerPort: 5432 + env: + - name: POSTGRES_DB + value: starcoin + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: postgresql + key: username + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: postgresql + key: password + resources: + requests: + memory: "4Gi" + cpu: "2" + limits: + memory: "4Gi" + cpu: "2" + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: postgres-storage + volumes: + - name: postgres-storage + persistentVolumeClaim: + claimName: postgres-pvc +--- +# Service +apiVersion: v1 +kind: Service +metadata: + name: postgres-service +spec: + type: ClusterIP + ports: + - port: 5432 + targetPort: 5432 + selector: + app: postgres +