[英]Setting requirepass with args while deploying Redis in k8s works with $() but not with ${}
我正在嘗試將 Redis (通過創建 Helm 圖表)部署為 Kubernetes 集群中的 StatefulSet。 I am not creating another Redis image on top of Official Redis Docker image, rather I am just trying to use the defaults available in Official Redis Docker image and just provide my redis.conf
and requirepass
at runtime.
為了提供redis.conf
,我使用 ConfigMap 並將其安裝在容器的/config/redis.conf
中。
現在,我想在 Kubernetes --requirepass
選項作為args
傳遞,如下所示:
...
containers: [
{
name: redis,
image: {
repository: redis,
tag: 5.0
},
imagePullPolicy: Always,
workingDir: /data/,
args: [ "/config/redis.conf", "--requirepass", "<password>" ], # line of concern
ports: [
containerPort: 6379
],
env: [
{
name: REDIS_AUTH,
valueFrom: {
secretKeyRef: {
name: redis,
key: password
}
}
}
],
...
以下行失敗:
args: [ "/config/redis.conf", "--requirepass", "${REDIS_AUTH}" ]
相反,這有效:
args: [ "/config/redis.conf", "--requirepass", "$(REDIS_AUTH)" ]
即使$()
語法用於命令替換, REDIS_AUTH
是環境變量而不是可執行文件,它是如何工作的,而${REDIS_AUTH}
不是?
這是 Kubernetes 的特定功能,如果您想在command
或args
字段中擴展環境變量,那么您必須使用$()
語法而不是${}
語法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.