Skip to content

Commit

Permalink
Add TM database
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Apr 26, 2024
1 parent ec665eb commit 30fec04
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 5 deletions.
10 changes: 5 additions & 5 deletions osm-seed/templates/tasking-manager-api/tm-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ spec:
{{- end }}
env:
- name: POSTGRES_HOST
value: {{ .Values.tmApi.env.POSTGRES_HOST }}
value: {{ .Release.Name }}-tm-db
- name: POSTGRES_DB
value: {{ .Values.tmApi.env.POSTGRES_DB }}
value: {{ .Values.tmDb.env.POSTGRES_DB }}
- name: POSTGRES_PASSWORD
value: {{ quote .Values.tmApi.env.POSTGRES_PASSWORD }}
value: {{ quote .Values.tmDb.env.POSTGRES_PASSWORD }}
- name: POSTGRES_USER
value: {{ .Values.tmApi.env.POSTGRES_USER }}
value: {{ .Values.tmDb.env.POSTGRES_USER }}
- name: POSTGRES_PORT
value: {{ .Values.tmApi.env.POSTGRES_PORT | quote }}
value: "5432"
- name: TM_DB
value: {{ printf "postgresql://%s:%s@%s/%s" .Values.tmApi.env.POSTGRES_USER .Values.tmApi.env.POSTGRES_PASSWORD .Values.tmApi.env.POSTGRES_HOST .Values.tmApi.env.POSTGRES_DB }}
- name: TM_ORG_NAME
Expand Down
85 changes: 85 additions & 0 deletions osm-seed/templates/tasking-manager-db/tm-db-pd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{{- if .Values.tmDb.enabled -}}
{{- if .Values.tmDb.persistenceDisk.enabled -}}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Release.Name }}-tm-db-pv
labels:
app: {{ template "osm-seed.name" . }}
component: tm-db-pd
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
############## Minikube ##############
{{- if eq .Values.cloudProvider "minikube" }}
storageClassName: local-storage
capacity:
storage: {{ .Values.tmDb.persistenceDisk.localVolumeSize }}
accessModes:
- ReadWriteOnce
hostPath:
path: {{ .Values.tmDb.persistenceDisk.localVolumeHostPath | quote }}
{{- end }}

############## AWS Provider ##############
{{- if eq .Values.cloudProvider "aws" }}
storageClassName: ""
capacity:
storage: {{ .Values.tmDb.persistenceDisk.AWS_ElasticBlockStore_size }}
accessModes:
- ReadWriteOnce
awsElasticBlockStore:
volumeID: {{ .Values.tmDb.persistenceDisk.AWS_ElasticBlockStore_volumeID }}
fsType: ext4
{{- end }}

