Kubernets resource management super easy to use command record

Need to organize the resource overhead of all projects
 

# 管理节点获取数据
kubectl get pods -o json -A | jq -r '.items[] | {name: .metadata.name, cpu: .spec.containers[].resources.requests.cpu, memory: .spec.containers[].resources.requests.memory}'

# 加工数据成JSON
sed -i '1i[' 1.txt  && sed -i 's/}/},/g' 1.txt && tac 1.txt > temp.txt && sed -i '0,/,/{s/,/]/}' temp.txt &&tac temp.txt > 2.txt


Script function: add a comma after }, and then add [delete the last line, add one] at the front

Post it to https://uutool.cn/json2excel/ and you can download the resource description file above.

Guess you like

Origin blog.csdn.net/lansye/article/details/132578993