happyso
study with happyso
happyso
전체 방문자
오늘
어제
  • 분류 전체보기 (302)
    • GIT (3)
    • 컴퓨터 기본 개념 (29)
    • 알고리즘 (125)
      • 알고리즘 문제 (115)
      • 알고리즘 개념 (10)
    • Go (2)
    • 클라우드 (54)
      • DevOps (4)
      • Kubernetes(쿠버네티스) (33)
      • AWS (6)
      • CKA (8)
    • 리눅스(Linux) (18)
      • 컨테이너(Container) (8)
    • Front (22)
      • JavaScript (2)
      • React (20)
    • Python (21)
      • Python 웹 크롤링 (11)
      • Django (7)
      • MachineLearning (3)
    • 데이터베이스 (6)
      • MariaDB (2)
      • MongoDB (4)
    • C언어 (5)
    • Trouble Shooting (2)
    • 네트워크 (8)
      • CCNA (5)
    • 보안 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • replace
  • 18
  • Patch
  • kubernetes
  • edit
  • 15
  • apply

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
happyso

study with happyso

클라우드/CKA

[CKA] Advanced kubectl commands

2022. 1. 3. 22:48

문제01

Get the list of nodes in JSON format and store it in a file at /opt/outputs/nodes.json.

[나의 풀이]

kubectl get nodes -o json > /opt/outputs/nodes.json

 

문제02

Get the details of the node node01 in json format and store it in the file /opt/outputs/node01.json.

[나의 풀이]

kubectl get nodes node01 -o json > /opt/outputs/node01.json

 

문제03

Use JSON PATH query to fetch node names and store them in /opt/outputs/node_names.txt.

Remember the file should only have node names.

[나의 풀이]

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

 

문제04

Use JSON PATH query to retrieve the osImages of all the nodes and store it in a file /opt/outputs/nodes_os.txt.

The osImages are under the nodeInfo section under status of each node.

[나의 풀이]

kubectl get nodes -o=jsonpath='{.items[*].status.nodeInfo.osImage}' > /opt/outputs/nodes_os.txt

 

문제 05

A kube-config file is present at /root/my-kube-config. Get the user names from it and store it in a file /opt/outputs/users.txt.

Use the command kubectl config view --kubeconfig=/root/my-kube-config to view the custom kube-config.

[나의 풀이]
kubectl config view --kubeconfig=/root/my-kube-config -o jsonpath='{.users[*].name}' > /opt/outputs/users.txt

 

문제06

A set of Persistent Volumes are available. Sort them based on their capacity and store the result in the file /opt/outputs/storage-capacity-sorted.txt.

[나의 풀이]

kubectl get pv -A --sort-by=.spec.capacity.storage > /opt/outputs/storage-capacity-sorted.txt

 

문제07

That was good, but we don't need all the extra details. Retrieve just the first 2 columns of output and store it in /opt/outputs/pv-and-capacity-sorted.txt.

The columns should be named NAME and CAPACITY. Use the custom-columns option and remember, it should still be sorted as in the previous question.

[나의 풀이]

kubectl get pv -A --sort-by=.spec.capacity.storage -o=custom-columns='NAME:metadata.name,CAPACITY:spec.capacity.storage' > /opt/outputs/pv-and-capacity-sorted.txt

문제08

Use a JSON PATH query to identify the context configured for the aws-user in the my-kube-config context file and store the result in /opt/outputs/aws-context-name.

[정답]

kubectl config view --kubeconfig=/root/my-kube-config -o jsonpath='{.contexts[?(@.context.user=="aws-user")].name}' > /opt/outputs/aws-context-name

 

저작자표시 비영리 (새창열림)

'클라우드 > CKA' 카테고리의 다른 글

[CKA] 네트워크 & 리눅스 명령어  (0) 2022.01.16
[CKA] Ligtning Lab  (0) 2022.01.02
[CKA] mock exam 03  (0) 2021.12.26
[CKA] mock exam 02  (0) 2021.12.26
[CKA] mock exam 01  (0) 2021.12.15
    '클라우드/CKA' 카테고리의 다른 글
    • [CKA] 네트워크 & 리눅스 명령어
    • [CKA] Ligtning Lab
    • [CKA] mock exam 03
    • [CKA] mock exam 02
    happyso
    happyso

    티스토리툴바