Giter Site home page Giter Site logo

ultach / osrm-backend-k8s Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peter-evans/osrm-backend-k8s

0.0 0.0 0.0 69 KB

Open Source Routing Machine (OSRM) osrm-backend for Kubernetes on Google Container Engine (GKE).

Home Page: https://hub.docker.com/r/peterevans/osrm-backend-k8s/

License: MIT License

Shell 60.10% Dockerfile 39.90%

osrm-backend-k8s's Introduction

osrm-backend for Kubernetes

CircleCI

Open Source Routing Machine (OSRM) osrm-backend for Kubernetes on Google Container Engine (GKE).

This Docker image and sample Kubernetes configuration files are one solution to persisting osrm-backend data and providing immutable deployments.

If you are looking for a more general purpose docker image, see osrm-backend-docker.

Supported tags and respective Dockerfile links

For earlier versions see releases and the available tags on Docker Hub.

Usage

The Docker image can be run standalone without Kubernetes:

docker run -d -p 5000:5000 \
-e OSRM_PBF_URL='http://download.geofabrik.de/asia/maldives-latest.osm.pbf' \
--name osrm-backend peterevans/osrm-backend-k8s:latest

Tail the logs to verify the graph has been built and osrm-backend is serving requests:

docker logs -f <CONTAINER ID>

Then point your web browser to http://localhost:5000/

Kubernetes Deployment

The osrm-backend builds a data graph from a PBF file. This process can take over an hour for a single country. If a pod in a deployment fails, waiting over an hour for a new pod to start could lead to loss of service.

The sample Kubernetes files provide a means of persisting a data graph in storage that is used by all pods in the deployment. Each pod having their own copy of the graph is desirable in order to have no single point of failure.

Explanation

Initial deployment flow:

  1. Create a secret that contains the JSON key of a Google Cloud IAM service account that has read/write permissions to Google Storage.
  2. Deploy the canary deployment.
  3. Wait for the graph to be built and uploaded to Google Storage.
  4. Delete the canary deployment.
  5. Deploy the stable track deployment.

To update the live deployment with a new graph:

  1. Deploy the canary deployment alongside the stable track deployment.
  2. Wait for the graph to be built and uploaded to Google Storage.
  3. Delete the canary deployment.
  4. Perform a rolling update on the stable track deployment to create pods using the new graph.

Creating the secret

# Google Cloud project ID and service account details
PROJECT_ID=my-project
SA_NAME=my-service-account
SA_DISPLAY_NAME="My Service Account"
SA_EMAIL=$SA_NAME@$PROJECT_ID.iam.gserviceaccount.com
KEY_FILE=service-account-key.json

# Create a new GCP IAM service account
gcloud iam service-accounts create $SA_NAME --display-name "$SA_DISPLAY_NAME"

# Create and download a new key for the service account
gcloud iam service-accounts keys create $KEY_FILE --iam-account $SA_EMAIL

# Give the service account the "Storage Object Viewer" and "Storage Object Creator" IAM roles
gcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SA_EMAIL --role roles/storage.objectViewer
gcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SA_EMAIL --role roles/storage.objectCreator

# Create a secret containing the service account key file
kubectl create secret generic osrm-storage-secret --from-file=$KEY_FILE

Deployment configuration

Before deploying, edit the env section of both the canary deployment and stable track deployment.

  • OSRM_MODE - CREATE from PBF data, or RESTORE from Google Storage.
  • OSRM_PBF_URL - URL to PBF data file. (Optional when OSRM_MODE=RESTORE)
  • OSRM_GRAPH_PROFILE - Graph profile; car,bicycle or foot. (Optional when OSRM_MODE=RESTORE)
  • OSRM_DATA_LABEL - A meaningful and unique label for the data. e.g. maldives-car-20161209
  • OSRM_SA_KEY_PATH - Path to the JSON service account key. This needs to match the mountPath of the volume mounted secret.
  • OSRM_PROJECT_ID - Google Cloud project ID.
  • OSRM_GS_BUCKET - Google Storage bucket.

License

MIT License - see the LICENSE file for details

osrm-backend-k8s's People

Contributors

peter-evans avatar grigorievnick avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.