我想在 Openshift 的每個 pod 中的腳本中執行一個本地函式。
function1() {
...
}
function2() {
...
}
verify() {
... # the function I want to execute in each pod
}
main() {
# $1: openshift host
if ! oc projects > /dev/null; then
oc logout
oc login "$1"
fi
while IFS= read -r project;
do
oc project $project
while IFS= read -r pod;
do
echo Check pod $pod
type verify # here it says it's a function
## how do we put it here?? this does not work, nothing happens, it just hangs. I expect "type verify" to be a function in the pod, just like above
oc exec $pod -- bash -s "export -f function1; export -f function2; export -f verify; type verify; verify"
done <<< $(oc get pods | awk '/broker*/ {print $1}')
done <<< $(oc projects | awk '{ some logic here }')
}
setup "$@"
main "$@"
我知道:
- 如果是腳本,我可以
oc exec $pod -- bash -s < my_script.sh - 如果它是一個簡單的命令,我可以這樣做:
oc exec $pod -- bash -c "date", 或oc rsh --no-tty=true date.
但現在它是一個本地功能,我不知道。
uj5u.com熱心網友回復:
like ssh,typeset將使您的功能在遠程 pod 上可用。
oc exec $pod -- bash -c "$(typeset -f function1); function1"
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/478102.html
標籤:重击 开班 openshift-客户端工具
上一篇:為什么我的嵌套If條件不起作用?
