add helm charts

This commit is contained in:
Ybehrooz
2025-11-09 13:22:40 +03:30
parent 282c3e52d0
commit 38e4d749ad
1352 changed files with 190457 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -0,0 +1,10 @@
apiVersion: v1
appVersion: 5.22.0
description: OSRM - Open Source Routing Machine
keywords:
- osrm
kubeVersion: '>= 1.19.0-0'
name: osrm
sources:
- https://github.com/Project-OSRM/osrm-backend
version: 0.6.0

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
ensure_dependency() {
if ! which "$1" &>/dev/null ; then
echo "$1 not found"
exit 1
fi
}
ensure_dependency gsutil
ensure_dependency tar
version="{{ .Values.map.gcs.version | default "unversioned" }}"
uri="{{ .Values.map.gcs.uri }}"
file="{{ base .Values.map.gcs.uri }}"
mkdir -p "/data/maps/${version}"
cd "/data/maps/${version}"
if [ ! -r downloaded.lock ]; then
gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS"
gsutil -m cp "${uri}" .
tar xzvf "${file}"
rm "${file}"
# Rename all files so we have predictable argument name in statefulset.
shopt -s nullglob
for f in *.osrm*
do
echo "Rename $f -> map.osrm${f#*.osrm*}"
mv "$f" "map.osrm${f#*.osrm*}"
done
touch downloaded.lock
fi
echo "Done!"
exit 0

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
ensure_dependency() {
if ! which "$1" &>/dev/null ; then
echo "$1 not found"
exit 1
fi
}
ensure_dependency wget
ensure_dependency md5sum
version="{{ .Values.map.http.version | default "unversioned" }}"
uri="{{ .Values.map.http.uri }}"
file="{{ base .Values.map.http.uri }}"
checkMD5="{{ if .Values.map.http.checkMD5 }}1{{ end }}"
mkdir -p "/data/maps/${version}"
cd "/data/maps/${version}"
if [ ! -r downloaded.lock ]; then
wget "${uri}"
if [ -n "${checkMD5}" ]; then
wget "${uri}.md5"
md5sum -c "${file}.md5"
rm "${file}.md5"
fi
# Rename the file so we have predictable argument name in statefulset.
echo "Rename ${file} -> map.osm.pbf"
mv "${file}" "map.osm.pbf"
touch downloaded.lock
fi
echo "Done!"
exit 0

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
ensure_dependency() {
if ! which "$1" &>/dev/null ; then
echo "$1 not found"
exit 1
fi
}
ensure_dependency osrm-extract
ensure_dependency osrm-partition
ensure_dependency osrm-customize
version="{{ .Values.map.http.version | default "unversioned" }}"
file_pbf="map.osm.pbf"
file_osrm="map.osrm"
profile="{{ .Values.map.profile | default "car" }}"
cd "/data/maps/${version}"
if [ ! -r extracted.lock ]; then
osrm-extract -p /opt/${profile}.lua "${file_pbf}"
osrm-partition "${file_osrm}"
osrm-customize "${file_osrm}"
touch extracted.lock
fi
echo "Done!"
exit 0

View File

@@ -0,0 +1,32 @@
image:
repository: 172.16.16.2:30516/osrm/osrm-backend
tag: v5.22.0
pullPolicy: IfNotPresent
map:
enabled: true
# Profile to be used for routing (one of "car", "bicycle", "foot")
profile: car
source: http
http:
version: ""
uri: https://blog.tavanasys.app/iran-latest.osm.pbf
resources:
requests:
cpu: 1000m
memory: 1200Mi
limits:
cpu: 1000m
memory: 1200Mi
ingress:
enabled: false
annotations:
kubernetes.io/ingress.class: traefik
hosts:
- host: osm.tavanasys.app
nodeSelector:
node.name: worker-1

View File

@@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "osrm.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "osrm.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "osrm.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "osrm.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}

View File

@@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "osrm.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "osrm.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "osrm.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "osrm.labels" -}}
app.kubernetes.io/name: {{ include "osrm.name" . }}
helm.sh/chart: {{ include "osrm.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

View File

@@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "osrm.fullname" . }}-files
labels: {{ include "osrm.labels" . | nindent 4 }}
data:
{{- range $key, $filepath := .Values.configTemplatedFiles }}
{{ $key }}: |- {{ ( tpl ($.Files.Get $filepath) $ ) | nindent 4 }}
{{- end }}
{{- if and .Values.map.enabled ( eq "http" .Values.map.source ) }}
{{- range $key, $filepath := .Values.map.http.configTemplatedFiles }}
{{ $key }}: |- {{ ( tpl ($.Files.Get $filepath) $ ) | nindent 4 }}
{{- end }}
{{- end }}
{{- if and .Values.map.enabled ( eq "gcs" .Values.map.source ) }}
{{- range $key, $filepath := .Values.map.gcs.configTemplatedFiles }}
{{ $key }}: |- {{ ( tpl ($.Files.Get $filepath) $ ) | nindent 4 }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,43 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "osrm.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "osrm.labels" . | nindent 4 }}
{{- with .Values.ingress.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
pathType: ImplementationSpecific
backend:
service:
name: {{ $fullName }}
port:
name: http
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "osrm.fullname" . }}-headless
labels:
{{ include "osrm.labels" . | indent 4 }}
spec:
type: {{ .Values.service.type }}
clusterIP: None
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "osrm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "osrm.fullname" . }}
labels:
{{ include "osrm.labels" . | indent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "osrm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@@ -0,0 +1,115 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "osrm.fullname" . }}
labels:
{{ include "osrm.labels" . | indent 4 }}
spec:
serviceName: {{ include "osrm.fullname" . }}-headless
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "osrm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "osrm.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
{{- with .Values.initContainersTpl }}
{{- ( tpl . $ ) | nindent 8 }}
{{- end }}
{{- with .Values.initContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if and .Values.map.enabled ( eq "http" .Values.map.source ) }}
{{- ( tpl .Values.map.http.initContainersTpl $ ) | nindent 8 }}
{{- end }}
{{- if and .Values.map.enabled ( eq "gcs" .Values.map.source ) }}
{{- ( tpl .Values.map.gcs.initContainersTpl $ ) | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- osrm-routed
- --algorithm
- mld
{{- if and .Values.map.enabled ( eq "http" .Values.map.source ) }}
- /data/maps/{{ .Values.map.http.version | default "unversioned" }}/map.osrm
{{- end }}
{{- if and .Values.map.enabled ( eq "gcs" .Values.map.source ) }}
- /data/maps/{{ .Values.map.gcs.version | default "unversioned" }}/map.osrm
{{- end }}
{{- if .Values.extraArgs }}
{{- toYaml .Values.extraArgs | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 5000
protocol: TCP
{{- with .Values.livenessProbe }}
livenessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe: {{ toYaml . | nindent 12 }}
{{- end }}
resources: {{ toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: maps
mountPath: /data/maps
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config-files
configMap:
name: {{ include "osrm.fullname" . }}-files
defaultMode: 0755
{{- if not .Values.persistence.enabled }}
- name: maps
emptyDir: {}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.extraVolumesTpl }}
{{- ( tpl . $ ) | nindent 8 }}
{{- end }}
{{- if and .Values.map.enabled ( eq "gcs" .Values.map.source ) }}
{{- ( tpl .Values.map.gcs.extraVolumesTpl $ ) | nindent 8 }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: maps
spec:
accessModes:
{{- toYaml .Values.persistence.accessModes | nindent 10 }}
{{- if .Values.persistence.storageClassName }}
{{- if (eq "-" .Values.persistence.storageClassName) }}
storageClassName: ""
{{- else }}
storageClassName: {{ .Values.persistence.storageClassName }}
{{- end }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- end }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "osrm.fullname" . }}-test-connection"
labels:
{{ include "osrm.labels" . | indent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "osrm.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

View File

@@ -0,0 +1,254 @@
# 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 }}