你好,我想将环境变量值传递给一个作业。为了做到这一点,我使用以下 Kubernetes 模板:
apiVersion: batch/v1
kind: Job
metadata:
name: socksdownloader
spec:
template:
spec:
containers:
- name: socksdownloader
image: socksdownloader:0.0.1
# env:
# - name: REDIS_HOST
# value: redis
# - name: REDIS_PORT
# value: 6379
# - name: REDIS_DB
# value: 0
# - name: REDIS_KEY
# value: "SOCK:"
command: ["python", "src/main.py"]
restartPolicy: Never
backoffLimit: 4
如果我取消yml文件中的env条目的注释,将会得到以下错误:
请求无效:patch: 无效的值:"map[metadata:map[annotations:map[kubectl.kubernetes.io/last-applied-configuration:{"apiVersion":"batch/v1","kind":"Job","metadata":{"annotations":{},"name":"socksdownloader","namespace":"default"},"spec":{"backoffLimit":4,"template":{"spec":{"containers":[{"command":["python","src/main.py"],"env":[{"name":"REDIS_HOST","value":"redis"},{"name":"REDIS_PORT","value":6379},{"name":"REDIS_DB","value":0},{"name":"REDIS_KEY","value":"SOCK:"}],"image":"socksdownloader:0.0.1","name":"socksdownloader"}],"restartPolicy":"Never"}}}}\n]] spec:map[template:map[spec:map[]]]]": 无法将int64转换为string
问题是如何将这些值传递给一个Job,以便可以连接到redis。
谢谢。