Skip to content

Instantly share code, notes, and snippets.

@viniciusjssouza
Created June 28, 2019 15:19
Show Gist options
  • Select an option

  • Save viniciusjssouza/42666e6d01b28ce2deaf1bf426d36929 to your computer and use it in GitHub Desktop.

Select an option

Save viniciusjssouza/42666e6d01b28ce2deaf1bf426d36929 to your computer and use it in GitHub Desktop.
run a command inside a running POD
#/bin/bash
# run a shell inside a running POD
# Paramenter 1: the name of the "app". The deployment should match <app_name>-deployment and the container must have the
# app name.
POD_NAME=$(kubectl get pods -n stock --no-headers -o custom-columns=":metadata.name" | grep -m1 "$1-deployment")
echo "Acessing pod $POD_NAME"
kubectl exec -it "$POD_NAME" -n stock -c "$1" -- sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment