{"id":15650130,"url":"https://github.com/peter-evans/osrm-backend-k8s","last_synced_at":"2025-07-02T03:31:51.110Z","repository":{"id":14103333,"uuid":"76004407","full_name":"peter-evans/osrm-backend-k8s","owner":"peter-evans","description":"Open Source Routing Machine (OSRM) osrm-backend for Kubernetes on Google Container Engine (GKE).","archived":false,"fork":false,"pushed_at":"2022-03-11T16:51:10.000Z","size":69,"stargazers_count":38,"open_issues_count":3,"forks_count":22,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-30T17:26:56.981Z","etag":null,"topics":["canary-deployment","docker-image","gke","google-cloud","kubernetes","osrm","osrm-backend","pbf"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/peterevans/osrm-backend-k8s/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter-evans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-09T05:23:57.000Z","updated_at":"2024-10-07T17:48:13.000Z","dependencies_parsed_at":"2022-08-07T07:16:18.216Z","dependency_job_id":null,"html_url":"https://github.com/peter-evans/osrm-backend-k8s","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/peter-evans/osrm-backend-k8s","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fosrm-backend-k8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fosrm-backend-k8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fosrm-backend-k8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fosrm-backend-k8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-evans","download_url":"https://codeload.github.com/peter-evans/osrm-backend-k8s/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fosrm-backend-k8s/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263069064,"owners_count":23408892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["canary-deployment","docker-image","gke","google-cloud","kubernetes","osrm","osrm-backend","pbf"],"created_at":"2024-10-03T12:33:27.275Z","updated_at":"2025-07-02T03:31:51.092Z","avatar_url":"https://github.com/peter-evans.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# osrm-backend for Kubernetes\n[![](https://images.microbadger.com/badges/image/peterevans/osrm-backend-k8s.svg)](https://microbadger.com/images/peterevans/osrm-backend-k8s)\n[![CircleCI](https://circleci.com/gh/peter-evans/osrm-backend-k8s/tree/master.svg?style=svg)](https://circleci.com/gh/peter-evans/osrm-backend-k8s/tree/master)\n\nOpen Source Routing Machine (OSRM) [osrm-backend](https://github.com/Project-OSRM/osrm-backend) for Kubernetes on Google Container Engine (GKE).\n\nThis Docker image and sample Kubernetes configuration files are one solution to persisting [osrm-backend](https://github.com/Project-OSRM/osrm-backend) data and providing immutable deployments.\n\nIf you are looking for a more general purpose docker image, see [osrm-backend-docker](https://github.com/peter-evans/osrm-backend-docker).\n\n## Supported tags and respective `Dockerfile` links\n\n- [`1.21.1`, `1.21`, `latest`  (*1.21/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master)\n- [`1.20.0`, `1.20` (*1.20/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.20)\n- [`1.19.0`, `1.19` (*1.19/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.19)\n- [`1.18.0`, `1.18` (*1.18/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.18)\n- [`1.17.1`, `1.17` (*1.17/Dockerfile*)](https://github.com/peter-evans/osrm-backend-k8s/tree/master/archive/1.17)\n\nFor earlier versions see [releases](https://github.com/peter-evans/osrm-backend-k8s/releases) and the available [tags on Docker Hub](https://hub.docker.com/r/peterevans/osrm-backend-k8s/tags/).\n\n## Usage\nThe Docker image can be run standalone without Kubernetes:\n\n```bash\ndocker run -d -p 5000:5000 \\\n-e OSRM_PBF_URL='http://download.geofabrik.de/asia/maldives-latest.osm.pbf' \\\n--name osrm-backend peterevans/osrm-backend-k8s:latest\n```\nTail the logs to verify the graph has been built and osrm-backend is serving requests:\n```\ndocker logs -f \u003cCONTAINER ID\u003e\n```\nThen point your web browser to [http://localhost:5000/](http://localhost:5000/)\n\n## Kubernetes Deployment\nThe [osrm-backend](https://github.com/Project-OSRM/osrm-backend) builds a data graph from a PBF file. This process can take over an hour for a single country.\nIf a pod in a deployment fails, waiting over an hour for a new pod to start could lead to loss of service.\n\nThe sample Kubernetes files provide a means of persisting a data graph in storage that is used by all pods in the deployment. \nEach pod having their own copy of the graph is desirable in order to have no single point of failure.\n\n#### Explanation\nInitial deployment flow:\n\n1. Create a secret that contains the JSON key of a Google Cloud IAM service account that has read/write permissions to Google Storage.\n2. Deploy the canary deployment.\n3. Wait for the graph to be built and uploaded to Google Storage.\n4. Delete the canary deployment.\n5. Deploy the stable track deployment.\n\nTo update the live deployment with a new graph:\n\n1. Deploy the canary deployment alongside the stable track deployment.\n2. Wait for the graph to be built and uploaded to Google Storage.\n3. Delete the canary deployment.\n4. Perform a rolling update on the stable track deployment to create pods using the new graph.\n\n#### Creating the secret\n\n```bash\n# Google Cloud project ID and service account details\nPROJECT_ID=my-project\nSA_NAME=my-service-account\nSA_DISPLAY_NAME=\"My Service Account\"\nSA_EMAIL=$SA_NAME@$PROJECT_ID.iam.gserviceaccount.com\nKEY_FILE=service-account-key.json\n\n# Create a new GCP IAM service account\ngcloud iam service-accounts create $SA_NAME --display-name \"$SA_DISPLAY_NAME\"\n\n# Create and download a new key for the service account\ngcloud iam service-accounts keys create $KEY_FILE --iam-account $SA_EMAIL\n\n# Give the service account the \"Storage Object Viewer\" and \"Storage Object Creator\" IAM roles\ngcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SA_EMAIL --role roles/storage.objectViewer\ngcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SA_EMAIL --role roles/storage.objectCreator\n\n# Create a secret containing the service account key file\nkubectl create secret generic osrm-storage-secret --from-file=$KEY_FILE\n```  \n\n#### Deployment configuration\nBefore deploying, edit the `env` section of both the canary deployment and stable track deployment.\n\n- `OSRM_MODE` - `CREATE` from PBF data, or `RESTORE` from Google Storage.\n- `OSRM_PBF_URL` - URL to PBF data file. (Optional when `OSRM_MODE=RESTORE`)\n- `OSRM_GRAPH_PROFILE` - Graph profile; `car`,`bicycle` or `foot`. (Optional when `OSRM_MODE=RESTORE`)\n- `OSRM_DATA_LABEL` - A meaningful and **unique** label for the data. e.g. maldives-car-20161209\n- `OSRM_SA_KEY_PATH` - Path to the JSON service account key. This needs to match the `mountPath` of the volume mounted secret.\n- `OSRM_PROJECT_ID` - Google Cloud project ID.\n- `OSRM_GS_BUCKET` - Google Storage bucket.\n\n## License\n\nMIT License - see the [LICENSE](LICENSE) file for details","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fosrm-backend-k8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-evans%2Fosrm-backend-k8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fosrm-backend-k8s/lists"}