I'm trying to setup the Azure Face recognition container, but wondering how to use a k8 secret as a Docker command "argument."
This works, but I need to replace the ApiKey with my k8 secret.
{
"kind": "Deployment",
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "azure-face",
"args": [
"Eula=accept",
"Billing=https://microsoft.com",
"ApiKey=123"
]
}
]
}
}
}
}
Create secret like this:
kubectl create secret generic azure-api-key --from-literal=azure-api-key="123"
Tried changing the container args like this but it doesn't work - arugment is not passed as expected: (also tried other variations like 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"
}
}
}
]
}
]
Also did docker exec and from inside container verified that:
$ echo $AZURE_API_KEY
$ 123
Looks like this was the issue thanks to @Blokje5:
Note: The environment variable appears in parentheses, "$(VAR)". This is required for the variable to be expanded in the command or args field.
I had tried ${VAR} not $(VAR).