# Default values for osrm.

# Chart name override. Defaults to chart name, i.e. "osrm".
nameOverride: ""
# App name override. Defaults to name built upon release name and chart name.
fullnameOverride: ""

# How many replicas of the statefulset to deploy.
replicaCount: 1

image:
  repository: osrm/osrm-backend
  tag: v5.22.0
  pullPolicy: IfNotPresent

imagePullSecrets: []

# Init containers to add to the pod in statefulset.
# This field is plain yaml that is inserted as-is.
initContainers: []

# Init containers to add to the pod in statefulset.
# This field is a template string that is passed to tpl func before insertion.
initContainersTpl: ""

# Extra arguments to pass to the osrm binary.
extraArgs: []

# Extra volumes to add to the pod.
# This field is plain yaml that is inserted as-is.
extraVolumes: []
#  # Example:
#  - name: something
#    configMap:
#      name: some-volume

# Extra volumes to add to the pod.
# This field is a template string that is passed to tpl func before insertion.
extraVolumesTpl: ""
#  # Example:
#  - name: scripts
#    configMap:
#      name: {{ include "osrm.fullname" . }}-scripts

# Files that are stored in configmap and can be accessed from containers/initContainers.
# This field is a map, where keys are configmap key names and values are file paths relative to chart root.
# File contents is passed to tpl func before insertion.
configTemplatedFiles: {}
#  # Example:
#  download.sh: "files/download.sh.tpl"
#  extract.sh: "files/extract.sh.tpl"

# Kubernetes Service object configuration.
service:
  type: ClusterIP
  port: 80

# Kubernetes Ingress object configuration.
ingress:
  enabled: false
  extraLabels: {}
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  className: ""
  hosts:
    - host: chart-example.local
      paths: []
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

resources: {}
  # requests:
  #   cpu: 200m
  #   memory: 256Mi
  # limits:
  #   cpu: 1000m
  #   memory: 512Mi

nodeSelector: {}

tolerations: []

affinity: {}

livenessProbe: null
#  httpGet:
#    path: /route/v1/driving/13.388860,52.517037;13.385983,52.496891
#    port: http

readinessProbe: null
#  httpGet:
#    path: /route/v1/driving/13.388860,52.517037;13.385983,52.496891
#    port: http

# Persistence allows you to store downloaded maps in the persistent store.
# Enable & configure this if you don't want to download the same maps each
# time you deploy.
persistence:
  enabled: false

  # If defined, storageClassName: <storageClass>.
  # If set to "-", storageClassName: "", which disables dynamic provisioning.
  # If set to null (the default), no storageClassName spec is set, choosing
  # 'standard' storage class available with the default provisioner
  # (gcd-pd on GKE, hostpath on minikube, etc).
  # More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
  storageClassName: null

  accessModes:
    - ReadWriteOnce
  size: 1Gi

