I have misunderstanding with how to execute $() commands in exec. i'm creating a job in kubernetes with this params:
command:
- ./kubectl
- -n
- $MONGODB_NAMESPACE
- exec
- -ti
- $(kubectl
- -n
- $MONGODB_NAMESPACE
- get
- pods
- --selector=app=$MONGODB_CONTAINER_NAME
- -o
- jsonpath='{.items[*].metadata.name}')
- --
- /opt/mongodb-maintenance.sh
but the part with $(kubectl -n ... --selector ...) is treated as a string and don't execute. Please tell me how to do it properly. Thanks!
From the output of the kubectl exec, I noticed that you can use
--
to separate your argumentsAs far as I know this is not achievable by putting each section as an array element. Instead you can do something like the following: