gis-ops / docker-valhalla

This is our flexible Docker repository for the Valhalla routing engine
MIT License
233 stars 69 forks source link

Deploying to K8s #76

Closed conor-nsurely closed 1 year ago

conor-nsurely commented 1 year ago

Hey guys, just found this project.

Are there any template k8s deployments/config for Valhalla? Had a look around online but can't find anything.

Thanks!

nilsnolde commented 1 year ago

Not that I’m aware of, sorry. But feel free to post back anything you come up with yourself in the discussions section:)

samvanemelen commented 1 year ago

It is by far perfect, but this is the deployment I am using. On creation, each pod will download pre-generated tiles and the valhalla config json file (this is only feasible if your area is not too large). As I understood, the valhalla container can use multiple cpu cores of a node, so I found that setting the cpu request to 0.7 makes sure only one pod runs per node.

There are most likely better ways to do this, but maybe this can be a starting point, I am also curious how this can be improved 👍

apiVersion: apps/v1
kind: Deployment
metadata:
  name: valhalla-deployment
  labels:
    app: valhalla
spec:
  replicas: 10
  selector:
    matchLabels:
      app: valhalla
  template:
    metadata:
      labels:
        app: valhalla
    spec:
      volumes:
      - name: shared-dir
        emptyDir: {}
      containers:
      - name: valhalla
        image: gisops/valhalla:latest
        env:
        - name: tile_urls
          value: "url/to/custom/tiles.tar url/to/valhalla.json"
        ports:
        - containerPort: 8002
          protocol: TCP
        volumeMounts:
        - name: shared-dir
          mountPath: /custom_files
        resources:
          requests:
            cpu: 0.7 # Claim 70% so no other pod can be started on the same node
nilsnolde commented 1 year ago

Did you have a look at this project?

https://github.com/valhalla/valhalla/discussions/3802

samvanemelen commented 1 year ago

Did you have a look at this project?

valhalla/valhalla#3802

I hadn't. This deployment was made before the operator was released. But I will see if I can get that to work with Digital Ocean. The operator might be a better starting point :)