Skip to content

Latest commit

 

History

History
134 lines (87 loc) · 2.75 KB

File metadata and controls

134 lines (87 loc) · 2.75 KB

Practice Test - PODs

Here are the solutions to the practice test

  1. Run the command kubectl get pods and count the number of pods.

    $ kubectl get pods
    
  2. Run the command kubectl run nginx --image=nginx.

    $ kubectl run nginx --image=nginx
    
  3. Run the command kubectl get pods and count the number of pods.

    $ kubectl get pods --no-headers | wc -l
    
  4. Run the command kubectl describe pod newpods look under the containers section.

    $ kubectl describe pod newpods | grep -w Image
    
  5. Run the command kubectl describe pod newpods look into the Node section at the very beginning or simply run the command kubectl get pods -o wide.

    $ kubectl describe pod newpods
    
  6. Run the command kubectl describe pod webapp and look under the Containers section (or) Run kubectl get pods and look under the READY section.

    $ kubectl describe pod webapp
    
  7. Run the command kubectl describe pod webapp and look under the containers section.

    $ kubectl describe pod webapp
    
  8. Run the command kubectl describe pod webapp and look under the containers section.

    $ kubectl describe pod webapp
    
  9. Run the command kubectl describe pod webapp and look under the events section.

    $ kubectl describe pod webapp
    
  10. Run the command kubectl get pods.

    $ kubectl get pods
    
  11. Run the command kubectl delete pod webapp.

    To delete the pod without any delay and confirmation, we can add --force flag.
    $ kubectl delete pod webapp --force
    
  12. Create a pod definition YAML file and use it to create a POD or use the command kubectl run redis --image=redis123.

    To create a pod definition yaml file:
    $ kubectl run redis --image=redis123 --dry-run=client -oyaml > redis.yaml
    
    $ kubectl create -f redis.yaml
    
  13. Now fix the image on the pod to redis. Update the pod-definition file and use kubectl apply command or use kubectl edit pod redis command.

    Fix the image name in the redis.yaml file and apply the changes.
    
    $ kubectl apply -f redis.yaml
    
    Direct edit in the running pod.
    
    $ kubectl edit pod redis