exam questions

Exam CKA All Questions

View all questions & answers for the CKA exam

Exam CKA topic 1 question 9 discussion

Actual exam question from CNCF's CKA
Question #: 9
Topic #: 1
[All CKA Questions]

SIMULATION -


Task -
Check to see how many nodes are ready (not including nodes tainted NoSchedule) and write the number to /opt/KUSC00402/kusc00402.txt.

Show Suggested Answer Hide Answer
Suggested Answer:

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
SijoTharakan
Highly Voted 2 years, 1 month ago
kubectl get nodes -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect Reference: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#interacting-with-nodes-and-cluster
upvoted 19 times
leebug
1 year, 6 months ago
Thanks for the link to the reference!
upvoted 3 times
...
...
frankja2
Highly Voted 1 year, 2 months ago
are you drunk or on drugs? It says "NOT INCLUDING" but every answer is like getting those
upvoted 6 times
...
noahsark
Most Recent 1 month, 3 weeks ago
killer_sh_lab: k get no k describe no node01 | g taint # keep it simple, check each node, there’s only a few nodes. # count number of nodes accordingly not including nodes tainted NoSchedule, sample below: echo “2” > /opt/KUSC00402/kusc00402.txt
upvoted 2 times
...
137eceb
2 months, 1 week ago
k describe nodes | grep Taint | grep -v NoSchedule| wc -l > filename.txt
upvoted 2 times
...
Archanakaviya
2 months, 3 weeks ago
echo $(k get nodes --no-headers | grep 'Ready' | grep -v 'NoSchedule' | wc -l) > opt/KUSC00402/kusc00402.txt
upvoted 1 times
...
[Removed]
5 months, 1 week ago
kubectl get nodes --no-headers | grep -v 'NoSchedule' | grep -c ' Ready ' > /opt/KUSC00402/kusc00402.txt
upvoted 2 times
...
zanhsieh
8 months ago
k8s jsonpath doesn't support multiple filter conditions like: ...conditions[?(@.type=="Ready" && @.status=="True")].type ...conditions[?(@.type=="Ready" AND @.status=="True")].type So have to play around with extra grep as below. This shall handle node status Ready. k get no --no-headers -o='custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect,Status:.status.conditions[?(@.type=="Ready")].status' | grep -v NoSchedule | grep True > /opt/KUSC00402/kusc00402.txt
upvoted 1 times
...
plamennfs
8 months, 4 weeks ago
The easiest solution and smart solution is : k describe nodes | grep -i taint | grep none -c > /opt/KUSC00402/kusc00402.txt
upvoted 1 times
wwwmmm
4 months ago
I tested, this one works
upvoted 1 times
...
...
thanhnv142
9 months, 2 weeks ago
step 1: kubectl get nodes - o yaml | grep taint step 2: check the tainted and export to the file
upvoted 2 times
...
fc146fc
10 months, 2 weeks ago
kubectl get nodes –no-headers -o='custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect' | grep -v NoSchedule | wc -l > /opt/KUSC00402/kusc00402.txt
upvoted 2 times
...
Einthu
1 year, 3 months ago
k get nodes -o jsonpath='{range.items[*]}{.metadata.name}{"\t"}{.spec.taints[?(.effect == "NoSchedule")]}{"\n"}{end}'
upvoted 2 times
...
femijohn123
1 year, 3 months ago
k get nodes -o yaml --no-headers | grep -i taint | wc -l #this will show the tainted nodes
upvoted 1 times
...
Samm1
1 year, 4 months ago
From my understanding of the question: -c command will count the occurrence, for example of 2 node with 1 tainted node kubectl get nodes -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect| grep -c NoSchedule > to1.txt cat to1.txt. # 1
upvoted 2 times
...
Shenannigan
1 year, 4 months ago
I was able to accomplish this with the following command: k get nodes --no-headers -o custom-columns=Name:.metadata.name,Taint:.spec.taints[*].effect,Ready:'{.status.conditions[?(@.reason == "KubeletReady")].status}' | grep -v NoSchedule | wc -l you can remove the | wc -l to see the output
upvoted 1 times
Shenannigan
1 year, 4 months ago
modified to pull type instead of True/False value so you get the ready output k get nodes --no-headers -o custom-columns=Name:.metadata.name,Taint:.spec.taints[*].effect,Ready:'{.status.conditions[?(@.reason == "KubeletReady")].type}' | grep -v NoSchedule
upvoted 2 times
...
...
Shepardos
1 year, 4 months ago
kubectl describe node | grep -ie Ready -ie taint
upvoted 2 times
...
mellohello
1 year, 6 months ago
controlplane $ vim /opt/KUSC00402/kusc00402.txt write the number of the nodes, then save the doc! controlplane $ cat /opt/KUSC00402/kusc00402.txt
upvoted 2 times
...
mellohello
1 year, 6 months ago
kubectl describe node | grep -i taint > /opt/KUSC00402/kusc00402.txt
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago