-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fb603e
commit 207ad5c
Showing
14 changed files
with
1,454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v2 | ||
name: navi-attractor | ||
description: Attractor Helm chart | ||
type: application | ||
keywords: | ||
- navi | ||
- attractor | ||
version: 0.1.0 | ||
appVersion: 7.27.1.2 | ||
dependencies: | ||
- name: generic-chart | ||
version: '*' | ||
repository: file://../generic-chart | ||
maintainers: | ||
- name: 2gis | ||
url: https://github.com/2gis | ||
email: [email protected] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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 }}{{ .path }} | ||
{{- end }} | ||
{{- end }} | ||
{{- else if contains "NodePort" .Values.service.grpc.type }} | ||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "generic-chart.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.grpc.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 "generic-chart.fullname" . }}' | ||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "generic-chart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") | ||
echo http://$SERVICE_IP:{{ .Values.service.grpc.port }} | ||
{{- else if contains "ClusterIP" .Values.service.grpc.type }} | ||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "generic-chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") | ||
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") | ||
echo "Visit http://127.0.0.1:8080 to use your application" | ||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT | ||
{{- end }} | ||
|
||
{{- if .Values.attractor.app_castle_host }} | ||
################################################################################# | ||
###### WARNING: `attractor.app_castle_host` has been deprecated! ##### | ||
###### We recommend using `attractor.castleUrl`. ##### | ||
################################################################################# | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
{{/* | ||
Distinguishable main container name | ||
Override generic-chart | ||
TODO: rewrite https://github.com/helm/helm/issues/11291 | ||
*/}} | ||
{{- define "generic-chart.containerName" -}} | ||
{{- if .Values.dataGroup.enabled }} | ||
{{- .Values.dataGroup.prefix }}-{{ .Chart.Name }} | ||
{{- else }} | ||
{{- .Chart.Name }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{- define "config.setCpuNumber" }} | ||
{{- $cpu_divider := 1 }} | ||
{{- $num_threads := 0 }} | ||
{{- $resources := regexSplit "m" (toString .Values.resources.limits.cpu) -1 }} | ||
{{- if eq (len $resources) 2 }} | ||
{{- $cpu_divider = 1000 }} | ||
{{- end }} | ||
{{- $cpu_value := index $resources 0 }} | ||
{{- $num_threads = ceil (divf $cpu_value $cpu_divider) }} | ||
{{- print $num_threads }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Renders a value or file that contains rules. | ||
Usage: | ||
{{ include "rules.renderRules" }} | ||
*/}} | ||
{{- define "rules.renderRules" -}} | ||
{{- $rules := list -}} | ||
{{- if ( and .Values.rules (kindIs "slice" .Values.rules )) -}} | ||
{{- $rules = .Values.rules -}} | ||
{{- end -}} | ||
{{ $rules | toPrettyJson | nindent 6 -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Check if value exists in rule routing section | ||
Usage: | ||
{{ include "rules.inRoutingSection" ( dict "routingValue" "<value>" "context" $) }} | ||
*/}} | ||
{{- define "rules.inRoutingSection" -}} | ||
{{- $found := false -}} | ||
{{- if $.context.Values.rules -}} | ||
{{- range $.context.Values.rules -}} | ||
{{- if eq .name $.context.Values.attractor.app_rule -}} | ||
{{- if (has $.routingValue .routing) -}} | ||
{{- $found = true -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- ternary "true" "" $found -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Check if value exists in rule queries section | ||
Usage: | ||
{{ include "rules.inQueriesSection" ( dict "queriesValue" "<value>" "context" $) }} | ||
*/}} | ||
{{- define "rules.inQueriesSection" -}} | ||
{{- $found := false -}} | ||
{{- if $.context.Values.rules -}} | ||
{{- range $.context.Values.rules -}} | ||
{{- if eq .name $.context.Values.attractor.app_rule -}} | ||
{{- if (has $.queriesValue .queries) -}} | ||
{{- $found = true -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- ternary "true" "" $found -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Set attractor_car parameter in server config section | ||
Usage: | ||
{{ include "config.setAttractorCar" $ }} | ||
*/}} | ||
{{- define "config.setAttractorCar" -}} | ||
{{- ternary | ||
$.Values.attractor.attractor.car | ||
(include "rules.inRoutingSection" (dict "routingValue" "driving" "context" $)) | ||
(hasKey $.Values.attractor.attractor "car") | ||
-}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Set attractor_pedestrian parameter in server config section | ||
Usage: | ||
{{ include "config.setAttractorPedestrian" $ }} | ||
*/}} | ||
{{- define "config.setAttractorPedestrian" -}} | ||
{{- ternary | ||
$.Values.attractor.attractor.pedestrian | ||
(or (include "rules.inRoutingSection" (dict "routingValue" "ctx" "context" $)) | ||
(include "rules.inRoutingSection" (dict "routingValue" "public_transport" "context" $)) | ||
(include "rules.inRoutingSection" (dict "routingValue" "pedestrian" "context" $))) | ||
(hasKey $.Values.attractor.attractor "pedestrian") | ||
-}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Set attractor_taxi parameter in server config section | ||
Usage: | ||
{{ include "config.setAttractorTaxi" $ }} | ||
*/}} | ||
{{- define "config.setAttractorTaxi" -}} | ||
{{- ternary | ||
$.Values.attractor.attractor.taxi | ||
(include "rules.inRoutingSection" (dict "routingValue" "taxi" "context" $)) | ||
(hasKey $.Values.attractor.attractor "taxi") | ||
-}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Set attractor_truck parameter in server config section | ||
Usage: | ||
{{ include "config.setAttractorTruck" $ }} | ||
*/}} | ||
{{- define "config.setAttractorTruck" -}} | ||
{{- ternary | ||
$.Values.attractor.attractor.truck | ||
(include "rules.inRoutingSection" (dict "routingValue" "truck" "context" $)) | ||
(hasKey $.Values.attractor.attractor "truck") | ||
-}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Set attractor_bicycle parameter in server config section | ||
Usage: | ||
{{ include "config.setAttractorBicycle" $ }} | ||
*/}} | ||
{{- define "config.setAttractorBicycle" -}} | ||
{{- ternary | ||
$.Values.attractor.attractor.bicycle | ||
(or (include "rules.inRoutingSection" (dict "routingValue" "bicycle" "context" $)) | ||
(include "rules.inRoutingSection" (dict "routingValue" "scooter" "context" $))) | ||
(or (hasKey $.Values.attractor.attractor "bicycle") (hasKey $.Values.attractor.attractor "scooter")) | ||
-}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Check if instance is running in truck mode | ||
Usage: | ||
{{ include "config.isTruck" $ }} | ||
*/}} | ||
{{- define "config.isTruck" -}} | ||
{{- $is_enabled_routing := ( eq "true" (include "rules.inRoutingSection" (dict "routingValue" "truck" "context" $))) -}} | ||
{{- ternary "true" "" $is_enabled_routing -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Check if instance is running in ctx mode | ||
Usage: | ||
{{ include "config.isCTX" $ }} | ||
*/}} | ||
{{- define "config.isCTX" -}} | ||
{{- $is_enabled_routing := ( or (eq "true" (include "rules.inRoutingSection" (dict "routingValue" "ctx" "context" $))) (eq "true" (include "rules.inRoutingSection" (dict "routingValue" "public_transport" "context" $)))) -}} | ||
{{- $is_enabled_query := ( or (eq "true" (include "rules.inQueriesSection" (dict "queriesValue" "ctx" "context" $))) (eq "true" (include "rules.inQueriesSection" (dict "queriesValue" "public_transport" "context" $)))) -}} | ||
{{- ternary "true" "" (or $is_enabled_routing $is_enabled_query) -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Check if instance is running in taxi mode | ||
Usage: | ||
{{ include "config.isTaxi" $ }} | ||
*/}} | ||
{{- define "config.isTaxi" -}} | ||
{{- $is_enabled_routing := ( eq "true" (include "rules.inRoutingSection" (dict "routingValue" "taxi" "context" $))) -}} | ||
{{- ternary "true" "" $is_enabled_routing -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Check if map matching is enabled | ||
Usage: | ||
{{ include "config.isMapMatching" $ }} | ||
*/}} | ||
{{- define "config.isMapMatching" -}} | ||
{{- include "rules.inQueriesSection" (dict "queriesValue" "map_matching" "context" $) -}} | ||
{{- end -}} | ||
|
||
{{/* vim: set filetype=mustache: */}} | ||
|
||
{{/* | ||
Set castle url | ||
If use frozenData return local path | ||
Usage: | ||
{{ include "config.setCastleUrl" $ }} | ||
*/}} | ||
{{- define "config.setCastleUrl" -}} | ||
{{- if .Values.frozenData.enabled -}} | ||
{{- printf "file://{LOCAL_PATH}" -}} | ||
{{- else if .Values.attractor.castleUrl -}} | ||
{{- printf .Values.attractor.castleUrl -}} | ||
{{- else if .Values.attractor.app_castle_host -}} | ||
{{- printf "http://%s" .Values.attractor.app_castle_host -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Set restriction url | ||
If rtr enabled return attractor.rtr.url, else return attractor.castleUrl | ||
Usage: | ||
{{ include "config.setRestrictionUrl" $ }} | ||
*/}} | ||
{{- define "config.setRestrictionUrl" -}} | ||
{{- if .Values.attractor.rtr.enabled -}} | ||
{{- printf .Values.attractor.rtr.url -}} | ||
{{- else -}} | ||
{{- printf (include "config.setCastleUrl" $) -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Set probe | ||
If mock enable then use http probe, else user grpc probe | ||
Usage: | ||
{{ include "navi-attractor.probe" . }} | ||
*/}} | ||
{{- define "navi-attractor.probe" -}} | ||
{{- if .Values.attractor.mock -}} | ||
httpGet: | ||
path: /about | ||
port: http | ||
{{- else -}} | ||
grpc: | ||
port: {{ .Values.attractor.grpcPort }} | ||
{{- end -}} | ||
{{- end -}} |
Oops, something went wrong.