Skip to content

Commit

Permalink
Add osmcha database helm template
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Sep 6, 2023
1 parent 56bcee6 commit 12b389f
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 0 deletions.
85 changes: 85 additions & 0 deletions osm-seed/templates/osmcha-db/osmcha-db-pd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{{- if .Values.osmchaDb.enabled -}}
{{- if .Values.osmchaDb.persistenceDisk.enabled -}}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Release.Name }}-osmcha-db-pv
labels:
app: {{ template "osm-seed.name" . }}
component: osmcha-db-pd
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
############## Minikube ##############
{{- if eq .Values.cloudProvider "minikube" }}
storageClassName: local-storage
capacity:
storage: {{ .Values.osmchaDb.persistenceDisk.localVolumeSize }}
accessModes:
- ReadWriteOnce
hostPath:
path: {{ .Values.osmchaDb.persistenceDisk.localVolumeHostPath | quote }}
{{- end }}

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

############## GCP Provider ##############
{{- if eq .Values.cloudProvider "gcp" }}
storageClassName: ""
capacity:
storage: {{ .Values.osmchaDb.persistenceDisk.GCP_gcePersistentDisk_size }}
accessModes:
- ReadWriteOnce
gcePersistentDisk:
pdName: {{ .Values.osmchaDb.persistenceDisk.GCP_gcePersistentDisk_pdName }}
fsType: ext4
{{- end }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-osmcha-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 }}-osmcha-db-pv
accessModes:
- ReadWriteOnce
resources:
requests:
############# Minikube ##############
{{- if eq .Values.cloudProvider "minikube" }}
storage: {{ .Values.osmchaDb.persistenceDisk.localVolumeSize }}
{{- end }}

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

############## GCP Provider ##############
{{- if eq .Values.cloudProvider "gcp" }}
storage: {{ .Values.osmchaDb.persistenceDisk.GCP_gcePersistentDisk_size }}
{{- end }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions osm-seed/templates/osmcha-db/osmcha-db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.osmchaDb.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-osmcha-db
labels:
app: {{ template "osm-seed.name" . }}
component: osmcha-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 }}-osmcha-db
{{- end }}
101 changes: 101 additions & 0 deletions osm-seed/templates/osmcha-db/osmcha-db-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{{- if .Values.osmchaDb.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-osmcha-db
labels:
app: {{ template "osm-seed.name" . }}
component: db-tiler-statefulset
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-osmcha-db
serviceName: {{ .Release.Name }}-osmcha-db
template:
metadata:
labels:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-osmcha-db
spec:
containers:
- name: {{ .Chart.Name }}-osmcha-db
image: "{{ .Values.osmchaDb.image.name }}:{{ .Values.osmchaDb.image.tag }}"
ports:
- name: postgres
containerPort: 5432
protocol: TCP
env:
- name: POSTGRES_HOST
value: {{ .Release.Name }}-osmcha-db
- name: POSTGRES_DB
value: {{ .Values.osmchaDb.env.POSTGRES_DB }}
- name: POSTGRES_PASSWORD
value: {{ quote .Values.osmchaDb.env.POSTGRES_PASSWORD }}
- name: POSTGRES_USER
value: {{ default "postgres" .Values.osmchaDb.env.POSTGRES_USER | quote }}
- name: PGUSER
value: {{ default "postgres" .Values.osmchaDb.env.POSTGRES_USER | quote }}
- name: PGDATA
value: {{ .Values.osmchaDb.persistenceDisk.mountPath }}
- name: POSTGRES_DB_MAX_CONNECTIONS
value: {{ default 100 .Values.osmchaDb.env.POSTGRES_DB_MAX_CONNECTIONS | quote }}
- name: POSTGRES_DB_SHARED_BUFFERS
value: {{ default "128MB" .Values.osmchaDb.env.POSTGRES_DB_SHARED_BUFFERS | quote }}
- name: POSTGRES_DB_WORK_MEM
value: {{ default "4MB" .Values.osmchaDb.env.POSTGRES_DB_WORK_MEM | quote }}
- name: POSTGRES_DB_MAINTENANCE_WORK_MEM
value: {{ default "64MB" .Values.osmchaDb.env.POSTGRES_DB_MAINTENANCE_WORK_MEM | quote }}
- name: POSTGRES_DB_EFFECTIVE_CACHE_SIZE
value: {{ default "4GB" .Values.osmchaDb.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.osmchaDb.persistenceDisk.mountPath }}
subPath: {{ .Values.osmchaDb.persistenceDisk.subPath }}
{{- if .Values.osmchaDb.resources.enabled }}
resources:
requests:
memory: {{ .Values.osmchaDb.resources.requests.memory }}
cpu: {{ .Values.osmchaDb.resources.requests.cpu }}
limits:
memory: {{ .Values.osmchaDb.resources.limits.memory }}
cpu: {{ .Values.osmchaDb.resources.limits.cpu }}
{{- end }}
volumes:
- name: postgres-storage
{{- if .Values.osmchaDb.persistenceDisk.enabled }}
persistentVolumeClaim:
claimName: {{ .Release.Name }}-osmcha-db-pv-claim
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.osmchaDb.nodeSelector.enabled }}
nodeSelector:
{{ .Values.osmchaDb.nodeSelector.label_key }} : {{ .Values.osmchaDb.nodeSelector.label_value }}
{{- end }}
{{- end }}

0 comments on commit 12b389f

Please sign in to comment.