tyk-gateway
by Tyk
A Helm chart for deploying the open source Tyk Gateway. Tyk Gateway is a fully open source Enterprise API Gateway, supporting REST, GraphQL, TCP and gRPC protocols. Tyk Gateway is provided ‘Batteries-included’, with no feature lockout. It enables organisations and businesses around the world to protect, secure, and process APIs and well as review and audit the consumed apis.
About this chart
Tyk Gateway
Tyk is an open source Enterprise API Gateway, supporting REST, GraphQL, TCP and gRPC protocols.
Tyk Gateway is provided ‘Batteries-included’, with no feature lockout. Enabling your organization to control who accesses your APIs, when they access, and how they access it. Tyk Gateway can also be deployed as part of a larger Full Lifecycle API Management platform Tyk Self-Managed which also includes Management Control Plane, Dashboard GUI and Developer Portal.
Introduction
This chart defines a standalone open source Tyk Gateway component 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 should already be installed or accessible by the gateway
Installing the Chart
To install the chart from the Helm repository in namespace tyk with the release name tyk-gateway:
helm repo add tyk-helm https://helm.tyk.io/public/helm/charts/
helm repo update
helm show values tyk-helm/tyk-gateway > values.yaml
Note: Set redis connection details first. See Configuration below.
helm install tyk-gateway tyk-helm/tyk-gateway -n tyk --create-namespace -f values.yaml
Uninstalling the Chart
helm uninstall tyk-gateway -n tyk
This removes all the Kubernetes components associated with the chart and deletes the release.
Upgrading Chart
helm upgrade tyk-gateway tyk-helm/tyk-gateway -n tyk
Note: pinned image tags and runAsUser
The runAsUser: 1000 defaults have been removed from gateway.securityContext (pod level) and
gateway.containerSecurityContext (container level) so that platforms such as OpenShift can assign a UID via a
Security Context Constraint. runAsNonRoot: true and fsGroup are retained, so kubelet now relies on the
image's USER directive.
The setupDirectories init container is the exception: because busybox has no USER directive of its own,
the chart gives it a concrete UID. The UID is resolved from
gateway.initContainers.setupDirectories.securityContext.runAsUser, then
gateway.containerSecurityContext.runAsUser, then gateway.securityContext.runAsUser, and finally defaults to
65532 to match the gateway image. This keeps directories under /mnt/tyk-gateway writable after upgrades that
retain an older gateway UID with --reuse-values. Override or disable the init block separately on OpenShift.
If you pin gateway.image.tag to a version whose image has no numeric USER — for example v5.9.1, which runs
as USER 0 — pods will fail admission on upgrade with CreateContainerConfigError: container has runAsNonRoot and image will run as root. Images with a symbolic user (such as the distroless nonroot user) fail the same
way, because kubelet cannot verify a non-numeric user. Check yours with
crane config <image> | jq -r '.config.User' before upgrading. Either move to a tag with a numeric USER (the
chart default is docker.tyk.io/tyk-gateway/tyk-gateway:v5.13.1, USER 65532), set an explicit
gateway.containerSecurityContext.runAsUser, or set gateway.containerSecurityContext.enabled: false to omit
the block entirely and let the cluster decide.
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-gateway > 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)
Tyk uses Redis for distributed rate-limiting and token storage. You may set global.redis.addr and global.redis.pass with redis connection string and password respectively.
If you do not already have redis installed, you can use these charts provided by Bitnami
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install tyk-redis bitnami/redis -n tyk --create-namespace
Follow the notes from the installation output to get connection details and password. The DNS name of your Redis as set
by Bitnami is tyk-redis-master.tyk.svc:6379 (Tyk needs the name including the port).
You can update them in your local values.yaml file under global.redis.addrs and global.redis.pass.
Alternatively, you can use --set flag to set it in Tyk installation. For example --set global.redis.pass=$REDIS_PASSWORD
Remote control plane credentials (hybrid / MDCB gateways)
When global.remoteControlPlane.enabled is true, the gateway's credentials can be supplied from externally managed
k8s Secrets rather than plaintext values. There are two independent settings:
global.remoteControlPlane.useSecretName— readsorgId,userApiKeyandgroupIDfrom the named Secret, using those exact key names.global.remoteControlPlane.connectionStringSecretName— reads the MDCB connection string from the named Secret intoTYK_GW_SLAVEOPTIONS_CONNECTIONSTRING. The key defaults toconnectionStringand can be overridden withglobal.remoteControlPlane.connectionStringSecretKey.
connectionStringSecretName is independent of useSecretName: setting useSecretName does not make the chart look up
the connection string in a secret, so an install that keeps a literal global.remoteControlPlane.connectionString in
values.yaml alongside a credentials secret continues to work unchanged. The two may point at the same Secret or at
different ones.
Enable autoscaling
This chart allows for easy configuration of autoscaling parameters. To simply enable autoscaling
it's enough to add --set gateway.autoscaling.enabled=true. That will enable 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 gateway.autoscaling.averageCpuUtilization=75 or use values.yaml file:
gateway:
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 30
Built-in rules include gateway.autoscaling.averageCpuUtilization for CPU utilization (set by default at 60%) and
gateway.autoscaling.averageMemoryUtilization for memory (disabled by default).
In addition to that you can define rules for custom metrics using gateway.autoscaling.autoscalingTemplate list:
gateway:
autoscaling:
autoscalingTemplate:
- type: Pods
pods:
metric:
name: nginx_ingress_controller_nginx_process_requests_total
target:
type: AverageValue
averageValue: 10000m
Graceful shutdown and rolling updates
For zero-downtime rollouts and scale-downs (for example when running behind an AWS ALB/NLB with
target-type: ip and pod readiness gates), you can tune how the Gateway pods terminate and how the
workload is updated:
gateway.terminationGracePeriodSeconds— how long (in seconds) Kubernetes waits for a pod to shut down gracefully before sendingSIGKILL. Unset by default, so the Kubernetes default of30sapplies. When you configure graceful shutdown, set this greater than the sum of the Gateway'sgraceful_shutdown_delay_secondsandgraceful_shutdown_timeout_duration.gateway.lifecycle— container lifecycle hooks (preStop/postStart). ApreStopsleep keeps a terminating pod alive while the load balancer deregisters the target and drains in-flight connections.gateway.strategy— the update strategy.typedefaults toRollingUpdate; you can overriderollingUpdate.maxSurgeandrollingUpdate.maxUnavailable(settingmaxUnavailable: 0is useful for zero-downtime deployments with readiness gates). Forkind: StatefulSet,maxSurgeis not applicable and is omitted.
gateway:
terminationGracePeriodSeconds: 60
lifecycle:
preStop:
sleep:
seconds: 40 # sleep action requires Kubernetes >= 1.29 (GA in 1.30)
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2
maxUnavailable: 0
The Gateway's own shutdown timings (graceful_shutdown_delay_seconds,
graceful_shutdown_timeout_duration) can be set via gateway.extraEnvs.
Note on lifecycle hook handlers: recent Tyk Gateway images are minimal and do not ship a shell or coreutils, so
exechandlers such as["/bin/sh", "-c", "sleep 40"]or["/bin/sleep", "40"]will fail with an executable-not-found error. Use the nativesleephandler shown above (Kubernetes 1.29+, GA in 1.30) instead — for connection draining it needs no shell and no network access.Two security points to keep in mind if you deviate from that:
- An
exechandler runs commands inside the container with the same permissions as the Gateway process, so any command should be carefully reviewed before rollout.- An
httpGethandler issues a request from inside the pod's network namespace, so it can reach in-cluster services and cloud metadata endpoints that are not exposed externally. If you use one, point it at a trusted endpoint on the Gateway itself, and make sure the URL neither returns sensitive data nor triggers a side effect.
Enabling TLS
We have provided an easy way of enabling TLS via the global.tls.gateway flag. Setting this value to true will
automatically enable TLS using the certificate provided under tyk-gateway/certs/cert.pem.
If you want to use your own key/cert pair, you must follow the following steps:
- Create a tls secret using your cert and key pair.
- Set
global.tls.gatewayto true. - Set
global.tls.useDefaultTykCertificateto false. - Set
gateway.tls.secretNameto the name of the newly created secret.
OpenTelemetry
To enable OpenTelemetry for Gateway set gateway.opentelemetry.enabled flag to true. It is disabled by default.
You can also configure connection settings for it's exporter. By default grpc exporter is enabled on localhost:4317 endpoint.
To enable TLS settings for the exporter, you can set gateway.opentelemetry.tls.enabled to true.
Deploy tyk-gateway with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has tyk-gateway 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the charttyk-gateway is pinned at v5.5.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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