Other Topics

hahic·2023년 1월 10일
0

Kubernetes/CKA

목록 보기
11/13
post-thumbnail

JSON PATH

Key Value Pair VS Array/Lists VS Dictionary/Map


Advanced Kubectl Commands

JSON PATH query


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

핵심 명령어

  • k get nodes -o json > /opt/outputs/nodes.json
  • kubectl get node node01 -o json > /opt/outputs/node01.json
  • kubectl get nodes -o jsonpath='{.items[*].metadata.name}' > /opt/outputs/node_names.txt
  • k get nodes -o jsonpath='{.items[*].status.nodeInfo.osImage}' > /opt/outputs/nodes_os.txt
  • k config view --kubeconfig=/root/my-kube-config -o jsonpath='{.users[*].name}' > /opt/outputs/users.txt
  • k get pv --sort-by='{.spec.capacity.storage}' > /opt/outputs/storage-capacity-sorted.txt
  • k get pv --sort-by='{.spec.capacity.storage}' -o=custom-columns=NAME:.metadata.name,CAPACITY:.spec.capacity.storage > /opt/outputs/pv-and-capacity-sorted.txt
  • kubectl config view --kubeconfig=my-kube-config -o jsonpath="{.contexts[?(@.context.user=='aws-user')].name}" > /opt/outputs/aws-context-name
profile
👩‍💻 Junior Backend Developer

0개의 댓글