Shell script for kubectl pod

4/26/2020

I am writing a shell script for automating the commands inside a kubectl pod. For entering into the pod I am using:

#!/bin/bash
winpty kubectl --kubeconfig="C:\config.kubeconfig" -n namespace exec -it podname bash
cd /
ls
sftp username@hostname.com

After the execution of the first command root directory becomes:

root@podname:/deployments#

then the remaining commands don't get executed. Is there any solution for this?

Thanks.

-- Ash Raf
bash
kubectl
kubernetes
kubernetes-pod
shell

0 Answers