Skill #1: Set the kubectl alias
You should set an alias for kubectl command, because this command is the most frequently used command in the exam.
Then , you can use the k command to execute commands in kubernetes like this:
k get pods k get nodes -o wide k scale replicas=2 deployment/testapp ...
Trust me, this alias would save you tons of time in the exam.
Skill #2: Set environment variable for some command options
In the exam, you would likely to input some command options repeatedly, please follow this steps to improve the performance:
If you want to create a resource in kubernetes, but you only want to make a dryrun, and get the yaml template, you can do this command:
k craete deployment testapp --image=nginx --dry-run -o yaml
You would find that the options –dry-run -o yaml would be used more than once, you can define a variable to reuse it in other commands:
export do='--dry-run -o yaml' kubectl get pod <pod-name> $do
Skill #3: Delete resource quicky by –force option
Normally, if you delete a resource in kubernetes like this:
k delete pod testapp
It would make you wait for a while to safely teardown some other resources. In the exam , it would be not necessary to wait for that, just delete it by force:
k delete pod testapp --force
Skill #4: Create secret by imperative command
Normally, if you create secret in kubernetes with yaml , you would do as follows:
echo -n '1f2d1e2e67df' | base64 #you get MWYyZDFlMmU2N2Rm
Then you create a yaml file to define the secret:
apiVersion: v1 kind: Secret metadata: name: mysecret type: Opaque data: password: MWYyZDFlMmU2N2Rm
It would cost you a lot of time to do the job, you can use a single command to accomplish the same secret like this:
k create secret generic mysecret —from-literal=password=1f2d1e2e67df
You can view some references as follows: