我正在尝试设置Azure 人脸识别容器,但想知道如何将 k8 机密用作 Docker 命令“参数”。
这可行,但我需要用我的 k8 密钥替换 ApiKey。
{
"kind": "Deployment",
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "azure-face",
"args": [
"Eula=accept",
"Billing=https://microsoft.com",
"ApiKey=123"
]
}
]
}
}
}
}
像这样创建秘密:
kubectl create secret generic azure-api-key --from-literal=azure-api-key="123"
尝试像这样更改容器参数,但它不起作用 - 参数未按预期传递:(还尝试了其他变体,如 ApiKey=${AZURE_API_KEY})
"containers": [
{
"args": [
"Eula=accept",
"Billing=https://microsoft.com",
"ApiKey=$AZURE_API_KEY"
],
"env": [
{
"name": "AZURE_API_KEY",
"valueFrom": {
"secretKeyRef": {
"name": "azure-api-key",
"key": "azure-api-key"
}
}
}
]
}
]
docker exec 和从容器内部也验证了:
$ echo $AZURE_API_KEY
$ 123