Add new infra architecture 6
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "nominatim.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "nominatim.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "nominatim.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "nominatim.labels" -}}
|
||||
helm.sh/chart: {{ include "nominatim.chart" . }}
|
||||
{{ include "nominatim.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "nominatim.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "nominatim.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/component: geocoding
|
||||
app.kubernetes.io/part-of: bakery-ia
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
ConfigMap name
|
||||
*/}}
|
||||
{{- define "nominatim.configMapName" -}}
|
||||
{{- printf "%s-config" (include "nominatim.fullname" .) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Service name
|
||||
*/}}
|
||||
{{- define "nominatim.serviceName" -}}
|
||||
{{- default (printf "%s-service" (include "nominatim.fullname" .)) .Values.service.name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Data PVC name
|
||||
*/}}
|
||||
{{- define "nominatim.dataPvcName" -}}
|
||||
{{- printf "%s-data" (include "nominatim.fullname" .) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Flatnode PVC name
|
||||
*/}}
|
||||
{{- define "nominatim.flatnodePvcName" -}}
|
||||
{{- printf "%s-flatnode" (include "nominatim.fullname" .) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Init job name
|
||||
*/}}
|
||||
{{- define "nominatim.initJobName" -}}
|
||||
{{- printf "%s-init" (include "nominatim.fullname" .) -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "nominatim.labels" . | nindent 4 }}
|
||||
data:
|
||||
NOMINATIM_PBF_URL: {{ .Values.config.pbfUrl | quote }}
|
||||
NOMINATIM_REPLICATION_URL: {{ .Values.config.replicationUrl | quote }}
|
||||
NOMINATIM_IMPORT_STYLE: {{ .Values.config.importStyle | quote }}
|
||||
NOMINATIM_THREADS: {{ .Values.config.threads | quote }}
|
||||
NOMINATIM_FLATNODE_FILE: {{ .Values.config.flatnodeFile | quote }}
|
||||
@@ -0,0 +1,80 @@
|
||||
{{- if .Values.initJob.enabled }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: {{ include "nominatim.initJobName" . }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "nominatim.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: data-init
|
||||
spec:
|
||||
ttlSecondsAfterFinished: {{ .Values.initJob.ttlSecondsAfterFinished }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ include "nominatim.initJobName" . }}
|
||||
app.kubernetes.io/component: data-init
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: nominatim-import
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
echo "Checking if Nominatim database is already initialized..."
|
||||
|
||||
if psql -lqt | cut -d \| -f 1 | grep -qw nominatim; then
|
||||
echo "Nominatim database already exists. Skipping import."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Downloading Spain OSM data..."
|
||||
wget -O /tmp/spain-latest.osm.pbf "${NOMINATIM_PBF_URL}"
|
||||
|
||||
echo "Importing OSM data into Nominatim (this may take 30-60 minutes)..."
|
||||
nominatim import --osm-file /tmp/spain-latest.osm.pbf
|
||||
|
||||
echo "Building search indices..."
|
||||
nominatim refresh --website --importance
|
||||
|
||||
echo "Nominatim initialization complete!"
|
||||
volumeMounts:
|
||||
- name: nominatim-data
|
||||
mountPath: /var/lib/postgresql
|
||||
- name: nominatim-flatnode
|
||||
mountPath: /nominatim-flatnode
|
||||
env:
|
||||
- name: NOMINATIM_PBF_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_PBF_URL
|
||||
- name: NOMINATIM_IMPORT_STYLE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_IMPORT_STYLE
|
||||
- name: NOMINATIM_THREADS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_THREADS
|
||||
- name: NOMINATIM_FLATNODE_FILE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_FLATNODE_FILE
|
||||
resources:
|
||||
{{- toYaml .Values.initJob.resources | nindent 10 }}
|
||||
volumes:
|
||||
- name: nominatim-data
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "nominatim.dataPvcName" . }}
|
||||
- name: nominatim-flatnode
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "nominatim.flatnodePvcName" . }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,37 @@
|
||||
{{- if .Values.persistence.data.enabled }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "nominatim.dataPvcName" . }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "nominatim.labels" . | nindent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.persistence.data.accessMode }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.data.size }}
|
||||
{{- if .Values.persistence.data.storageClassName }}
|
||||
storageClassName: {{ .Values.persistence.data.storageClassName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if .Values.persistence.flatnode.enabled }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "nominatim.flatnodePvcName" . }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "nominatim.labels" . | nindent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.persistence.flatnode.accessMode }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.flatnode.size }}
|
||||
{{- if .Values.persistence.flatnode.storageClassName }}
|
||||
storageClassName: {{ .Values.persistence.flatnode.storageClassName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "nominatim.serviceName" . }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "nominatim.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
selector:
|
||||
{{- include "nominatim.selectorLabels" . | nindent 4 }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.service.port }}
|
||||
protocol: TCP
|
||||
name: http
|
||||
type: {{ .Values.service.type }}
|
||||
@@ -0,0 +1,113 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ include "nominatim.fullname" . }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "nominatim.labels" . | nindent 4 }}
|
||||
spec:
|
||||
serviceName: {{ include "nominatim.serviceName" . }}
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "nominatim.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "nominatim.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: nominatim
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- containerPort: {{ .Values.service.port }}
|
||||
name: http
|
||||
volumeMounts:
|
||||
- name: nominatim-data
|
||||
mountPath: /var/lib/postgresql
|
||||
- name: nominatim-flatnode
|
||||
mountPath: /nominatim-flatnode
|
||||
env:
|
||||
- name: NOMINATIM_PBF_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_PBF_URL
|
||||
- name: NOMINATIM_REPLICATION_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_REPLICATION_URL
|
||||
- name: NOMINATIM_IMPORT_STYLE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_IMPORT_STYLE
|
||||
- name: NOMINATIM_THREADS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_THREADS
|
||||
- name: NOMINATIM_FLATNODE_FILE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "nominatim.configMapName" . }}
|
||||
key: NOMINATIM_FLATNODE_FILE
|
||||
{{- range $key, $value := .Values.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 10 }}
|
||||
{{- if .Values.probes.liveness.enabled }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.probes.liveness.path }}
|
||||
port: {{ .Values.probes.liveness.port }}
|
||||
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
|
||||
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
|
||||
{{- end }}
|
||||
{{- if .Values.probes.readiness.enabled }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: {{ .Values.probes.readiness.path }}
|
||||
port: {{ .Values.probes.readiness.port }}
|
||||
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
|
||||
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: nominatim-data
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "nominatim.dataPvcName" . }}
|
||||
- name: nominatim-flatnode
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "nominatim.flatnodePvcName" . }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user