Guest User

Untitled

a guest
Jun 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. 1. Create a `export-pod-name.sh` file with the following content:
  2.  
  3. ```shell
  4. POD_NAME=$(kubectl get pods --sort-by=.metadata.creationTimestamp --selector=YOUR-SELECTOR-KEY=YOUR-SELECTOR-VALUE -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | tail -n1)
  5. # Example:
  6. # POD_NAME=$(kubectl get pods --sort-by=.metadata.creationTimestamp --selector=app=nginx -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | tail -n1)
  7.  
  8. export POD_NAME=$POD_NAME
  9. ```
  10.  
  11. 1. Run script (notice the dot at the beginning!)
  12. ```shell
  13. . export-pod-name.sh
  14. ```
Add Comment
Please, Sign In to add comment