previously I was using a python statement like os.system("kubectl exec --it bash xxx") to exec into a kubernetes pod, it ends up redirect me to the bash of the pod and I could type commands directly. Someone recommended using subprocess.Popen instead because it is safer, so I tried something like
subprocess.Popen(["kubectl", "exec"] + kube_args + ["-it", pod_name, "--", "bash"],
stdout=subprocess.PIPE)
the python script run through, but it end up like nothing has happened(not redirecting me to the interactive bash of the pod. What should be the correct equivalent of the command in order to achieve this? Thank you.