Hi All, I’m pleased to inform that I have passed CKA after more than 2 months of . . .

P S:
Hi All, I’m pleased to inform that I have passed CKA after more than 2 months of preparation. Thanks a lot @Mumshad Mannambeth for the great course. Thanks to @Tej_Singh_Rana @OE @runlevl4 @maheshwar reddy @Harindha Fernando for all the help and being available to help in this channel!!
My Experience and some tips:-

  1. Exam was smooth and luckily there were no issues with the platform during the exam.
  2. I did a mistake in first question itself! Used the switch context command given for the question, but did not create the resource in right NS.
  3. When I’m validating this, I got to know the mistake and corrected it. Did not do similar mistake for the rest of the questions. So if you stuck or something went wrong, quickly correct it if it’s possible, otherwise move ahead for the next question without wasting any time. Same for the questions where you have some doubt.
  4. While practicing, always validate your answer yourself by using kubectl commands, don’t just relay on the kodekloud UI which validates them automatically, this helps you to validate the answers in the exam as well.
  5. Using awk helped me for one of the jsonpath related question. So its good to know these linux commands which helps you get result without using any complex jsonpath query.
  6. If at all you want to use jsonpath itself, make sure you know this options as suggested by @OE in earlier posts.
kubectl get pods -o json | jq -c 'path(..)|[.[]|tostring]|join(".")'

and try to filter out managedFields related entries by using grep as below… and then do grep for the required field…

kubectl get pods -o json | jq -c 'path(..)|[.[]|tostring]|join(".")' | grep -vi managedfields

No need to remember the first jq command, it’s there in cheatsheet : https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources

All the best for those who are preparing!

Congrats @P S Glad I could help. And like @runlevl4 said, you get extra points for using awk :grinning:

maheshwar reddy:
Congrats @P S

P S:
Thanks @OE @maheshwar reddy

Mohamed Ayman:
Congratulations!! Thanks for sharing your experience!

@P S Congratulations! well done. Could you please share with us the uses case of awk command

@Amel ECHEIKH EZAOUALI Here are a couple of examples from things I tend to do in the real world.

List Only Pod Names

# kgp --no-headers | awk '{print $1}'

I frequently use awk to capture data to pipe to another command. Let’s say, for example, you want to review the logs for all the pods in a deployment. Maybe you’re troubleshooting an app and need to send the logs to someone. If you have one or two pods it isn’t a big deal but let’s make it easier.

# k get po -l app=nginx --no-headers
nginx-f89759699-g9h8f   1/1   Running   0     91m
nginx-f89759699-bqkkn   1/1   Running   0     91m
nginx-f89759699-rnnlq   1/1   Running   0     91m

So we have three nginx pods. We’ll grab the pod name and use that in a loop to grab the logs.

# for po in $(k get po -l app=nginx --no-headers | awk '{print $1}'); do k logs $po > $po.log; done
total 24
-rw-r--r--  1 runlevl4  staff   583B Dec 12 15:47 nginx-f89759699-bqkkn.log
-rw-r--r--  1 runlevl4  staff   583B Dec 12 15:47 nginx-f89759699-g9h8f.log
-rw-r--r--  1 runlevl4  staff   583B Dec 12 15:47 nginx-f89759699-rnnlq.log

In this command we get the pods without headers and pipe the output to awk to print the first column which is the pod name. We assign the name to a variable named po. Then we use that in the k logs command.

Those are a couple of simple examples.

@runlevl4 thank you very much for your detailed explanation, it’s clear for me and it’s very helpful in production environment which contains serval object pods,svc, deploy…but i think is not useful in CKA exam as we don’t have so much objects

I can agree with that especially with these examples. The utility is there, though. The awk command can definitely be used for other tasks, though. I doubt you’ll have a task to save all of the logs. :slightly_smiling_face:

Mumshad Mannambeth:
Great stuff!! Congratulations!!!

P S:
Thanks @Mumshad Mannambeth @Amel ECHEIKH EZAOUALI @Mohamed Ayman…