# map configuration enables out-of-the-box map downloading from various sources and required preparations
# (extraction, etc.).
#
# If you do not want to use default downloading mechanics of this chart, you can disable this.
map:
  # Whether the map downloading feature is enabled.
  # If you want to manage maps yourself (e.g. mount pre-existing PV with maps to the pod),
  # set this to false.
  enabled: true

  # Profile to be used for routing (one of "car", "bicycle", "foot")
  profile: car

  # Configures what source provider to use to download map.
  # Supported providers:
  # - http
  # - gcs
  source: http

  # http section is used when chart is configured to download maps from an HTTP endpoint.
  #
  # HTTP mode is designed to download .pbf file from the source, extract it and run other preparation commands.
  # Each replica in the stateful set executes these actions on its own volume and map.
  #
  # HTTP mode supports versioning. It downloads/extracts the map once for each version and creates corresponding
  # lock-files "downloaded.lock", "extracted.lock". You can remove file to re-do an action, e.g. remove
  # "downloaded.txt" to re-download the map.
  # There is no logic to distinguish versions, so no version can be considered "old". If you want to remove old
  # versions from the volume, you have to do it manually.
  http:
    # An arbitrary version for the map at the uri. Any versioning scheme can be used. This field is used only to create
    # corresponding directory within the volume and to decide whether to download a new version of the map.
    #
    # Example: "20200226-1"
    version: ""

    # HTTP(S) uri to download map.
    #
    # Some sources/mirrors you may use:
    # - http://download.geofabrik.de
    # - https://download.openstreetmap.fr/extracts/
    uri: https://download.openstreetmap.fr/extracts/europe/monaco.osm.pbf

    # Set to "true" when the .md5 file is available for checksum.
    checkMD5: false

    # http mode files for config map.
    # See top-level 'configTemplatedFiles' for documentation.
    configTemplatedFiles:
      download.sh: "files/http-download.sh.tpl"
      extract.sh: "files/http-extract.sh.tpl"

    # http mode init containers.
    # See tol-level 'initContainersTpl' for documentation.
    initContainersTpl: |-
      - name: map-downloader
        image: 172.16.16.2:30516/bash:5
        imagePullPolicy: IfNotPresent
        command:
          - /scripts/download.sh
        volumeMounts:
          - name: config-files
            mountPath: /scripts
          - name: maps
            mountPath: /data/maps
      - name: map-extractor
        image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        command:
          - /scripts/extract.sh
        volumeMounts:
          - name: config-files
            mountPath: /scripts
          - name: maps
            mountPath: /data/maps

  # gcs section is used when chart is configured to download maps from Google Cloud Storage bucket.
  #
  # gcs mode is designed to do download already prepared map files in the form of tgz archive.
  # Each replica in the stateful set downloads its own copy of map.
  #
  # gcs mode supports versioning. It downloads the map once for each version, and creates "ready.lock" file.
  # If you want to re-download the map of already downloaded version on the next pod start, remove this file.
  # There is no logic to distinguish versions, so no version can be considered "old". If you want to remove old
  # versions from the volume, you have to do it manually.
  gcs:
    # An arbitrary version for the map at the uri. Any versioning scheme can be used. This field is used only to create
    # corresponding directory within the volume and to decide whether to download a new version of the map.
    #
    # Example: "20200226-1"
    version: ""

    # Google Cloud Storage URI to download map archive from.
    #
    # Example: "gs://example-osrm-maps/20200226-1/map.tar.gz"
    uri: ""

    # To download from private gcs bucket you need google application credentials.
    # This section allows configuring it via an externally created secret.
    googleApplicationCredentials:
      enabled: true
      secretName: osrm-google-application-credentials
      secretKey: credentials.json

    # gcs mode files for config map.
    # See top-level 'configTemplatedFiles' for documentation.
    configTemplatedFiles:
      download.sh: "files/gcs-download-prepared.sh.tpl"

    # gcs mode init containers.
    # See tol-level 'initContainersTpl' for documentation.
    initContainersTpl: |-
      - name: map-downloader
        image: gcr.io/google.com/cloudsdktool/cloud-sdk:282.0.0-alpine
        imagePullPolicy: IfNotPresent
        command:
          - /scripts/download.sh
        {{- if .Values.map.gcs.googleApplicationCredentials.enabled }}
        env:
          - name: GOOGLE_APPLICATION_CREDENTIALS
            value: /var/run/secrets/osrm/google-application-credentials/{{ .Values.map.gcs.googleApplicationCredentials.secretKey }}
        {{- end }}
        volumeMounts:
          - name: config-files
            mountPath: /scripts
          - name: maps
            mountPath: /data/maps
          {{- if .Values.map.gcs.googleApplicationCredentials.enabled }}
          - name: google-application-credentials
            mountPath: /var/run/secrets/osrm/google-application-credentials
            readOnly: true
          {{- end }}

    # gcs mode extra volumes.
    # See tol-level 'extraVolumesTpl' for documentation.
    extraVolumesTpl: |-
      - name: google-application-credentials
        secret:
          secretName: {{ .Values.map.gcs.googleApplicationCredentials.secretName }}
