An alternative to using jsonpath with kubectl is go templates!
Try switching this:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
kubectl get serviceaccount myserviceaccount --context supercoolcontext --namespace themagicalcloud -o jsonpath='{.secrets[0].name}'
```
To this and it should work just the same.
Since I know go templates pretty well, this is a good alternative for jsonpath syntax.
````shell
kubectl get serviceaccount myserviceaccount --context supercoolcontext --namespace themagicalcloud -o go-template='{{range .secrets }}{{.name}}{{end}}'
```
Further reading:
- [List Container images using a go-template instead of jsonpath](https://kubernetes.io/docs/tasks/access-application-cluster/list-all-running-container-images/#list-container-images-using-a-go-template-instead-of-jsonpath)
|
Webmentions
(No webmentions yet.)