Skip to main content

Installing Traffic API Proxy

Important note:

All passwords and keys in this section are given for illustration purposes.

During a real installation, it is recommended to use more complex and reliable passwords.

1. Before installing

  1. Consider getting familiar with:

  2. Make sure the necessary preparation steps are completed:

    1. Preparation for installation
    2. Fetching installation artifacts
    3. Installing License service
    4. Installing API Keys service
  3. Collect the necessary information that was set or retrieved on previous steps:

    ObjectExample valueHow to get value
    Docker Registry mirror endpointdocker.storage.example.local:5000See Fetching installation artifacts
    Kubernetes secret for accessing Docker Registryonpremise-registry-credsSee Fetching installation artifacts
  4. Make sure that the resource requirements specified in the Helm chart are met. For more information on how to do this, refer to the System requirements document.

Note

Contents of the Helm chart described in this chapter are relevant for the latest On-Premise version (see Release notes). To find parameters for earlier versions, open values.yaml on GitHub and enter the required version number (for example, 1.18.0) in the tag switcher on the left.

2. Install Traffic API Proxy service

  1. Create a Helm configuration file. See here for more details on the available settings.

    The example is prefilled with the necessary data collected on previous steps.

    values-traffic-proxy.yaml
    dgctlDockerRegistry: docker.storage.example.local:5000

    imagePullSecrets: [onpremise-registry-creds]

    replicaCount: 1

    proxy:
    host: https://traffic-jams.2gis.com
    worker:
    processes: 2
    connections: 1024
    log:
    customFormats: []
    # - name: small
    # escape: json
    # format: |
    # '{"time_local":"$time_local",'
    # '"remote_addr":"$remote_addr",'
    # '"request":"$request",'
    # '"status":"$status",'
    # '"host":"$host"}'
    errorLog:
    level: error

    accessLog: '/dev/null'
    # accessLog: '/dev/stdout main'

    keepaliveTimeout: 65

    locations: []
    # - path: /test/
    # definition: |
    # default_type text/html;
    # return 200 "<!DOCTYPE html><h2>test page</h2>\n";

    httpServers:
    {}
    # examplecfg: |
    # server {
    # listen 0.0.0.0:8080;

    # location / {
    # default_type text/html;
    # return 200 "<!DOCTYPE html><h2>test page</h2>\n";
    # }
    # }

    resources:
    requests:
    cpu: 10m
    memory: 32Mi
    limits:
    cpu: 500m
    memory: 256Mi

    ingress:
    enabled: true
    className: nginx
    hosts:
    - host: traffic-proxy.example.com
    paths:
    - path: /
    pathType: Prefix
    tls: []
    #- hosts:
    # - traffic-proxy-api.example.com
    # secretName: secret.tls

    Where:

    • dgctlDockerRegistry: endpoint of your Docker Registry with the images of the On-Premise services.
    • imagePullSecrets: Kubernetes Secrets to access the Docker Registry with the images of the On-Premise services.
    • replicaCount: number of the NGINX service replicas.
    • proxy: proxy server settings.
      • host: FQDN of a public Traffic Update server. For the list of available servers, see the Architecture section.
      • worker: worker settings.
        • processes: number of worker processes.
        • connections: number of worker connections.
      • log: logging settings.
        • customFormats: list of custom log formats to use in NGINX configuration.
        • errorLog.level: error logging level. Allowed values: debug, info, notice, warn, error, crit, alert, emerg.
        • accessLog: access logging.
      • keepaliveTimeout: keep-alive timeout.
      • locations: additional location blocks, which are included in the NGINX configuration.
      • httpServers: additional server blocks, which are included in the NGINX configuration.
    • resources: computational resources settings for the service. To find out recommended resource values, see Computational resources.
    • ingress: configuration of the Ingress resource. Adapt it to your Ingress installation. Note that the path for the host should point to the root: /.
  2. Deploy the service with Helm using created values-traffic-proxy.yaml configuration file:

    helm upgrade --install --atomic --wait-for-jobs --values ./values-traffic-proxy.yaml traffic-proxy 2gis-on-premise/traffic-proxy

3. Test deployment

1. Verify the proxy operation

In a browser, go to the address specified in the ingress.hosts[0].host parameter of the configuration file for installing Traffic API Proxy and append the path /traffic/moses/speeds5.json. For example: traffic-proxy-api.example.com/traffic/moses/speeds5.json.

Alternatively, send a GET request to the same address:

curl -X GET https://traffic-proxy-api.example.com/traffic/moses/speeds5.json

The response must be a JSON object containing a list of files with traffic data.

2. Verify traffic data retrieval by the consuming service

To ensure that the Navi-Back service retrieves traffic data through the proxy, follow these steps:

  1. Do any of the preparatory steps:

    • Ensure that the ingress.enabled: "true" parameter is set in the configuration file for installing the Navi-Back service. In the following steps, use the address specified in the ingress.hosts[0].host parameter of the Navi-Back configuration file (for example, https://navi-back-ingress.example.com).
    • Forward the HTTP port of the Navi-Back container to the host network level to access the service endpoints. In the following steps, use the host IP address and the required port.
  2. Check the time of the last traffic data retrieval using one of the methods below:

    • Retrieve Navi-Back metrics in Prometheus format via the /metrics endpoint. Add the path /metrics to the address from the preparation step and send a GET request. Example:

      curl -X GET https://navi-back-ingress.example.com/metrics

      The response must contain the mosesd_jams metric (a timestamp of the last traffic data retrieval in UNIX timestamp format) and the mosesd_jams_delay metric (the time elapsed since the last data retrieval). If these metrics are missing, the service could not retrieve traffic data through the proxy.

    • In a browser, go to the address from the preparation step and append the path /city to it. For example: navi-back-ingress.example.com/city?type=json.

      The response must be an HTML page containing a traffic column and the time of the last traffic data retrieval.

    • Send a GET request to the address from the preparation step and append the path /city to it. For example:

      curl -X GET https://navi-back-ingress.example.com/city?type=json

      The response must be a JSON object containing a traffic field and the time of the last traffic data retrieval.

What's next?