############## GCP Provider ##############
{{- if eq .Values.cloudProvider "gcp" }}
storageClassName: ""
capacity:
storage: {{ .Values.tmDb.persistenceDisk.GCP_gcePersistentDisk_size }}
accessModes:
- ReadWriteOnce
gcePersistentDisk:
pdName: {{ .Values.tmDb.persistenceDisk.GCP_gcePersistentDisk_pdName }}
fsType: ext4
{{- end }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-tm-db-pv-claim
labels:
app: {{ template "osm-seed.name" . }}
component: db-pd
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
############## Minikube ##############
{{- if eq .Values.cloudProvider "minikube" }}
storageClassName: local-storage
{{- else }}
############## Other providers ##############
storageClassName: ""
{{- end }}
volumeName: {{ .Release.Name }}-tm-db-pv
accessModes:
- ReadWriteOnce
resources:
requests:
############# Minikube ##############
{{- if eq .Values.cloudProvider "minikube" }}
storage: {{ .Values.tmDb.persistenceDisk.localVolumeSize }}
{{- end }}

############## AWS Provider ##############
{{- if eq .Values.cloudProvider "aws" }}
storage: {{ .Values.tmDb.persistenceDisk.AWS_ElasticBlockStore_size }}
{{- end }}

############## GCP Provider ##############
{{- if eq .Values.cloudProvider "gcp" }}
storage: {{ .Values.tmDb.persistenceDisk.GCP_gcePersistentDisk_size }}
{{- end }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions osm-seed/templates/tasking-manager-db/tm-db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.tmDb.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-tm-db
labels:
app: {{ template "osm-seed.name" . }}
component: tm-db-service
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-tm-db
{{- end }}
101 changes: 101 additions & 0 deletions osm-seed/templates/tasking-manager-db/tm-db-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{{- if .Values.tmDb.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-tm-db
labels:
app: {{ template "osm-seed.name" . }}
component: db-tm-statefulset
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-tm-db
serviceName: {{ .Release.Name }}-tm-db
template:
metadata:
labels:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-tm-db
spec:
containers:
- name: {{ .Chart.Name }}-tm-db
image: "{{ .Values.tmDb.image.name }}:{{ .Values.tmDb.image.tag }}"
ports:
- name: postgres
containerPort: 5432
protocol: TCP
env:
- name: POSTGRES_HOST
value: {{ .Release.Name }}-tm-db
- name: POSTGRES_DB
value: {{ .Values.tmDb.env.POSTGRES_DB }}
- name: POSTGRES_PASSWORD
value: {{ quote .Values.tmDb.env.POSTGRES_PASSWORD }}
- name: POSTGRES_USER
value: {{ default "postgres" .Values.tmDb.env.POSTGRES_USER | quote }}
- name: PGUSER
value: {{ default "postgres" .Values.tmDb.env.POSTGRES_USER | quote }}
- name: PGDATA
value: {{ .Values.tmDb.persistenceDisk.mountPath }}
- name: POSTGRES_DB_MAX_CONNECTIONS
value: {{ default 100 .Values.tmDb.env.POSTGRES_DB_MAX_CONNECTIONS | quote }}
- name: POSTGRES_DB_SHARED_BUFFERS
value: {{ default "128MB" .Values.tmDb.env.POSTGRES_DB_SHARED_BUFFERS | quote }}
- name: POSTGRES_DB_WORK_MEM
value: {{ default "4MB" .Values.tmDb.env.POSTGRES_DB_WORK_MEM | quote }}
- name: POSTGRES_DB_MAINTENANCE_WORK_MEM
value: {{ default "64MB" .Values.tmDb.env.POSTGRES_DB_MAINTENANCE_WORK_MEM | quote }}
- name: POSTGRES_DB_EFFECTIVE_CACHE_SIZE
value: {{ default "4GB" .Values.tmDb.env.POSTGRES_DB_EFFECTIVE_CACHE_SIZE | quote }}
- name: POD_IP
valueFrom: { fieldRef: { fieldPath: status.podIP } }
livenessProbe:
exec:
command:
- sh
- -c
- exec pg_isready --host $POD_IP
initialDelaySeconds: 120
timeoutSeconds: 5
failureThreshold: 6
readinessProbe:
exec:
command:
- sh
- -c
- exec pg_isready --host $POD_IP
initialDelaySeconds: 5
timeoutSeconds: 3
periodSeconds: 5
volumeMounts:
- name: postgres-storage
mountPath: {{ .Values.tmDb.persistenceDisk.mountPath }}
subPath: {{ .Values.tmDb.persistenceDisk.subPath }}
{{- if .Values.tmDb.resources.enabled }}
resources:
requests:
memory: {{ .Values.tmDb.resources.requests.memory }}
cpu: {{ .Values.tmDb.resources.requests.cpu }}
limits:
memory: {{ .Values.tmDb.resources.limits.memory }}
cpu: {{ .Values.tmDb.resources.limits.cpu }}
{{- end }}
volumes:
- name: postgres-storage
{{- if .Values.tmDb.persistenceDisk.enabled }}
persistentVolumeClaim:
claimName: {{ .Release.Name }}-tm-db-pv-claim
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.tmDb.nodeSelector.enabled }}
nodeSelector:
{{ .Values.tmDb.nodeSelector.label_key }} : {{ .Values.tmDb.nodeSelector.label_value }}
{{- end }}
{{- end }}

0 comments on commit 30fec04

Please sign in to comment.