Gateway connection to Redis in Kubernetes

Thank you for your time Valmir, Ubong,

I will try to follow all your steps…

Can you also set this to true tyk-helm-chart/values.yaml at master · TykTechnologies/tyk-helm-chart · GitHub.

Please, note I am not using helm with this. However, I was setting storage.enable_cluster: true on my conf file. Is it the same? or do you refer to another setting?

Can the pods reach one another, i.e curl{gateway_url}:{port}/hello and/or list keys (keys *) after adding a random key? This will give us whether the pods can communicate with each other or not. This will also help us understand if your Redis connection is storing proper values. I noticed your earlier comment about different/ same namespaces but I just want to reconfirm that above again ^.

  • Please post the keys * from the master.
  • Also what is returned from your {gateway_url}:{port}/hello endpoint?

About Redis:

[devops@master-node redis]$ kubectl -n redis exec -it redis-cluster-0  -- bash
Defaulted contster-0:/data# redis-cli -h redis-cluster-0.redis-cluster.redis.svc.cluster.local -p 6379 -c
redis-cluster-0.redis-cluster.redis.svc.cluster.local:6379> set test "some_value"
-> Redirected to slot [6918] located at 10.244.4.218:6379
OK
10.244.4.218:6379> set test2 "another_value"
OK
10.244.4.218:6379> keys *
1) "test"
2) "test2"
10.244.4.218:6379>

About tyk (from redis master #0):

[devops@master-node tyk-oss-k8s-deployment]$ kubectl -n tyk get pods -o wide
NAME                           READY   STATUS    RESTARTS   AGE     IP             NODE      NOMINATED NODE   READINESS GATES
tyk-gateway-65df8fdb9c-d265p   1/1     Running   0          3m49s   10.244.3.145   w-node3   <none>           <none>
[devops@master-node tyk-oss-k8s-deployment]$ kubectl -n redis exec -it redis-cluster-0  -- bash
root@redis-cluster-0:/data# curl 10.244.3.145:8081/hello
{"status":"fail","version":"4.2.1","description":"Tyk GW","details":{"redis":{"status":"fail","output":"storage: Redis is either down or was not configured","componentType":"datastore","time":"2022-09-28T12:01:57Z"}}}

I also notice from the gateway you provided that you have addrs inside storage and then you have redis_addrs . Can you confirm you deleted the redis_addrs portion entirely?

I have been using this .conf file on last test:

root@tyk-gateway-65df8fdb9c-d265p:/opt/tyk# cat tyk.conf
{
  "listen_address": "",
  "listen_port": 8081,
  "secret": "352d20ee67be67f6340b4c0605b044b7",
  "template_path": "/opt/tyk/templates",
  "tyk_js_path": "/opt/tyk/js/tyk.js",
  "middleware_path": "/opt/tyk/middleware",
  "use_db_app_configs": false,
  "db_app_conf_options": {
      "connection_string": "http://tyk-dashboard.tyk.svc.cluster.local:3000",
      "node_is_segmented": false,
      "tags": ["test2"]
  },
  "app_path": "/opt/tyk/apps/",
  "storage": {
    "type": "redis",
    "enable_cluster": true,
    "addrs": [
        "redis-cluster-0.redis-cluster.redis.svc.cluster.local:6379",
        "redis-cluster-3.redis-cluster.redis.svc.cluster.local:6379",
        "redis-cluster-1.redis-cluster.redis.svc.cluster.local:6379",
        "redis-cluster-4.redis-cluster.redis.svc.cluster.local:6379",
        "redis-cluster-2.redis-cluster.redis.svc.cluster.local:6379",
        "redis-cluster-5.redis-cluster.redis.svc.cluster.local:6379"]
    ,
    "database": 0,
    "optimisation_max_idle": 2000,
    "optimisation_max_active": 4000,
    "username": "",
    "password": "",
    "use_ssl": false
  },
  "enable_analytics": false,
  "optimisations_use_async_session_write": true,
  "enable_non_transactional_rate_limiter": true,
  "enable_sentinel_rate_limiter": false,
  "enable_redis_rolling_limiter": false,
  "allow_master_keys": false,
  "hash_keys": true,
  "close_connections": true,
  "http_server_options": {
    "enable_websockets": true
  },
  "allow_insecure_configs": true,
  "coprocess_options": {
    "enable_coprocess": false,
    "coprocess_grpc_server": ""
  },
  "enable_bundle_downloader": true,
  "bundle_base_url": "",
  "global_session_lifetime": 100,
  "force_global_session_lifetime": false,
  "max_idle_connections_per_host": 100
}

I will try to answer you trying standalone redis and with the files in a next post…

Thank you very much for all your efforts