Skip to content

Instantly share code, notes, and snippets.

@jay-johnson
Last active October 10, 2018 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jay-johnson/7cdf932e7595a6107175ad7cb5ce58e5 to your computer and use it in GitHub Desktop.
Save jay-johnson/7cdf932e7595a6107175ad7cb5ce58e5 to your computer and use it in GitHub Desktop.
Bash function for logging into a Kubernetes container and running a command with support for N-args
function sl() {
use_namespace="default"
pod_name=$(kubectl get pods -n ${use_namespace} | awk '{print $1}' | grep api | head -1)
kubectl exec -it \
${pod_name} \
-n ${use_namespace} \
-- bash -c ". /opt/venv/bin/activate && sp -q 'index=\"antinex\" AND ${@}' -u trex -p 123321 -i antinex -a splunk-svc:8089 | grep -v urllib3.connectionpool"
# -- bash -c ". /opt/venv/bin/activate && echo \"sp -q 'index=\"antinex\" AND ${@}' -u trex -p 123321 -a splunk-svc:8089 | grep -v urllib3\" && sp -q '${@}' -u trex -p 123321 -i antinex -a splunk-svc:8089 | grep -v urllib3.connectionpool"
}
@jay-johnson
Copy link
Author

jay-johnson commented Oct 10, 2018

sl user-sz
2018-10-10 07:08:49,158 - root - INFO - 2018-10-10 06:40:38.505528 user-sz - INFO - celery=True - found user={'id': 2, 'username': 'trex', 'email': 'bugs@domain.com'} 
2018-10-10 07:08:49,158 - root - INFO - 2018-10-10 06:40:38.228807 user-sz - INFO - created id=2 user=trex email=bugs@domain.com 
2018-10-10 07:08:49,159 - root - INFO - 2018-10-10 06:40:37.955799 user-sz - INFO - creating user=trex email=bugs@domain.com 

and

sl user_api
2018-10-10 07:09:25,545 - root - INFO - 2018-10-10 06:40:37.953570 user-api - INFO - user_api create 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment