tyk-pump

by Tyk

Helm chartv5.5.0

A Helm chart for deploying the open source Tyk Pump. Tyk Pump is a pluggable analytics purger to move Analytics generated by Tyk Gateway to any back-end.

About this chart

Tyk Pump

Tyk Pump is a pluggable analytics purger to move Analytics generated by your Tyk nodes to any back-end.

Overview of Tyk Pump

More on pump configurations

Introduction

This chart deploys the open source Tyk pump on a Kubernetes cluster using the Helm package manager.

For typical usage, we recommend using following umbrella charts:

  • For Tyk Open Source, please use tyk-oss
  • For Tyk Hybrid Gateway with Tyk Cloud or MDCB Remote Gateway, please use tyk-data-plane
  • For Tyk Self-Managed, please use tyk-stack

Learn more about different deployment options

Prerequisites

  • Kubernetes 1.19+
  • Helm 3+
  • Redis

Installing the Chart

To install the chart from the Helm repository in namespace tyk with the release name tyk-pump:

helm repo add tyk-helm https://helm.tyk.io/public/helm/charts/
helm repo update
helm show values tyk-helm/tyk-pump > values-pump.yaml

Note: Set Redis connection details first. See Configuration below.

helm install tyk-pump tyk-helm/tyk-pump -n tyk --create-namespace -f values-pump.yaml

Uninstalling the Chart

helm uninstall tyk-pump -n tyk

This removes all the Kubernetes components associated with the chart and deletes the release.

Upgrading Chart

helm upgrade tyk-pump tyk-helm/tyk-pump -n tyk

Upgrading from tyk-headless chart

Please see Migration notes in tyk-oss chart

Configuration

See Customizing the Chart Before Installing.

To get all configurable options with detailed comments:

helm show values tyk-helm/tyk-pump > values.yaml

You can update any value in your local values.yaml file and use -f [filename] flag to override default values during installation. Alternatively, you can use --set flag to set it in Tyk installation.

Set Redis connection details (Required)

Redis is Tyk Pump's primary database where it scrapes Tyk Gateway analytics from. You may set global.redis.addr and global.redis.pass with redis connection string and password for Tyk Gateway respectively.

Pump Configurations

PumpConfiguration
Prometheus Pump (Default)Add the value prometheus to the pump.backend entry, and add connection details for Prometheus under pump.prometheusPump.
Mongo PumpAdd mongo to pump.backend, and add connection details for mongo under global.mongo.
Mongo Selective PumpAdd mongo-selective to pump.backend, and add connection details for mongo under global.mongo.
Mongo Aggregate PumpAdd mongo-aggregate to pump.backend, and add connection details for mongo under global.mongo.
Postgres PumpAdd postgres to pump.backend, and add connection details for postgres under global.postgres.
Postgres Aggregate PumpAdd postgres-aggregate to pump.backend, and add connection details for postgres under global.postgres.
Uptime PumpSet pump.uptimePumpBackend to mongo or postgres or ""
Hybrid PumpAdd hybrid to pump.backend, and setup global.remoteControlPlane section with the required adresses and tokens
Other PumpsAdd the required environment variables in pump.extraEnvs

[!NOTE] For additional information on Tyk Pump configurations, refer to the Setup Dashboard Analytics documentation. To explore the list of supported backends for Tyk Pump, please visit https://tyk.io/docs/tyk-stack/tyk-pump/other-data-stores/.

Prometheus Pump

Add prometheus to pump.backend, and add connection details for prometheus under pump.prometheusPump.

We also support monitoring using Prometheus Operator. All you have to do is set pump.prometheusPump.prometheusOperator.enabled to true. This will create a PodMonitor resource for your Pump instance.

Mongo Pump

If you are using the MongoDB pumps in the tyk-oss installation you will require MongoDB installed for that as well.

To install MongoDB you can use these rather excellent charts provided by Bitnami:

