I’m a beginner for kubernetes and trying to use APScheduler with FastAPI in Kubernetes. The jobs are stored in redis.
FastAPI with APScheduler is running in pod A, Redis is running in pod B, so I need to connect redis between pods.
For redis, when I disable the password, got the connection error from APScheduler, but with a password it still shows the error below.
WARNING | logging:callHandlers:1706 – Error getting due jobs from job store ‘default’: Authentication required.
Redis yaml
file in Kubernetes:
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
labels:
app: redis
data:
redis.conf: |-
dir /srv
port 6379
bind 0.0.0.0
appendonly yes
daemonize no
protected-mode yes
requirepass ispassword
pidfile /srv/redis-6379.pid
The code for scheduler:
REDIS = {
'host': 'service-redis.default.svc.cluster.local',
'port': 6379,
'db': 5,
'password': 'ispassword',
'jobs_key': f'apscheduler.jobs.{settings.tsak_id}',
'run_times_key': f'apscheduler.run_times.{settings.task_id}'
}
jobstores = {"default": RedisJobStore(**REDIS)}
Schedule = AsyncIOScheduler(jobstores=jobstores)
There is a pod with another fastapi container and I have tested, redis is connectable.
Does anyone knows the reason behind this error and who should I fix it? Or what I did wrong with kubernetes and APScheuler? Thank you for any advice.
SenkuuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.