diff --git a/osm-seed/templates/osmcha-db/osmcha-db-pd.yaml b/osm-seed/templates/osmcha-db/osmcha-db-pd.yaml new file mode 100644 index 00000000..a3a25320 --- /dev/null +++ b/osm-seed/templates/osmcha-db/osmcha-db-pd.yaml @@ -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 }} \ No newline at end of file diff --git a/osm-seed/templates/osmcha-db/osmcha-db-service.yaml b/osm-seed/templates/osmcha-db/osmcha-db-service.yaml new file mode 100644 index 00000000..4ce6b3a7 --- /dev/null +++ b/osm-seed/templates/osmcha-db/osmcha-db-service.yaml @@ -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 }} \ No newline at end of file diff --git a/osm-seed/templates/osmcha-db/osmcha-db-statefulset.yaml b/osm-seed/templates/osmcha-db/osmcha-db-statefulset.yaml new file mode 100644 index 00000000..e206778a --- /dev/null +++ b/osm-seed/templates/osmcha-db/osmcha-db-statefulset.yaml @@ -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 }}