helm install tyk-mongo bitnami/mongodb --version {HELM_CHART_VERSION} --set "replicaSet.enabled=true" -n tyk

(follow notes from the installation output to get connection details and update them in values.yaml file)

[!NOTE] Here is list of supported MongoDB versions. Please make sure you are installing mongo helm chart that matches these version.

[!NOTE] Important Note regarding MongoDB: This helm chart enables the PodDisruptionBudget for MongoDB with an arbiter replica-count of 1. If you intend to perform system maintenance on the node where the MongoDB pod is running and this maintenance requires for the node to be drained, this action will be prevented due the replica count being 1. Increase the replica count in the helm chart deployment to a minimum of 2 to remedy this issue.

Add following under the global section in values.yaml:

   # Set mongo connection details if you want to configure mongo pump.     
   mongo:
      # The mongoURL value will allow you to set your MongoDB address.
      # Default value: mongodb://mongo.{{ .Release.Namespace }}.svc:27017/tyk_analytics
      # mongoURL: mongodb://mongo.tyk.svc:27017/tyk_analytics
      # If your MongoDB has a password you can add the username and password to the url
      # mongoURL: mongodb://root:[email protected]:27017/tyk_analytics?authSource=admin
      mongoURL: <MongoDB address>
      
     # mongo-go driver is supported for Tyk 5.0.2+.
     # We recommend using the mongo-go driver if you are using MongoDB 4.4.x+.
     # For MongoDB versions prior to 4.4, please use the mgo driver.
     # Since Pump 1.9 the default driver is mongo-go.
      driver: mongo-go

      # Enables SSL for MongoDB connection. MongoDB instance will have to support that.
      # Default value: false
      # useSSL: false

SQL Pump

If you are using the SQL pumps in the tyk-oss installation you will require PostgreSQL installed for that as well.

To install PostgreSQL you can use these rather excellent charts provided by Bitnami:

helm install tyk-postgres bitnami/postgresql --set "auth.database=tyk_analytics" -n tyk

(follow notes from the installation output to get connection details and update them in values.yaml file)

Add following under the global section in values.yaml:

  # Postgres connection string parameters.
  postgres:
    # host corresponds to the host name of postgres
    host: tyk-postgres-postgresql.tyk.svc
    # port corresponds to the port of postgres
    port: 5432
    # user corresponds to the user of postgres
    user: postgres
    # password corresponds to the password of the given postgres user in selected database
    password:
    # database corresponds to the database to be used in postgres
    database: tyk_analytics
    # sslmode corresponds to if postgres runs in sslmode (https)
    sslmode: disable
    # Connection string can also be set using a secret. Provide the name of the secret and key below.
    # connectionStringSecret:
    #   name: ""
    #   keyName: ""

Hybrid Pump

