diff --git a/charts/navi-attractor/Chart.yaml b/charts/navi-attractor/Chart.yaml new file mode 100644 index 000000000..18f48f700 --- /dev/null +++ b/charts/navi-attractor/Chart.yaml @@ -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: on-premise@2gis.com diff --git a/charts/navi-attractor/README.md b/charts/navi-attractor/README.md new file mode 100644 index 000000000..1a1ea1ee6 --- /dev/null +++ b/charts/navi-attractor/README.md @@ -0,0 +1,200 @@ +# Attractor Helm Chart + +## Description + +Данный helm-чарт предназначен для установки экземпляра Attractor, который позволяет обслуживать запросы, исходя из файла *rules.conf* + +Файл *rules.conf* повторяет содержимое аналогичного файла из navi-back. +Attractor не имеет смысла без сервиса navi-back. + + +## Values + +### Docker Registry settings + +| Name | Description | Value | +| --------------------- | --------------------------------------------------------------------------------------- | ----- | +| `dgctlDockerRegistry` | Docker Registry endpoint where On-Premise services' images reside. Format: `host:port`. | `""` | + +### Common settings + +| Name | Description | Value | +| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----- | +| `replicaCount` | A replica count for the pod. | `1` | +| `revisionHistoryLimit` | Number of replica sets to keep for deployment rollbacks | `1` | +| `imagePullSecrets` | Kubernetes image pull secrets. | `[]` | +| `nameOverride` | Base name to use in all the Kubernetes entities deployed by this chart. | `""` | +| `fullnameOverride` | Base fullname to use in all the Kubernetes entities deployed by this chart. | `""` | +| `podAnnotations` | Kubernetes [pod annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` | +| `podSecurityContext` | Kubernetes [pod security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/). | `{}` | +| `securityContext` | Kubernetes [security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/). | `{}` | +| `nodeSelector` | Kubernetes [node selectors](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector). | `{}` | +| `tolerations` | Kubernetes [tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) settings. | `[]` | +| `affinity` | Kubernetes pod [affinity settings](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity). | `{}` | +| `labels` | Custom labels to set to Deployment resource. | `{}` | +| `preStopDelay` | Delay in seconds before terminating container. | `5` | +| `terminationGracePeriodSeconds` | Maximum time allowed for graceful shutdown. | `60` | + +### Container image settings + +| Name | Description | Value | +| ------------------ | ----------- | ---------------------------- | +| `image.repository` | Repository | `2gis-on-premise/attractord` | +| `image.pullPolicy` | Pull Policy | `IfNotPresent` | +| `image.tag` | Tag | `7.27.1.2` | + +### Service account settings + +| Name | Description | Value | +| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------- | +| `serviceAccount.create` | Specifies whether a service account should be created. | `false` | +| `serviceAccount.annotations` | Annotations to add to the service account. | `{}` | +| `serviceAccount.name` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template. | `""` | + +### Service settings + +| Name | Description | Value | +| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------- | +| `service.labels` | Kubernetes [service labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). | `{}` | +| `service.annotations` | Kubernetes [service annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` | +| `service.http.port` | Service HTTP port. | `80` | +| `service.http.type` | Kubernetes [service type](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types). | `ClusterIP` | +| `service.http.clusterIP` | Controls Service cluster IP allocation. Cannot be changed after resource creation. | `""` | +| `service.http.labels` | Kubernetes [service labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). | `{}` | +| `service.http.annotations` | Kubernetes [service annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` | +| `service.grpc.port` | Service GRPC port. | `50051` | +| `service.grpc.type` | Kubernetes [service type](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types). | `ClusterIP` | +| `service.grpc.clusterIP` | Controls Service cluster IP allocation. Cannot be changed after resource creation. | `None` | +| `service.grpc.labels` | Kubernetes [service labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). | `{}` | +| `service.grpc.annotations` | Kubernetes [service annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` | + +### Kubernetes [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) settings + +| Name | Description | Value | +| ----------------------- | -------------------------------------- | --------------------- | +| `ingress.enabled` | If Ingress is enabled for the service. | `false` | +| `ingress.hosts[0].host` | Hostname for the Ingress service. | `navi-attractor.host` | + +### Limits + +| Name | Description | Value | +| --------------------------- | ------------------------------------------- | ----------- | +| `resources` | Container resources requirements structure. | `{}` | +| `resources.requests.cpu` | CPU request, recommended value `1000m`. | `undefined` | +| `resources.requests.memory` | Memory request, recommended value `2Gi`. | `undefined` | +| `resources.limits.cpu` | CPU limit, recommended value `3000m`. | `undefined` | +| `resources.limits.memory` | Memory limit, recommended value `8Gi`. | `undefined` | + +### Kubernetes [Horizontal Pod Autoscaling](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) settings + +| Name | Description | Value | +| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `hpa.enabled` | If HPA is enabled for the service. | `false` | +| `hpa.minReplicas` | Lower limit for the number of replicas to which the autoscaler can scale down. | `1` | +| `hpa.maxReplicas` | Upper limit for the number of replicas to which the autoscaler can scale up. | `100` | +| `hpa.scaleDown` | Scale-down settings structure | `""` | +| `hpa.scaleUp` | Scale-up settings structure | `""` | +| `hpa.targetCPUUtilizationPercentage` | Target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified the default autoscaling policy will be used. | `80` | +| `hpa.targetMemoryUtilizationPercentage` | Target average memory utilization (represented as a percentage of requested memory) over all the pods; if not specified the default autoscaling policy will be used. | `""` | + +### Kubernetes [Vertical Pod Autoscaling](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/README.md) settings + +| Name | Description | Value | +| ----------------------- | ------------------------------------------------------------------------------------------------------------ | ------- | +| `vpa.enabled` | If VPA is enabled for the service. | `false` | +| `vpa.updateMode` | VPA [update mode](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler#quick-start). | `Auto` | +| `vpa.minAllowed.cpu` | Lower limit for the number of CPUs to which the autoscaler can scale down. | | +| `vpa.minAllowed.memory` | Lower limit for the RAM size to which the autoscaler can scale down. | | +| `vpa.maxAllowed.cpu` | Upper limit for the number of CPUs to which the autoscaler can scale up. | | +| `vpa.maxAllowed.memory` | Upper limit for the RAM size to which the autoscaler can scale up. | | + +### Kubernetes [Pod Disruption Budget](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-budgets) settings + +| Name | Description | Value | +| -------------------- | ---------------------------------------------------- | ------- | +| `pdb.enabled` | If PDB is enabled for the service. | `false` | +| `pdb.minAvailable` | How many pods must be available after the eviction. | `""` | +| `pdb.maxUnavailable` | How many pods can be unavailable after the eviction. | `1` | + +### Navi-Attractor application settings + +| Name | Description | Value | +| --------------------------------- | ------------------------------------------------------------------- | ----------------- | +| `attractor.appPort` | Container port for HTTP interface | `8080` | +| `attractor.handlersNumber` | Total number of HTTP/GRPC handlers. | `20` | +| `attractor.maxProcessTime` | Maximum processing time limit in minutes. | `20` | +| `attractor.responseTimelimit` | Maximum response time limit in minutes. | `120` | +| `attractor.requestTimeout` | Maximum request time limit in minutes. | `120` | +| `attractor.dump.result` | Dump results in logs. | `true` | +| `attractor.dump.query` | Dump queries in logs. | `true` | +| `attractor.dump.answer` | Dump answers in logs. | `false` | +| `attractor.logLevel` | Logging level, one of: Verbose, Info, Warning, Error, Fatal. | `Info` | +| `attractor.logMessageField` | Field name in logs for messages data. | `custom.navi_msg` | +| `attractor.grpcPort` | Container port for gRPC interface | `50051` | +| `attractor.indexFilename` | Name of the index file on Castle | `index.json.zip` | +| `attractor.citiesFilename` | Name of the cities file on Castle | `cities.conf.zip` | +| `attractor.indices` | List of dynamic indices kill switches. | | +| `attractor.overrideConfig` | Complete config override. For test purposes only. | `""` | +| `attractor.rtr.enabled` | Enable real time restrictions. | `false` | +| `attractor.rtr.url` | URL real time restrictions server. | `http://rtr` | +| `attractor.rtr.updatePeriod` | Update period from real time restrictions server. | `60` | +| `attractor.mock` | If mock service being deployed. For test purposes only. | `false` | +| `attractor.tilesMetricsThreshold` | The value at which we send tiles metrics (used for internal tests). | `0` | + +### Kafka settings for interacting with Distance Matrix Async Service + +| Name | Description | Value | +| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ---------------- | +| `kafka.enabled` | If the Kafka is enabled | `false` | +| `kafka.groupId` | Navi-Attractor service group identifier | `navi_attractor` | +| `kafka.handlersNumber` | Number of Kafka handlers | `2` | +| `kafka.properties` | Properties as supported by librdkafka. Refer to inline comments for details | | +| `kafka.fileProperties` | As kafka.properties, but kept in a file, which passed to application as a filename. Refer to inline comments for details | `{}` | +| `kafka.distanceMatrix` | **Settings for interacting with Distance Matrix Async service** | | +| `kafka.distanceMatrix.taskTopic` | Name of the topic for receiving new tasks from Distance Matrix Async API | `task_topic` | +| `kafka.distanceMatrix.cancelTopic` | Name of the topic for canceling or receiving information about finished tasks | `cancel_topic` | +| `kafka.distanceMatrix.statusTopic` | Name of the topic for receiving task status information | `status_topic` | +| `kafka.distanceMatrix.updateTaskStatusPeriodSec` | Update period for task statuses | `120` | +| `kafka.distanceMatrix.messageExpiredPeriodSec` | Update period for task cancellations | `3600` | +| `kafka.distanceMatrix.requestDownloadTimeoutSec` | Timeout for downloading request data | `20` | +| `kafka.distanceMatrix.responseUploadTimeoutSec` | Timeout for uploading response data | `40` | + +### S3-compatible storage settings for interacting with Distance Matrix Async Service + +| Name | Description | Value | +| -------------- | -------------------------------------------- | ------- | +| `s3.enabled` | if S3 storage is enabled | `false` | +| `s3.host` | S3 endpoint | `""` | +| `s3.bucket` | S3 bucket name | `""` | +| `s3.accessKey` | S3 access key for accessing the bucket | `""` | +| `s3.secretKey` | S3 secret key for accessing the bucket | `""` | +| `s3.suffix` | String to be prepended to file name in reply | `""` | + +### Back-end and attractor group properties. Leave with defaults, FOR FUTURE RELEASE. + +| Name | Description | Value | +| --------------------- | ------------------------------------------------ | ------------- | +| `dataGroup.enabled` | if grouping enabled | `false` | +| `dataGroup.prefix` | common prefix for the group used for identifiers | `sampleGroup` | +| `dataGroup.timestamp` | data timestamp the group is running on | `no-default` | + +### Frozen data settings + +| Name | Description | Value | +| -------------------------------------- | ------------------------------------------- | --------------------------- | +| `frozenData.enabled` | If use frozen data is enabled. | `false` | +| `frozenData.image.repository` | Repository | `navi/frozen-data` | +| `frozenData.image.tag` | Tag | `perftesting-common-master` | +| `frozenData.image.pullPolicy` | Pull Policy | `Always` | +| `frozenData.resources` | Container resources requirements structure. | `{}` | +| `frozenData.resources.requests.cpu` | CPU request, recommended value `100m`. | `undefined` | +| `frozenData.resources.requests.memory` | Memory request, recommended value `100Mi`. | `undefined` | +| `frozenData.resources.limits.cpu` | CPU limit, recommended value `100m`. | `undefined` | +| `frozenData.resources.limits.memory` | Memory limit, recommended value `100Mi`. | `undefined` | + + +## Usage example + +``` +helm upgrade --install --dependency-update test-attractor . +``` diff --git a/charts/navi-attractor/templates/NOTES.txt b/charts/navi-attractor/templates/NOTES.txt new file mode 100644 index 000000000..c01ef17fc --- /dev/null +++ b/charts/navi-attractor/templates/NOTES.txt @@ -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 }} diff --git a/charts/navi-attractor/templates/_helpers.tpl b/charts/navi-attractor/templates/_helpers.tpl new file mode 100644 index 000000000..f11f0bb5b --- /dev/null +++ b/charts/navi-attractor/templates/_helpers.tpl @@ -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" "" "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" "" "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 -}} diff --git a/charts/navi-attractor/templates/configmap.yaml b/charts/navi-attractor/templates/configmap.yaml new file mode 100644 index 000000000..5a9c70fbb --- /dev/null +++ b/charts/navi-attractor/templates/configmap.yaml @@ -0,0 +1,299 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "generic-chart.fullname" . }}-configmap +data: + attractord.conf: | + {{- if .Values.attractor.overrideConfig }} + {{ .Values.attractor.overrideConfig | nindent 4 }} + {{- else }} + { + "log": { + "logger_name": "attractord", + "file_prefix": "../../../../", + "enable_syslog": true, + "level": {{ .Values.attractor.logLevel | quote }}, + "disabled_tags_": [ + "http", + "UploadData", + "Download", + "ProjectContext" + ], + "format": "Json", + "json_message_field_name": {{ .Values.attractor.logMessageField | quote }}, + "enable_mirroring": true + }, + "service": { + "pid_file": "/var/run/2gis/attractord.pid" + }, + "http": { + "port": {{ .Values.attractor.appPort }}, + "handlers_number": {{ .Values.attractor.handlersNumber | int }}, + "log_verbose": false, + "max_process_time": {{ .Values.attractor.maxProcessTime | int }}, + "response_timelimit": {{ .Values.attractor.responseTimelimit | int }}, + "request_timeout": {{ .Values.attractor.requestTimeout | int }}, + "server": "0.0.0.0" + }, + "grpc": + { + "server" : "0.0.0.0", + "port" : {{ .Values.attractor.grpcPort | int }}, + "max_process_time": {{ .Values.attractor.maxProcessTime | int }}, + "response_timelimit": {{ .Values.attractor.responseTimelimit | int }}, + "request_timeout": {{ .Values.attractor.requestTimeout | int }} + }, + "context": { + "variables": { + "LOCAL_PATH": "/opt/castle", + "LOCAL_ETC": "/etc/2gis/mosesd", + "REMOTE_PATH": "{{ include "config.setCastleUrl" $ }}" + }, + "rules": { + "update_period" : 0, + "nodes": [ + "file://{LOCAL_ETC}/rules.conf" + ], + "timeout_seconds": { + "count": 30 + } + }, + "cities": { + "update_period": 0, + "nodes": [ + "{REMOTE_PATH}/{{ .Values.attractor.citiesFilename }}" + ], + "timeout_seconds": { + "count": 30 + } + }, + "index": { + "update_period": 600, + {{- /* search .zip in files */}} + {{- if regexMatch ".*\\.zip.*" .Values.attractor.indexFilename }} + "content": "index.json", + {{- end }} + "nodes": [ + "{REMOTE_PATH}/{{ .Values.attractor.indexFilename }}" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- if .Values.attractor.indices.ctxOptions.enabled }} + "ctx_options": { + "update_period": 0, + "nodes": [ + "{REMOTE_PATH}/options/ctx_config.json" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- end }}{{- /* .Values.attractor.indices.ctxOptions.enabled */}} + {{- if .Values.attractor.indices.carOptions.enabled }} + "car_options": { + "update_period": 0, + "nodes": [ + "{REMOTE_PATH}/options/carrouting.json" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- end }}{{- /* .Values.attractor.indices.carOptions.enabled */}} + {{- if .Values.attractor.indices.countryCarOptions.enabled }} + "country_car_options": { + "update_period": 0, + "nodes": [ + "{REMOTE_PATH}/options/{payload}.json" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- end }}{{- /* .Values.attractor.indices.countryCarOptions.enabled */}} + {{- if .Values.attractor.indices.projectCarOptions.enabled }} + "project_car_options": { + "update_period": 0, + "nodes": [ + "{REMOTE_PATH}/" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- end }}{{- /* .Values.attractor.indices.projectCarOptions.enabled */}} + "routing_resources": { + "nodes": [ + "dir:///usr/share/2gis/moses2-routing-resources/" + ], + "timeout_seconds": { + "count": 30 + } + }, + "packages": { + "update_period": 0, + "nodes": [ + "{REMOTE_PATH}/" + ], + "timeout_seconds": { + "count": 30 + } + }, + "restrictions": { + "update_period": 0, + "nodes": [ + "{{ include "config.setRestrictionUrl" $ }}/" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- if .Values.attractor.indices.entrances.enabled }} + "entrances": { + "update_period": 0, + "nodes": [ + "{REMOTE_PATH}/" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- end }}{{- /* .Values.attractor.indices.entrances.enabled */}} + {{- if .Values.attractor.indices.snImport.enabled }} + "sn_import": { + "update_period": 0, + "nodes": + [ + "{REMOTE_PATH}/" + ], + "timeout_seconds": + { + "count": 60 + } + }, + {{- end }}{{- /* .Values.attractor.indices.snImport.enabled */}} + {{- if .Values.attractor.indices.geoImport.enabled }} + "geo_import": { + "update_period": 0, + "nodes": + [ + "{REMOTE_PATH}/" + ], + "timeout_seconds": + { + "count": 60 + } + }, + {{- end }}{{- /* .Values.attractor.indices.geoImport.enabled */}} + + + {{- if eq .Values.attractor.type "truck" }} + {{- if .Values.attractor.indices.passZones.enabled }} + "pass_zones": + { + "update_period": 0, + "nodes": + [ + "{REMOTE_PATH}/" + ], + "timeout_seconds": + { + "count": 60 + } + }, + {{- end }}{{- /* .Values.attractor.indices.passZones.enabled */}} + {{- end }} + {{- if .Values.attractor.rtr.enabled }} + "restrictions_index": { + "update_period": {{ .Values.attractor.rtr.updatePeriod }}, + "nodes": [ + "{{ .Values.attractor.rtr.url }}/restrictions_index.json.zip" + ], + "timeout_seconds": { + "count": 30 + } + }, + {{- end }}{{- /* if .Values.attractor.rtr.enabled */}} + {{- if .Values.s3.enabled }} + "s3": { + "distance_matrix": { + {{- if .Values.s3.suffix }} + "suffix": {{ .Values.s3.suffix | quote }}, + {{- end }} + "endpoint": {{ .Values.s3.host | quote }}, + "bucket": {{ .Values.s3.bucket | quote }}, + "access_key": {{ .Values.s3.accessKey | quote }}, + "secret_key": {{ .Values.s3.secretKey | quote }} + } + }, + {{- end }}{{- /* .Values.s3.enabled */}} + {{- if .Values.kafka.enabled }} + "kafka": { + "task_group_id" : {{ .Values.kafka.groupId | quote }}, + "cancel_group_id": {{ .Values.kafka.groupId | quote }}, + "handlers_number": {{ .Values.kafka.handlersNumber }}, + {{- /* + Collect merged Kafka properties from these dictionaries: + - kafka.properties: this is a simple key/value dictionary + - kafka.fileProperties: this is a key/content dictionary given in values, + content is sensitive and stored in Secret resource, they get + mounted as files sonamed after key. While actual secret values are + hidden this way, what actually goes here in environment properties is + file names. This value substitution is implemented down here. + */ -}} + {{- $kafkaProperties := dict -}} + {{- range $key, $_ := .Values.kafka.fileProperties -}} + {{- $_ := set $kafkaProperties $key (printf "/etc/2gis/mosesd/secret/%s" $key) -}} + {{- end -}} + {{- $kafkaProperties := mustMerge $kafkaProperties .Values.kafka.properties }} + "kafka_properties": {{ mustToPrettyJson $kafkaProperties | nindent 12 }}, + "distance_matrix": { + "task_topic": {{ .Values.kafka.distanceMatrix.taskTopic | quote }}, + "cancel_topic": {{ .Values.kafka.distanceMatrix.cancelTopic | quote }}, + "status_topic": {{ .Values.kafka.distanceMatrix.statusTopic | quote }}, + "update_task_status_period_sec": {{ .Values.kafka.distanceMatrix.updateTaskStatusPeriodSec | int }}, + "message_expired_period_sec" : {{ .Values.kafka.distanceMatrix.messageExpiredPeriodSec | int }}, + "request_download_timeout_sec" : {{ .Values.kafka.distanceMatrix.requestDownloadTimeoutSec | int }}, + "response_upload_timeout_sec": {{ .Values.kafka.distanceMatrix.responseUploadTimeoutSec | int }} + } + }, + {{- end }}{{- /* .Values.kafka.enabled */}} + {{- if .Values.attractor.additional_sections }} + {{- include "tplvalues.render" ( dict "value" .Values.attractor.additional_sections "context" $) | nindent 8 }} + {{- end }} + "server_info": { + "tiles_metrics_threshold": {{ .Values.attractor.tilesMetricsThreshold | int }}, + "attractor_car" : {{ include "config.setAttractorCar" $ | default false -}}, + "attractor_pedestrian" : {{ include "config.setAttractorPedestrian" $ | default false -}}, + "attractor_bicycle" : {{ include "config.setAttractorBicycle" $ | default false -}}, + "attractor_taxi" : {{ include "config.setAttractorTaxi" $ | default false -}}, + "attractor_truck" : {{ include "config.setAttractorTruck" $ | default false -}}, + {{- if ((.Values.resources).limits).cpu }} + "dist_matrix_thread_pool_size" : {{ include "config.setCpuNumber" . }}, + "simple_network_build_thread_pool_size" : {{ include "config.setCpuNumber" . }}, + {{- end }} + "update_projects_limit" : 2, + "carrouting_page_cache_size" : 8192, + "carrouting_tile_cache_size" : 8192, + "carrouting_bit_tile_cache_size" : 2048, + "dump_query" : {{ mustToJson .Values.attractor.dump.query }}, + "dump_result" : {{ mustToJson .Values.attractor.dump.result }}, + "dump_answer" : {{ mustToJson .Values.attractor.dump.answer }}, + "max_parallel_workers" : 2, + "use_memory_mapped_vfs" : true, + "engine_update_period_sec" : 30, + {{- if .Values.attractor.server_id }} + "server_id" : "{{- include "tplvalues.render" ( dict "value" .Values.attractor.server_id "context" .) }}", + {{- else }} + "server_id" : "{{- include "generic-chart.fullname" . }}", + {{- end }} + "extended_metrics": [ ] + } + } + } + {{- end }}{{- /* .Values.attractor.overrideConfig */}} + rules.conf: |- + {{- include "rules.renderRules" . }} diff --git a/charts/navi-attractor/templates/deployment.yaml b/charts/navi-attractor/templates/deployment.yaml new file mode 100644 index 000000000..f0f11ee0c --- /dev/null +++ b/charts/navi-attractor/templates/deployment.yaml @@ -0,0 +1,158 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "generic-chart.fullname" . }} + labels: + {{- include "generic-chart.labels" . | nindent 4 }} + rule: {{ .Values.attractor.app_rule | default "" | quote }} + navigroup: {{ .Values.navigroup | default "" | quote }} + {{- if .Values.dataGroup.enabled }} + dataGroupTimestamp: {{ .Values.dataGroup.timestamp | int | quote }} + dataGroupPrefix: {{ .Values.dataGroup.prefix | quote }} + {{- end }}{{- /* dataGroup.enabled */}} + {{- with .Values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if not .Values.hpa.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} + {{- if .Values.strategy }} + strategy: + {{- include "tplvalues.render" ( dict "value" .Values.strategy "context" $) | nindent 6 }} + {{- end }} + selector: + matchLabels: + {{- include "generic-chart.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ (include (print $.Template.BasePath "/configmap.yaml") . | fromYaml).data | toYaml | sha256sum }} + checksum/secret: {{ (include (print $.Template.BasePath "/secret.yaml") . | fromYaml).data | toYaml | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "generic-chart.selectorLabels" . | nindent 8 }} + navigroup: {{ .Values.navigroup | default "" | quote }} + {{- if .Values.dataGroup.enabled }} + dataGroupTimestamp: {{ .Values.dataGroup.timestamp | int | quote }} + dataGroupPrefix: {{ .Values.dataGroup.prefix | quote }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "generic-chart.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + volumes: + - name: {{ include "generic-chart.fullname" . }}-configmap + configMap: + name: {{ include "generic-chart.fullname" . }}-configmap + {{- if .Values.frozenData.enabled }} + - name: frozen-data + emptyDir: {} + {{- end }} + {{- if .Values.kafka.fileProperties }} + - name: {{ include "generic-chart.fullname" . }}-secret + secret: + secretName: {{ include "generic-chart.fullname" . }}-secret + {{- end }} + {{- if .Values.frozenData.enabled }} + initContainers: + - name: frozen-data + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: {{ required "A valid .Values.dgctlDockerRegistry entry required" .Values.dgctlDockerRegistry }}/{{ .Values.frozenData.image.repository }}:{{ .Values.frozenData.image.tag }} + command: ['sh', '-ec', 'cp -r /frozen_data_init/* /opt/castle; ls -l /opt/castle'] + imagePullPolicy: {{ .Values.frozenData.pullPolicy }} + {{- if (.Values.frozenData).resources }} + resources: {{- toYaml .Values.frozenData.resources | nindent 12 }} + {{- end }} + volumeMounts: + - name: frozen-data + mountPath: /opt/castle + {{- end }} + containers: +{{- /* generic-chart.containerName redefined in _helpers.tpl */}} + - name: {{ include "generic-chart.containerName" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ required "A valid .Values.dgctlDockerRegistry entry required" .Values.dgctlDockerRegistry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if not .Values.attractor.mock }} + command: [ "/usr/sbin/2gis/mosesd/tini","--" ] + args: + - /usr/sbin/2gis/mosesd/attractord + - --config + - /etc/2gis/mosesd/attractord.conf + {{- end }} + volumeMounts: + - name: {{ include "generic-chart.fullname" . }}-configmap + mountPath: /etc/2gis/mosesd/attractord.conf + subPath: attractord.conf + - name: {{ include "generic-chart.fullname" . }}-configmap + mountPath: /etc/2gis/mosesd/rules.conf + subPath: rules.conf + {{- if .Values.frozenData.enabled }} + - name: frozen-data + mountPath: /opt/castle + {{- end }} + {{- if .Values.kafka.fileProperties }} + - name: {{ include "generic-chart.fullname" . }}-secret + mountPath: /etc/2gis/mosesd/secret/ + {{- end }} + ports: + - name: http + containerPort: {{ .Values.attractor.appPort }} + protocol: TCP + - name: grpc + containerPort: {{ .Values.attractor.grpcPort }} + protocol: TCP + startupProbe: + {{- include "navi-attractor.probe" . | nindent 12 }} + periodSeconds: 5 + failureThreshold: 100 + livenessProbe: + {{- include "navi-attractor.probe" . | nindent 12 }} + periodSeconds: 5 + timeoutSeconds: 3 + failureThreshold: 5 + readinessProbe: + {{- include "navi-attractor.probe" . | nindent 12 }} + periodSeconds: 5 + timeoutSeconds: 3 + failureThreshold: 2 + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + {{ if ne .Values.attractor.type "schedule" }} + - name: RULE + value: {{ .Values.attractor.app_rule | default "" | quote }} + {{- else -}} + - name: RULE + value: "" + {{ end }} + - name: PROJECT + value: {{ .Values.app_project | default "" | quote }} + - name: PORT_GRPC + value: {{ .Values.attractor.grpc_port | quote }} + lifecycle: + # wait for the endpoint removal process + preStop: + exec: + command: ["/bin/sh", "-c", "sleep {{ .Values.preStopDelay | default 5 | int }}"] + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds | default 60 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + affinity: + {{- include "tplvalues.render" ( dict "value" .Values.affinity "context" $) | nindent 8 }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/navi-attractor/templates/hpa.yaml b/charts/navi-attractor/templates/hpa.yaml new file mode 100644 index 000000000..41e1e392d --- /dev/null +++ b/charts/navi-attractor/templates/hpa.yaml @@ -0,0 +1 @@ +{{- template "generic-chart.hpa.tpl" . }} diff --git a/charts/navi-attractor/templates/ingress.yaml b/charts/navi-attractor/templates/ingress.yaml new file mode 100644 index 000000000..9674c7d3c --- /dev/null +++ b/charts/navi-attractor/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "generic-chart.fullname" . -}} +{{- $svcPort := .Values.service.http.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "generic-chart.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }}-http + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/navi-attractor/templates/pdb.yaml b/charts/navi-attractor/templates/pdb.yaml new file mode 100644 index 000000000..824f66d70 --- /dev/null +++ b/charts/navi-attractor/templates/pdb.yaml @@ -0,0 +1 @@ +{{- template "generic-chart.pdb.tpl" . }} diff --git a/charts/navi-attractor/templates/secret.yaml b/charts/navi-attractor/templates/secret.yaml new file mode 100644 index 000000000..22e2f7c0e --- /dev/null +++ b/charts/navi-attractor/templates/secret.yaml @@ -0,0 +1,16 @@ +{{- if .Values.kafka.fileProperties }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "generic-chart.fullname" . }}-secret + labels: + {{- include "generic-chart.labels" . | nindent 4 }} + {{- if .Values.labels }} + {{- toYaml .Values.labels | nindent 4 }} + {{- end }} +type: Opaque +data: + {{- range $prop, $val := .Values.kafka.fileProperties }} + {{ $prop | quote }}: {{ $val | b64enc | quote }} + {{- end }} +{{- end }} diff --git a/charts/navi-attractor/templates/service.yaml b/charts/navi-attractor/templates/service.yaml new file mode 100644 index 000000000..e5ceeb499 --- /dev/null +++ b/charts/navi-attractor/templates/service.yaml @@ -0,0 +1,72 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "generic-chart.fullname" . }} + labels: + {{- include "generic-chart.labels" . | nindent 4 }} + {{- if .Values.service.labels }} + {{- include "tplvalues.render" ( dict "value" .Values.service.labels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.service.grpc.labels }} + {{- include "tplvalues.render" ( dict "value" .Values.service.grpc.labels "context" $) | nindent 4 }} + {{- end }} + rule: {{ .Values.attractor.app_rule | default "" | quote }} + navigroup: {{ .Values.navigroup | default "" | quote }} + type: {{ .Values.attractor.type | quote }} + {{- if .Values.dataGroup.enabled }} + dataGroupTimestamp: {{ .Values.dataGroup.timestamp | int | quote }} + dataGroupPrefix: {{ .Values.dataGroup.prefix | quote }} + {{- end }} + {{- if .Values.service.grpc.annotations }} + annotations: + {{- include "tplvalues.render" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }} + {{- end }} + +spec: + type: {{ .Values.service.grpc.type }} + clusterIP: {{ .Values.service.grpc.clusterIP | default "" | quote }} + ports: + - port: {{ .Values.service.grpc.port }} + targetPort: grpc + protocol: TCP + name: grpc + selector: + {{- include "generic-chart.selectorLabels" . | nindent 4 }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "generic-chart.fullname" . }}-http + labels: + {{- include "generic-chart.labels" . | nindent 4 }} + {{- if .Values.service.labels }} + {{- include "tplvalues.render" ( dict "value" .Values.service.labels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.service.http.labels }} + {{- include "tplvalues.render" ( dict "value" .Values.service.http.labels "context" $) | nindent 4 }} + {{- end }} + rule: {{ .Values.attractor.app_rule | default "" | quote }} + navigroup: {{ .Values.navigroup | default "" | quote }} + type: {{ .Values.attractor.type | quote }} + {{- if .Values.dataGroup.enabled }} + dataGroupTimestamp: {{ .Values.dataGroup.timestamp | int | quote }} + dataGroupPrefix: {{ .Values.dataGroup.prefix | quote }} + {{- end }} + annotations: + {{- if .Values.service.annotations }} + {{- include "tplvalues.render" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.service.http.annotations }} + {{- include "tplvalues.render" ( dict "value" .Values.service.http.annotations "context" $) | nindent 4 }} + {{- end }} + +spec: + type: {{ .Values.service.http.type }} + clusterIP: {{ .Values.service.http.clusterIP | default "" | quote }} + ports: + - port: {{ .Values.service.http.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "generic-chart.selectorLabels" . | nindent 4 }} diff --git a/charts/navi-attractor/templates/serviceaccount.yaml b/charts/navi-attractor/templates/serviceaccount.yaml new file mode 100644 index 000000000..7109eec48 --- /dev/null +++ b/charts/navi-attractor/templates/serviceaccount.yaml @@ -0,0 +1 @@ +{{- template "generic-chart.serviceaccount.tpl" . }} diff --git a/charts/navi-attractor/templates/vpa.yaml b/charts/navi-attractor/templates/vpa.yaml new file mode 100644 index 000000000..5de5ca28e --- /dev/null +++ b/charts/navi-attractor/templates/vpa.yaml @@ -0,0 +1 @@ +{{- template "generic-chart.vpa.tpl" . }} diff --git a/charts/navi-attractor/values.yaml b/charts/navi-attractor/values.yaml new file mode 100644 index 000000000..5e583d9dc --- /dev/null +++ b/charts/navi-attractor/values.yaml @@ -0,0 +1,356 @@ +# @section Docker Registry settings + +# @param dgctlDockerRegistry Docker Registry endpoint where On-Premise services' images reside. Format: `host:port`. + +dgctlDockerRegistry: '' + + +# @section Common settings + +# @param replicaCount A replica count for the pod. +# @param revisionHistoryLimit Number of replica sets to keep for deployment rollbacks +# @param imagePullSecrets Kubernetes image pull secrets. +# @param nameOverride Base name to use in all the Kubernetes entities deployed by this chart. +# @param fullnameOverride Base fullname to use in all the Kubernetes entities deployed by this chart. +# @param podAnnotations Kubernetes [pod annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). +# @param podSecurityContext Kubernetes [pod security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/). +# @param securityContext Kubernetes [security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/). +# @param nodeSelector Kubernetes [node selectors](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector). +# @param tolerations Kubernetes [tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) settings. +# @param affinity Kubernetes pod [affinity settings](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity). +# @param labels Custom labels to set to Deployment resource. +# @param preStopDelay Delay in seconds before terminating container. +# @param terminationGracePeriodSeconds Maximum time allowed for graceful shutdown. + +replicaCount: 1 +revisionHistoryLimit: 1 +imagePullSecrets: [] +nameOverride: '' +fullnameOverride: '' +podAnnotations: {} +podSecurityContext: {} +securityContext: {} +nodeSelector: {} +tolerations: [] +affinity: {} +labels: {} +preStopDelay: 5 +terminationGracePeriodSeconds: 60 + + +# @section Container image settings + +# @param image.repository Repository +# @param image.pullPolicy Pull Policy +# @param image.tag Tag + +image: + repository: 2gis-on-premise/attractord + pullPolicy: IfNotPresent + tag: 7.27.1.2 + + +# @section Service account settings + +# @param serviceAccount.create Specifies whether a service account should be created. +# @param serviceAccount.annotations Annotations to add to the service account. +# @param serviceAccount.name The name of the service account to use. If not set and create is true, a name is generated using the fullname template. + +serviceAccount: + create: false + annotations: {} + name: '' + + +# @section Service settings + +# @param service.labels Kubernetes [service labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). +# @param service.annotations Kubernetes [service annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). +# @param service.http.port Service HTTP port. +# @param service.http.type Kubernetes [service type](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types). +# @param service.http.clusterIP Controls Service cluster IP allocation. Cannot be changed after resource creation. +# @param service.http.labels Kubernetes [service labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). +# @param service.http.annotations Kubernetes [service annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). +# @param service.grpc.port Service GRPC port. +# @param service.grpc.type Kubernetes [service type](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types). +# @param service.grpc.clusterIP Controls Service cluster IP allocation. Cannot be changed after resource creation. +# @param service.grpc.labels Kubernetes [service labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). +# @param service.grpc.annotations Kubernetes [service annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). + +service: + labels: {} + annotations: {} + http: + port: 80 + type: ClusterIP + clusterIP: '' + labels: {} + annotations: {} + grpc: + port: 50051 + type: ClusterIP + clusterIP: None + labels: {} + annotations: {} + + +# @section Kubernetes [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) settings + +# @param ingress.enabled If Ingress is enabled for the service. +# @param ingress.hosts[0].host Hostname for the Ingress service. + +ingress: + enabled: false + hosts: + - host: navi-attractor.host + + +# @section Limits + +# @param resources [nullable] Container resources requirements structure. +# @param resources.requests.cpu [nullable] CPU request, recommended value `1000m`. +# @param resources.requests.memory [nullable] Memory request, recommended value `2Gi`. +# @param resources.limits.cpu [nullable] CPU limit, recommended value `3000m`. +# @param resources.limits.memory [nullable] Memory limit, recommended value `8Gi`. + +resources: {} + + +# @section Kubernetes [Horizontal Pod Autoscaling](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) settings + +# @param hpa.enabled If HPA is enabled for the service. +# @param hpa.minReplicas Lower limit for the number of replicas to which the autoscaler can scale down. +# @param hpa.maxReplicas Upper limit for the number of replicas to which the autoscaler can scale up. +# @param hpa.scaleDown Scale-down settings structure +# @param hpa.scaleUp Scale-up settings structure +# @param hpa.targetCPUUtilizationPercentage Target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified the default autoscaling policy will be used. +# @param hpa.targetMemoryUtilizationPercentage Target average memory utilization (represented as a percentage of requested memory) over all the pods; if not specified the default autoscaling policy will be used. +hpa: + enabled: false + minReplicas: 1 + maxReplicas: 100 + scaleDown: '' + scaleUp: '' + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: '' + + +# @section Kubernetes [Vertical Pod Autoscaling](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/README.md) settings + +# @param vpa.enabled If VPA is enabled for the service. +# @param vpa.updateMode VPA [update mode](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler#quick-start). +# @extra vpa.minAllowed.cpu Lower limit for the number of CPUs to which the autoscaler can scale down. +# @extra vpa.minAllowed.memory Lower limit for the RAM size to which the autoscaler can scale down. +# @extra vpa.maxAllowed.cpu Upper limit for the number of CPUs to which the autoscaler can scale up. +# @extra vpa.maxAllowed.memory Upper limit for the RAM size to which the autoscaler can scale up. + +vpa: + enabled: false + updateMode: Auto + + +# @section Kubernetes [Pod Disruption Budget](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-budgets) settings + +# @param pdb.enabled If PDB is enabled for the service. +# @param pdb.minAvailable How many pods must be available after the eviction. +# @param pdb.maxUnavailable How many pods can be unavailable after the eviction. + +pdb: + enabled: false + minAvailable: '' + maxUnavailable: 1 + + +# @section Navi-Attractor application settings + +# @param attractor.appPort Container port for HTTP interface +# @param attractor.handlersNumber Total number of HTTP/GRPC handlers. +# @param attractor.maxProcessTime Maximum processing time limit in minutes. +# @param attractor.responseTimelimit Maximum response time limit in minutes. +# @param attractor.requestTimeout Maximum request time limit in minutes. +# @param attractor.dump.result Dump results in logs. +# @param attractor.dump.query Dump queries in logs. +# @param attractor.dump.answer Dump answers in logs. +# @param attractor.logLevel Logging level, one of: Verbose, Info, Warning, Error, Fatal. +# @param attractor.logMessageField Field name in logs for messages data. +# @param attractor.grpcPort Container port for gRPC interface +# @param attractor.indexFilename Name of the index file on Castle +# @param attractor.citiesFilename Name of the cities file on Castle +# @extra attractor.indices List of dynamic indices kill switches. +# @skip attractor.indices.carOptions.enabled +# @skip attractor.indices.countryCarOptions.enabled +# @skip attractor.indices.ctxOptions.enabled +# @skip attractor.indices.entrances.enabled +# @skip attractor.indices.geoImport.enabled +# @skip attractor.indices.passZones.enabled +# @skip attractor.indices.projectCarOptions.enabled +# @skip attractor.indices.snImport.enabled +# @skip attractor.attractor +# @param attractor.overrideConfig Complete config override. For test purposes only. +# @param attractor.rtr.enabled Enable real time restrictions. +# @param attractor.rtr.url URL real time restrictions server. +# @param attractor.rtr.updatePeriod Update period from real time restrictions server. +# @param attractor.mock If mock service being deployed. For test purposes only. +# @param attractor.tilesMetricsThreshold The value at which we send tiles metrics (used for internal tests). +# @skip rules + +attractor: + appPort: 8080 + handlersNumber: 20 + maxProcessTime: 20 + responseTimelimit: 120 + requestTimeout: 120 + dump: + result: true + query: true + answer: false + logLevel: Info + logMessageField: custom.navi_msg + grpcPort: 50051 + indexFilename: index.json.zip + citiesFilename: cities.conf.zip + indices: + # items in alphabet order + carOptions: + enabled: true + countryCarOptions: + enabled: true + ctxOptions: + enabled: true + entrances: + enabled: true + geoImport: + enabled: false + passZones: + enabled: true + projectCarOptions: + enabled: true + snImport: + enabled: false + attractor: {} + overrideConfig: '' + rtr: + enabled: false + url: http://rtr + updatePeriod: 60 + mock: false + tilesMetricsThreshold: 0 + +rules: [] + +# @section Kafka settings for interacting with Distance Matrix Async Service + +# @param kafka.enabled If the Kafka is enabled +# @param kafka.groupId Navi-Attractor service group identifier +# @param kafka.handlersNumber Number of Kafka handlers +# @extra kafka.properties Properties as supported by librdkafka. Refer to inline comments for details +# @skip kafka.properties.bootstrap.servers +# @skip kafka.properties.security.protocol +# @param kafka.fileProperties As kafka.properties, but kept in a file, which passed to application as a filename. Refer to inline comments for details +# @extra kafka.distanceMatrix **Settings for interacting with Distance Matrix Async service** +# @param kafka.distanceMatrix.taskTopic Name of the topic for receiving new tasks from Distance Matrix Async API +# @param kafka.distanceMatrix.cancelTopic Name of the topic for canceling or receiving information about finished tasks +# @param kafka.distanceMatrix.statusTopic Name of the topic for receiving task status information +# @param kafka.distanceMatrix.updateTaskStatusPeriodSec Update period for task statuses +# @param kafka.distanceMatrix.messageExpiredPeriodSec Update period for task cancellations +# @param kafka.distanceMatrix.requestDownloadTimeoutSec Timeout for downloading request data +# @param kafka.distanceMatrix.responseUploadTimeoutSec Timeout for uploading response data + +kafka: + enabled: false + groupId: navi_attractor + handlersNumber: 2 + properties: + bootstrap.servers: kafka.host:9092 + security.protocol: PLAINTEXT + fileProperties: {} + distanceMatrix: + taskTopic: task_topic + cancelTopic: cancel_topic + statusTopic: status_topic + updateTaskStatusPeriodSec: 120 + messageExpiredPeriodSec: 3600 + requestDownloadTimeoutSec: 20 + responseUploadTimeoutSec: 40 + +# Kafka properties for common use-cases: +# +# Note that means that actual content passed from +# file user.p12 with --set-file (especially binary data), e.g.: +# +# $ helm install navi-attractor . --set-file 'kafka.fileProperties.ssl\.keystore\.location=user.p12' +# +# 1. SSL authentication with key file protected with password 123: +# +# properties: +# bootstrap.servers: kafka.host:9092 +# security.protocol: SSL +# ssl.keystore.password: '123' +# fileProperties: +# ssl.ca.location: '' +# ssl.certificate.location: '' +# ssl.key.location: '' +# +# 2. login/password SASL as test-username/123: +# +# properties: +# bootstrap.servers: kafka.host:9092 +# security.protocol: SASL_PLAINTEXT +# sasl.mechanism: SCRAM-SHA-512 +# sasl.username: test-username +# sasl.password: '123' +# +# 3. Unauthenticated: +# +# properties: +# bootstrap.servers: kafka.host:9092 +# security.protocol: PLAINTEXT + +# @section S3-compatible storage settings for interacting with Distance Matrix Async Service + +# @param s3.enabled if S3 storage is enabled +# @param s3.host S3 endpoint +# @param s3.bucket S3 bucket name +# @param s3.accessKey S3 access key for accessing the bucket +# @param s3.secretKey S3 secret key for accessing the bucket +# @param s3.suffix String to be prepended to file name in reply + +s3: + enabled: false + host: '' + bucket: '' + accessKey: '' + secretKey: '' + suffix: '' + +# @section Back-end and attractor group properties. Leave with defaults, FOR FUTURE RELEASE. + +# @param dataGroup.enabled if grouping enabled +# @param dataGroup.prefix common prefix for the group used for identifiers +# @param dataGroup.timestamp data timestamp the group is running on + +dataGroup: + enabled: false + prefix: sampleGroup + timestamp: no-default + + +# @section Frozen data settings + +# @param frozenData.enabled If use frozen data is enabled. +# @param frozenData.image.repository Repository +# @param frozenData.image.tag Tag +# @param frozenData.image.pullPolicy Pull Policy +# @param frozenData.resources [nullable] Container resources requirements structure. +# @param frozenData.resources.requests.cpu [nullable] CPU request, recommended value `100m`. +# @param frozenData.resources.requests.memory [nullable] Memory request, recommended value `100Mi`. +# @param frozenData.resources.limits.cpu [nullable] CPU limit, recommended value `100m`. +# @param frozenData.resources.limits.memory [nullable] Memory limit, recommended value `100Mi`. + +frozenData: + enabled: false + image: + repository: navi/frozen-data + pullPolicy: Always + tag: perftesting-common-master + resources: {}