[BTBS] How to use JSONPATH and Go-template in kubernetes/openshift?

preview_player
Показать описание
Hi Welcome to BTBS.

Today, I will talk about template output in kubernetes and openshift.

As a kubernetes/openshift administrator, what kind of command do you use the most?

Is it oc get pod/ kubectl get namespace?

That is very typical command lines that you usually use. However, when you try to get some specific data from object or list, what do you use?

In my case, I used to bash command like awk, grep, sed and so on because those commands are very failiar to me.

But, oc and kubectl already has a good feature to filter data and manipulate data by template.

Today, I will show you 10 command lines to understand jsonpath and go-template in kuberentes and openshift.

1. Get single string (Gather clusterIP from service object)

2. Get single string from list
jsonpath type

go-template type

template string

3. Get the word that match your condition( Gather pod names that are not running state in a project)

4. Get the word that match your condition by go-template (Gather pod names that are not running state in all projects).

5. Clean all pods that are not running state.
json-path style:

go-template style:

6. Gather pod information which are not running state.

7. Gather Elastic Search Data Usage

8. Gather Elastic Search Logging Image version

9. Gather Metrics Image version

10. Gather map value like environment value?

11. Gather string with complex data.

12. Delete orphan Docker images

Рекомендации по теме
Комментарии
Автор

Why do you quote 'go-template={}' unlike jsonpath='{}'. I saw some othe people do this way, could you tell me the reason why?

j.h.
Автор

Hi, Thanks for the video, it would be nice if you can post these command on github.

sureshvishnoi
welcome to shbcf.ru