Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Create a `export-pod-name.sh` file with the following content:
- ```shell
- 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)
- # Example:
- # POD_NAME=$(kubectl get pods --sort-by=.metadata.creationTimestamp --selector=app=nginx -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | tail -n1)
- export POD_NAME=$POD_NAME
- ```
- 1. Run script (notice the dot at the beginning!)
- ```shell
- . export-pod-name.sh
- ```
Add Comment
Please, Sign In to add comment