I am tring to run the below code in python3 running on Centos8
namespace="abcnkabc51-admin-ns"
podtype="smd"
appPodName="smd-84b4bf8fcc"
cmd_appNodeNames="kubectl get pod --show-labels -o wide -n "+namespace+"|egrep \"app="+podtype+"\" |grep "+appPodName+"| awk \'{print $7}\'"
print("cmd_appNodeNames: ")
print(cmd_appNodeNames)
I am getting the printout like this-
cmd_appNodeNames:
| awk '{print $7}'show-labels -o wide -n abcnkabc51-admin-ns|egrep "app=smd" |grep smd-84b4bf8fcc
However, expected output would be as below-
cmd_appNodeNames:
kubectl get pod --show-labels -o wide -n abcnkabc51-admin-ns|egrep "app=smd" |grep smd-84b4bf8fcc| awk '{print $7}'
Would you please advise how can I fix this?
Regards,
Ashish