Skip to content

Instantly share code, notes, and snippets.

@mecampbellsoup
Created January 19, 2017 16:14
Show Gist options
  • Select an option

  • Save mecampbellsoup/2035b9850a9d5af621b2c77c9875e44b to your computer and use it in GitHub Desktop.

Select an option

Save mecampbellsoup/2035b9850a9d5af621b2c77c9875e44b to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script inspects the present working directoy (`pwd`) and uses the
# current repository's name to return the first running kubernetes pod which
# matches the name of the repository.
# e.g. You are working in $HOME/zipmark/users-api
# Running `current-pod` should return something like `users-api-3769667108-1ybyz`
# /foo/users-api becomes /foo/users
NAME=$(pwd | sed 's/-api//g')
# select string contents after the final /
SERVICE_NAME=${NAME##*/}
echo `kubectl get pods | grep $SERVICE_NAME | awk '{print $1}' | head -1`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment