tyk-mdcb
by Tyk
A Helm chart for deploying Tyk MDCB.
About this chart
Tyk Multi Data Centre Bridge (MDCB)
Tyk’s Multi Data Centre Bridge (MDCB) is a separately licensed extension to the Tyk control plane that performs management and synchronisation of logically or geographically distributed clusters of Tyk API Gateways.
Introduction
This chart defines a standalone Tyk MDCB component on a Kubernetes cluster using the Helm package manager.
For typical usage, we recommend using following umbrella charts:
- For single data centre deployment, please use tyk-stack
- For multi data centre deployment, please use tyk-control-plane (Coming soon!)
Learn more about different deployment options
Prerequisites
- Kubernetes 1.19+
- Helm 3+
- Tyk Gateway
- Tyk Dashboard
- Redis should already be installed or accessible by the gateway
- MongoDB or PostgreSQL
Installing the Chart
To install the chart from the Helm repository in namespace tyk with the release name tyk-mdcb:
helm repo add tyk-helm https://helm.tyk.io/public/helm/charts/
helm show values tyk-helm/tyk-mdcb > values.yaml
Note:
- Set Redis connection details at
.Values.global.redis - Set MongoDB or Postgres connection details at
.Values.global.mongoor.Values.global.postgresrespectively. - The Tyk MDCB also requires a license to be set at
.Values.mdcb.license
helm install tyk-mdcb tyk-helm/tyk-mdcb -n tyk --create-namespace -f values.yaml
Uninstalling the Chart
helm uninstall tyk-mdcb -n tyk
This removes all the Kubernetes components associated with the chart and deletes the release.
Upgrading Chart
helm upgrade tyk-mdcb tyk-helm/tyk-mdcb -n tyk
Configuration
See Customizing the Chart Before Installing.
To get all configurable options with detailed comments:
helm repo add tyk-helm https://helm.tyk.io/public/helm/charts/
helm show values tyk-helm/tyk-mdcb > 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
Set MongoDB or PostgreSQL connection details (Required)
If you have already installed MongoDB or PostgreSQL, you can set the connection details in global.mongo and global.postgres section of values file respectively.
If not, you can use these rather excellent charts provided by Bitnami to install MongoDB or PostgreSQL:
MongoDB Installation
helm install tyk-mongo bitnami/mongodb --version {HELM_CHART_VERSION} --set "replicaSet.enabled=true" -n tyk
PostgreSQL Installation
helm install tyk-postgres bitnami/postgresql --set "auth.database=tyk_analytics" -n tyk
Follow the notes from the installation output to get connection details.
NOTE: Please make sure you are installing MongoDB or PostgreSQL versions that are supported by Tyk. Please refer to Tyk docs to get list of supported versions.
Tyk MDCB Configuration
Tyk MDCB License
Tyk MDCB requires a license to be set at .Values.mdcb.license. This field is mandatory and must be configured.
To enhance security and avoid storing plaintext values for the MDCB license directly in the Helm value file,
an alternative approach is available. You can store the license in a Kubernetes Secret and reference it externally.
Set the license in the Kubernetes Secret and provide the secret's name through .Values.mdcb.useSecretName.
The Secret must contain a key named MDCBLicense.
Tyk MDCB Listen Port
The .Values.mdcb.listenPort field represents a RPC port which worker Tyk Gateways will connect to.
Setting .Values.mdcb.listenPort field opens a port on MDCB container and MDCB service targets this port.
It is used to set TYK_MDCB_LISTENPORT
Tyk MDCB Health Check Port
The health check port for Tyk MDCB can be configurable via .Values.mdcb.probes.healthCheckPort field. This port lets MDCB allow standard health checks.
It also defines the path for liveness and readiness probes. It is used to set TYK_MDCB_HEALTHCHECKPORT
Enable autoscaling
MDCB can be scaled automatically with a HorizontalPodAutoscaler. It is disabled by default;
enable it with --set mdcb.autoscaling.enabled=true, which scales on average CPU utilization
(targetCPUUtilizationPercentage, default 80%) between minReplicas and maxReplicas. You can
also scale on memory via targetMemoryUtilizationPercentage. For example, in values.yaml:
mdcb:
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70
For custom or additional metrics beyond CPU/memory, use mdcb.autoscaling.autoscalingTemplate
(a list of extra HPA metric entries):
mdcb:
autoscaling:
autoscalingTemplate:
- type: Pods
pods:
metric:
name: nginx_ingress_controller_nginx_process_requests_total
target:
type: AverageValue
averageValue: 10000m
To control the scale-up/down policy, use mdcb.autoscaling.behavior, which maps directly to the
HPA behavior
field:
mdcb:
autoscaling:
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 100
periodSeconds: 15
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
mdcb.resources.requestsfor each resource you autoscale on (mdcb.resources.requests.cpufor CPU,mdcb.resources.requests.memoryfor memory). Without a request set, the HPA cannot compute utilization and will not scale the deployment. Custom metrics configured viamdcb.autoscaling.autoscalingTemplateare not subject to this requirement.
Caution — custom metrics and scaling policies are powerful knobs.
autoscalingTemplateandbehaviorare passed straight through to the HPA resource. An aggressive scale-up policy combined with a volatile metric can cause rapid, uncontrolled scaling and resource exhaustion. SizemaxReplicasto your cluster's capacity, test any custom configuration before production, and consider bounding total usage with a KubernetesResourceQuota.
Security contexts
Both .Values.mdcb.podSecurityContext and .Values.mdcb.containerSecurityContext are empty by default, and no
securityContext block is rendered at all. Add fields to either to have them applied.
To keep a block omitted after adding fields — for example so that OpenShift's SCC can allocate UID/GID — set
enabled: false on it. Setting the block to {} does not work, because Helm deep-merges the chart defaults back in.
mdcb:
podSecurityContext:
enabled: false
containerSecurityContext:
enabled: false
Each block is scoped independently, and the enabled key itself is never rendered into the manifest.
Deploy tyk-mdcb with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has tyk-mdcb 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-mdcb 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