First get help to find out what are the syntax to use with custom-columns option:
# kubectl get nodes --help | grep -i custom-columns
Then
# mkdir -p /opt/KUSC00402
# kubectl get nodes -o custom-columns=:.metadata.name,:.spec.taints --no-headers | grep -v "NoSchedule" | wc -l > /opt/KUSC00402/kusc00402.txt
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
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
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
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
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
This section is not available anymore. Please use the main Exam Page.CKA Exam Questions
Log in to ExamTopics
Sign in:
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.
SijoTharakan
Highly Voted 2 years, 8 months agonaggar_30
5 months, 4 weeks agoleebug
2 years agofrankja2
Highly Voted 1 year, 9 months agoJasonwcc
Most Recent 3 days, 12 hours agoJasonwcc
5 days, 19 hours agojesmonsa
5 months, 1 week agonoahsark
8 months, 1 week ago137eceb
8 months, 3 weeks agoArchanakaviya
9 months ago[Removed]
11 months, 2 weeks agozanhsieh
1 year, 2 months agoplamennfs
1 year, 3 months agowwwmmm
10 months, 2 weeks agothanhnv142
1 year, 3 months agofc146fc
1 year, 4 months agoEinthu
1 year, 9 months agofemijohn123
1 year, 10 months agoSamm1
1 year, 10 months agoShenannigan
1 year, 10 months agoShenannigan
1 year, 10 months ago