wrongmove/k8s/osrm-init-job.yaml
Viktor Barzin 7084c46f89
Add Kubernetes manifests for routing engines
Deployments and Services for osrm-foot (256-512MB), osrm-bicycle
(256-512MB), and OTP (1-2GB). Includes PVCs for data storage and an
init Job to download and pre-process Greater London OSM data.
2026-02-08 13:16:38 +00:00

64 lines
2.3 KiB
YAML

apiVersion: batch/v1
kind: Job
metadata:
name: osrm-init
spec:
backoffLimit: 3
template:
spec:
restartPolicy: OnFailure
containers:
- name: osrm-init
image: ghcr.io/project-osrm/osrm-backend:latest
command:
- /bin/bash
- -c
- |
set -euo pipefail
OSM_FILE="greater-london-latest.osm.pbf"
GEOFABRIK_URL="https://download.geofabrik.de/europe/great-britain/england/greater-london-latest.osm.pbf"
# Download OSM data if not present
if [ ! -f "/data/${OSM_FILE}" ]; then
echo "Downloading Greater London OSM extract..."
apt-get update -qq && apt-get install -qq -y curl
curl -L -o "/data/${OSM_FILE}" "${GEOFABRIK_URL}"
fi
# Process foot profile
if [ ! -f "/data/foot/greater-london-latest.osrm" ]; then
echo "Processing foot profile..."
mkdir -p /data/foot
cp "/data/${OSM_FILE}" "/data/foot/${OSM_FILE}"
osrm-extract -p /opt/foot.lua "/data/foot/${OSM_FILE}"
osrm-partition "/data/foot/greater-london-latest.osrm"
osrm-customize "/data/foot/greater-london-latest.osrm"
rm -f "/data/foot/${OSM_FILE}"
fi
# Process bicycle profile
if [ ! -f "/data/bicycle/greater-london-latest.osrm" ]; then
echo "Processing bicycle profile..."
mkdir -p /data/bicycle
cp "/data/${OSM_FILE}" "/data/bicycle/${OSM_FILE}"
osrm-extract -p /opt/bicycle.lua "/data/bicycle/${OSM_FILE}"
osrm-partition "/data/bicycle/greater-london-latest.osrm"
osrm-customize "/data/bicycle/greater-london-latest.osrm"
rm -f "/data/bicycle/${OSM_FILE}"
fi
echo "OSRM data initialization complete!"
volumeMounts:
- name: osrm-data
mountPath: /data
resources:
requests:
memory: "1Gi"
cpu: "500m"
limits:
memory: "2Gi"
cpu: "2000m"
volumes:
- name: osrm-data
persistentVolumeClaim:
claimName: osrm-data-pvc