Question-81:  How can you create an object specified in “he_Object.yaml”?

Answer: You can use apply command as below

“kubectl apply -f he_object.yaml”

And while specifying, you don’t have to provide the resource type of the objects. This can be obtained from object itself. And same command you can use to update the object. If object already exists in the cluster it will simply exit successfully without making any changes.

Question-82: How can you check before apply command, what it can do if you run it?

Answer: In that case you have to use “--dry-run” option while running apply command.

Question-83: How does “kubectl edit” command is different?

Answer: When you use “edit” command, it will download the latest object state and then launch an editor that contains the definition. And once you save the file it will automatically uploaded back to the Kubernetes cluster.

Question-84: Which are the commands which are helpful for checking history of apply command?

Answer: You can use following options to check the entire history of the apply command

  • edit-last-applied
  • set-last-applied
  • view-last-applied

For example below command would show you the last applied command to the object

“kubectl apply -f heobj.yaml view-last-applied”

Question-85: How can you delete the object in Kubernetes?

Answer: If you want to delete the object in Kubernetes cluster you can use delete command as below

“kubectl delete resource-name obj-name”