-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Summary
There are several issues with the secrets templates in the tyk-stack Helm chart where secrets are created unconditionally or with incorrect logic, leading to unnecessary resources and potential confusion.
Issue 1: tyk-stack Secret is Always Created Regardless of useSecretName
File: tyk-stack/templates/secrets.yaml
Description
The tyk-stack secrets template creates a Secret unconditionally, ignoring the global.secrets.useSecretName setting. When a user specifies a pre-created secret via global.secrets.useSecretName, the chart should skip creating its own secret, but it doesn't.
Impact
- unnecessary secret created
Issue 2: tyk-pump Secret Creates mongoURL Even When Using PostgreSQL
File: components/tyk-pump/templates/secrets.yaml
Description
The pump secrets template creates a mongoURL entry in the secret even when PostgreSQL is configured as the database backend and MongoDB is not configured at all.
Current Behavior
The condition for creating the secret is:
{{- if not ( and ((.Values.global.redis.passSecret).name)
((.Values.global.mongo.connectionURLSecret).name)
((.Values.global.postgres.connectionStringSecret).name)) -}}This means the secret is created if any of the three secrets (redis, mongo, postgres) is not externally provided. Inside, it creates:
{{- if not ((.Values.global.mongo.connectionURLSecret).name) }}
mongoURL: {{ include "tyk-pump.mongo_url" . | quote }}
{{- end }}The problem is that when using PostgreSQL:
global.mongo.connectionURLSecret.nameis typically not set (because Mongo isn't used)- This triggers the creation of a
mongoURLfield with empty/default values - The outer condition also evaluates incorrectly because it requires ALL three secrets to be set
Expected Behavior
- The secret creation logic should be database-aware
- When using PostgreSQL, MongoDB-related fields should not be created
- The outer condition should use OR logic for optional backends, not AND logic
Issue 3: tyk-dashboard Secret Has Same MongoDB/PostgreSQL Logic Issue
File: components/tyk-dashboard/templates/secrets.yaml
Description
The dashboard secrets template has the same issue as the pump template - it creates MongoDB connection strings even when PostgreSQL is the configured backend.
Current Behavior
{{- if not ( and .Values.global.secrets.useSecretName
((.Values.global.redis.passSecret).name)
((.Values.global.mongo.connectionURLSecret).name)
((.Values.global.postgres.connectionStringSecret).name)) -}}This condition requires ALL of the following to be true to skip secret creation:
useSecretNameis set- Redis secret is externally provided
- Mongo secret is externally provided
- Postgres secret is externally provided
When using PostgreSQL only, the MongoDB secret is not provided (because it's not used), so the condition fails and creates the secret with MongoDB-related fields.
Expected Behavior
Same as Issue 2 - the logic should be:
- Database-aware (check if Mongo/Postgres is actually being used)
- Use OR logic for optional components
- Only create secrets for the database backend that is actually in use
Reproduction Steps
-
Deploy tyk-stack with PostgreSQL backend configured
-
Set
global.secrets.useSecretNameto reference a pre-created secret -
Configure
global.postgres.connectionStringSecret.namefor external postgres secret -
Do not configure any MongoDB settings (as it's not used)
-
Observe:
secret-tyk-stack-*is still created (Issue 1)- Dashboard and Pump secrets contain empty/default
mongoURL(Issues 2 & 3)