☸️ Kubernetes

[Kubernetes] Json

loose 2024. 1. 4. 17:10
반응형

리눅스에서 Json 조회 방법

{
    "car": {
        "color": "blue",
        "price": "$20,000"
    },
    "bus": {
        "color": "white",
        "price": "$120,000"
    }
}

 

cat q2.json | jpath $.bus

cat q12.json | jpath $[0]

cat q13.json | jpath '$[0,3]'

 

$.bus

.으로 시작하면 Dictinaory( 맵 조회 )

.으로 시작하지 않으면 List ( 배열 조회 )

kubectl json

yaml 파일을 json 형태로 출력할 수 있다.

k get node -o json | cat -n

kubectl jsonpath

위의 json으로 출력된 결과 중 일부만을 선택해서 json으로 출력할 수 있다.

k get node -o jsonpath='{.items[*].metadata.name}' > /opt/outputs/node_names.txt

k get node -o jsonpath='{.items[*].status.nodeInfo.osImage}'

kubectl config view --kubeconfig=/root/my-kube-config -o jsonpath='{.users[*].name}'

 

kubectl --sort-by

kubectl get pv --sort-by=.spec.capacity.storage -o=custom-columns=NAME:.metadata.name,CAPACITY:.spec.capacity.storage

 

kubectl custom columns

k get deploy my-deploy -o custom-columns='NAME:.metadata.name'

 

 

 

728x90