GitHub user YhebBOUSSELMI edited a comment on the discussion: Does Redis auth 
works through envFromSecret ?

I ran into this issue and solved it by overriding the _superset-config_  helper 
defined in the superset [_helper.tpl 
file](https://github.com/apache/superset/blob/21f85a414511cf298b6f6531792b846e59926a56/helm/superset/templates/_helpers.tpl#L65)
 
**The Problem**:
When the Redis password is provided via a Kubernetes secret (rather than 
directly in values.yaml), the Helm template condition {{- if 
.Values.supersetNode.connections.redis_password }} evaluates to false. This 
causes the password authentication to be excluded from the generated config, 
even though the password will exist at runtime as an environment variable.

**The Solution**:
I moved the password check from Helm template logic to Python runtime logic. 
Instead of conditionally including the password field during template 
rendering, which always lets Python check if the REDIS_PASSWORD environment 
variable exists.

### Change 1: Redis Base URL
I replace this:

```
# Redis Base URL
{{- if .Values.supersetNode.connections.redis_password }}
REDIS_BASE_URL=f"{env('REDIS_PROTO')}://{env('REDIS_USER', 
'')}:{env('REDIS_PASSWORD')}@{env('REDIS_HOST')}:{env('REDIS_PORT')}"
{{- else }}
REDIS_BASE_URL=f"{env('REDIS_PROTO')}://{env('REDIS_HOST')}:{env('REDIS_PORT')}"
{{- end }}
```

With this: 
```
# Redis Base URL
REDIS_USER = env('REDIS_USER', '')
REDIS_PASSWORD = env('REDIS_PASSWORD', '')

if REDIS_PASSWORD:
    REDIS_BASE_URL = 
f"{env('REDIS_PROTO')}://{REDIS_USER}:{REDIS_PASSWORD}@{env('REDIS_HOST')}:{env('REDIS_PORT')}"
else:
    REDIS_BASE_URL = 
f"{env('REDIS_PROTO')}://{env('REDIS_HOST')}:{env('REDIS_PORT')}"
```    
    
### Change 2: RESULTS_BACKEND
I replaced this: 
```
RESULTS_BACKEND = RedisCache(
      host=env('REDIS_HOST'),
      {{- if .Values.supersetNode.connections.redis_password }}
      password=env('REDIS_PASSWORD'),
      {{- end }}
      port=env('REDIS_PORT'),
      key_prefix='superset_results',
      {{- if .Values.supersetNode.connections.redis_ssl.enabled }}
      ssl=True,
      ssl_cert_reqs=env('REDIS_SSL_CERT_REQS'),
      {{- end }}
)
```

With this:     
```
# Build Redis cache config dynamically
redis_cache_config = {
    'host': env('REDIS_HOST'),
    'port': env('REDIS_PORT'),
    'key_prefix': 'superset_results',
}

# Add password if present
if env('REDIS_PASSWORD'):
    redis_cache_config['password'] = env('REDIS_PASSWORD')

# Add SSL config if cert reqs is set
if env('REDIS_SSL_CERT_REQS'):
    redis_cache_config['ssl'] = True
    redis_cache_config['ssl_cert_reqs'] = env('REDIS_SSL_CERT_REQS')

RESULTS_BACKEND = RedisCache(**redis_cache_config)
```

I hope this helps! 
Cheers!

GitHub link: 
https://github.com/apache/superset/discussions/25240#discussioncomment-15012450

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to