List all the pods showing name and namespace with a json path expression
Suggested Answer: A
Get Premium CKA Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
35 comments · newest first
VI
Vi
11 months ago
Looks good, but I’d double-check the quotes.
SU
Susy
11 months ago
Totally agree, that command is super useful!
TA
Tamar
12 months ago
Wait, can you really get both name and namespace like that?
LA
Lamonica
12 months ago
I think the syntax is a bit off in that example.
DE
Deeanna
1 year ago
You can use `kubectl get pods -o=jsonpath='{.items[*].metadata.name}'` for just names.
YU
Yun
1 year ago
I think we just need to list the names and namespaces, but I'm not sure if the expression is complete as it is.
MA
Margarett
1 year ago
I'm a bit unsure about the syntax; I feel like there might be a mistake in how the json path is structured.
DA
Dante
1 year ago
I remember practicing a similar question, but I can't recall if we needed to include the brackets around the keys.
DA
Dahlia
1 year ago
I think the json path expression should be using double quotes instead of single quotes for the keys, right?
PA
Paris
1 year ago
I think I've got the right approach. Let me just double-check the syntax before I write down my answer.
BO
Bong
1 year ago
Wait, how do I format the JSON path expression again? I know it's something like .items[*]['metadata.name', 'metadata.namespace'] but I'm not 100% sure.
TR
Tresa
1 year ago
No problem, I've got this. The solution is to use the -o=jsonpath flag with kubectl get pods to return the fields we need.
MA
Maryann
1 year ago
Hmm, I'm a bit unsure about the exact syntax for the JSON path expression. I'll need to review my notes on that.
LE
Leonida
1 year ago
I think I can handle this one. The key is using the right JSON path expression to extract the name and namespace fields for each pod.
FR
Frederica
1 year ago
Is it just me, or does 'jsonpath' sound like the name of a hip new programming language?
MA
Malinda
1 year ago
Wait, do I need to include the curly braces around the field names? I always get that mixed up.
MA
Marla
1 year ago
Easy peasy, I got this! Kubectl is my middle name.
RO
Robt
1 year ago
User3: I love using kubectl, it makes managing pods so much easier.
RO
Rolande
1 year ago
User2: Nice, that command will list all the pods with their name and namespace.
MA
Maynard
1 year ago
User1: kubectl get pods -o=jsonpath=\'{.items[*]['metadata.name', 'metadata.namespace']}\'
AN
Annelle
1 year ago
Kubectl definitely makes it easy to work with Kubernetes resources.
AL
Alisha
1 year ago
That's a handy command to know for getting specific information about pods.
PE
Pearline
1 year ago
Nice job! Kubectl commands can be really powerful.
BE
Beckie
2 years ago
Okay, let's see if I can remember the syntax. Is it .items[*].metadata['name', 'namespace']?
BI
Billi
1 year ago
Oh, I see. Thanks for the correction!
ME
Meaghan
1 year ago
No, it's actually .items[*]['metadata.name', 'metadata.namespace']
MA
Marta
2 years ago
It's kubectl get pods -o=jsonpath=\'{.items[*]['metadata.name', 'metadata.namespace']}\'
CA
Casey
2 years ago
Wow, a JSON path expression! I feel like a coding wizard just reading that.
RO
Rolland
1 year ago
User1: I'll have to try it out next time I need to get specific information from my pods.
EV
Eve
1 year ago
User3: Exactly! It's a useful tool for customizing the output of kubectl commands.
VA
Vashti
2 years ago
User2: Oh, I see. So you can use it to get the name and namespace of pods with that command.
KA
Kathrine
2 years ago
User1: It's not as complicated as it sounds, just a way to extract specific data from JSON objects.
NA
Nana
2 years ago
What is it?
MA
Marta
2 years ago
I agree, but I remember the command for that.
NA
Nana
2 years ago
I think that question is quite tricky.