Jacob:
Hi there
I noticed many people that passed the exams recommended to export some configurations like this one:
export y='--dry-run=client -o yaml'
while im aware of aliases and its benefits im not sure how the export command might be useful in the exam itself.
explanation will be appreciated
Thy:
Basically it’s exporting a variable y
and to be re-use for avoiding re-typing the options (dry-run and output), you can run kubectl with $y
. For example:
export y='--dry-run=client -o yaml'
k run nginx --image=nginx $y
# without the export, you need to re-type the options
k run nginx --image=nginx --dry-run=client -o yaml
Jacob:
@Thy thanks for the explanation. so once exporting the variable, basically i can run the following:
k run nginx --image=nginx $y > somename.yaml
?
Thy:
@Jacob That’s correct
Thy:
Btw just fyi, you don’t need to use export
so you can just run y='--dry-run=client -o yaml'
and use $y
to your kubectl command, for example:
$ y='--dry-run=client -o yaml'
$ k run nginx --image=nginx $y
kg:
ok , what are all the alias /short cuts we need to set /aware to crack the CKA ?
Paul:
aliases and exports are useful simply because it allows you to type commands with speed and accuracy which are very important during the exam. you don’t want to waste time fighting with your keyboard typos.
exports allow you to have flexibility with commands as well as remove redundancy. for example, almost most of the time you will be creating objects imperatively but in the event that you want to export the yaml file (which you will do a LOT), you can just slap your export command at the end of it.
k run tmp-nginx --image=nginx:alpine $y > pod.yaml