-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[chart/navi-attractor] chart syncup #519
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
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.33.0.5 | ||
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.
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 }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
{{/* | ||
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 -}} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Разное число пустых строк между блоками. Где-то одна, где-то две. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. привёл |
||
{{/* | ||
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 -}} | ||
|
||
{{/* | ||
Set castle url | ||
Usage: | ||
{{ include "config.setCastleUrl" $ }} | ||
*/}} | ||
{{- define "config.setCastleUrl" -}} | ||
{{- 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 -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Объявление нового шаблона с именем из чужого домена.
При чтении чарта не понятно где её искать. В этом чарте или в чарте
generic-chart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, ровно это и написано в комментарии выше