Reputation: 2935
echo "import /opt/tomcat/webapps/identityiq/WEB-INF/config/BLANKIdentity.xml" | /opt/tomcat/webapps/identityiq/WEB-INF/bin/iiq console)
This command works if kubectl exec -it [container] -n [namespace] -- /bin/bash and then run it from the console.
However, if I try to: kubectl exec [container] -n [namespace] -- echo "import /opt/tomcat/webapps/identityiq/WEB-INF/config/BLANKIdentity.xml" | /opt/tomcat/webapps/identityiq/WEB-INF/bin/iiq console
..it claims not to be able to find 'iiq'.
I've tried variables on relative vs. absolute pathing and am currently just defaulting to absolute paths to make sure nothing is getting lost in translation there.
I've also tried variations like: kubectl exec [container] -n [namespace] -- /bin/bash <(echo "import /opt/tomcat/webapps/identityiq/WEB-INF/config/BLANKIdentity.xml" | /opt/tomcat/webapps/identityiq/WEB-INF/bin/iiq console)
any suggestions?
Upvotes: 0
Views: 263
Reputation: 312868
When you run kubectl exec ... <somecommand> | <anothercommand>
, anything after the |
is execute on your local host, not inside the remote container. It's just a regular shell a | b | c
pipeline, where a
in this case is your kubectl exec
command.
If you want to run a shell pipeline inside the remote container, you'll need to ensure you pass the entire command line to the remote container, for example like this:
kubectl exec somepod -- sh -c '
echo "import /opt/tomcat/webapps/identityiq/WEB-INF/config/BLANKIdentity.xml" |
/opt/tomcat/webapps/identityiq/WEB-INF/bin/iiq console
'
Here, we're passing the pipeline as an argument to the sh -c
command in the pod.
Upvotes: 1