Hybrid Pump can be configured by setting pump.backend to hybrid. Set the connection details of your control plane in global.remoteControlPlane field of values file. Connection details can be stored either directly in the values file or you can store it in k8s secret and provide reference to it in the global.remoteControlPlane.useSecretName field. The MDCB connection string has its own, independent secret reference: global.remoteControlPlane.connectionStringSecretName.

  # Set remoteControlPlane connection details if you want to configure hybrid pump.
  remoteControlPlane:
      # useSecretName can be used if you don't want to store plaintext values for remote control plane configurations in
      # the Helm value file and would rather provide the k8s Secret externally.
      # You should set following fields in the secret
      # - orgId - Sets slave_options.rpc_key of Tyk Gateway
      # - userApiKey - Sets slave_options.api_key of Tyk Gateway
      # - groupID - Sets slave_options.group_id of Tyk Gateway
      useSecretName: ""
      # connection string used to connect to an MDCB deployment. For Tyk Cloud users, you can get it from Tyk Cloud Console and retrieve the MDCB connection string.
      # Set this as a literal value, OR (alternatively) load it from a k8s secret by setting connectionStringSecretName below.
      connectionString: ""
      # connectionStringSecretName — when set, the pump reads the MDCB connection string from this k8s
      # Secret instead of the literal connectionString above. Independent of useSecretName (which only
      # covers orgId/userApiKey/groupID). The secret may be the same one referenced by useSecretName, or
      # a separate secret. Default key looked up in the secret is "connectionString" (override via
      # connectionStringSecretKey).
      connectionStringSecretName: ""
      # connectionStringSecretKey — key name inside connectionStringSecretName to read. Defaults to
      # "connectionString" when unset.
      connectionStringSecretKey: ""
      # orgID of your dashboard user
      orgId: ""
      # API key of your dashboard user
      userApiKey: ""
      # needed in case you want to have multiple data-planes connected to the same redis instance
      groupID: ""
      # enable/disable ssl
      useSSL: true
      # Disables SSL certificate verification
      sslInsecureSkipVerify: true
  # hybridPump configures Tyk Pump to forward Tyk metrics to a Tyk Control Plane.
  # Please add "hybrid" to .Values.pump.backend in order to enable Hybrid Pump.
  hybridPump: 
    # Send aggregated analytics data to Tyk MDCB
    enableAggregateAnalytics: true
    # Hybrid pump RPC calls timeout in seconds. If not specified, default value will be picked up by Tyk Pump.
    callTimeout: 10
    # Hybrid pump connection pool size. If not specified, default value will be picked up by Tyk Pump.
    poolSize: 5

Uptime Pump

Uptime Pump can be configured by setting pump.uptimePumpBackend in values.yaml file. It supports following values

  1. mongo: Used to set mongo pump for uptime analytics. Mongo Pump should be enabled.
  2. postgres: Used to set postgres pump for uptime analytics. Postgres Pump should be enabled.
  3. empty: Used to disable uptime analytics.

Other Pumps

To set up other backends for pump, refer to this document and add the required environment variables in pump.extraEnvs

Enable autoscaling

This chart allows for easy configuration of autoscaling parameters. To simply enable autoscaling it's enough to add --set pump.autoscaling.enabled=true. That will enable a Horizontal Pod Autoscaler resource with default parameters (avg. CPU load at 60%, scaling between 1 and 3 instances). To customize those values you can add --set pump.autoscaling.averageCpuUtilization=75 or use values.yaml:

pump:
  autoscaling:
    enabled: true
    minReplicas: 3
    maxReplicas: 5

Prerequisite — resource requests are required for CPU/memory autoscaling. The Horizontal Pod Autoscaler scales on utilization measured as a percentage of the Pod's resource requests, so you must set pump.resources.requests for each resource you autoscale on (pump.resources.requests.cpu for CPU, pump.resources.requests.memory for memory). Without a request set, the HPA cannot compute utilization and will not scale the deployment. Custom metrics configured via pump.autoscaling.autoscalingTemplate are not subject to this requirement.

Note on maxReplicas. Size minReplicas/maxReplicas to your cluster's capacity and expected load — the values above are only an example. A high ceiling can drive significant resource consumption and cost under load; consider bounding total usage with a Kubernetes ResourceQuota.

Built-in rules include pump.autoscaling.averageCpuUtilization for CPU utilization (set by default at 60%) and pump.autoscaling.averageMemoryUtilization for memory (disabled by default). In addition to that you can define rules for custom metrics using pump.autoscaling.autoscalingTemplate list:

pump:
  autoscaling:
    autoscalingTemplate:
      - type: Pods
        pods:
          metric:
            name: nginx_ingress_controller_nginx_process_requests_total
          target:
            type: AverageValue
            averageValue: 10000m

You can also tune how quickly the autoscaler scales up and down using pump.autoscaling.behavior, which is passed through as-is to the HPA's [spec.behavior](https://kubernetes.io/docs/tasks/run-appli

Deploy tyk-pump with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has tyk-pump on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charttyk-pump is pinned at v5.5.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply