Skip to content

Latest commit

 

History

History
128 lines (92 loc) · 2.9 KB

07-Practice-Test-Taints-and-Tolerations.md

File metadata and controls

128 lines (92 loc) · 2.9 KB

Practice Test - Taints and Tolerations

Solutions to the Practice Test - Taints and Tolerations

  1. How many nodes exist on the system?
    $ kubectl get nodes
    

    Count the nodes

  2. Do any taints exist on node01 node?
    $ kubectl describe node node01
    

    Find the Taints property in the output.

  3. Create a taint on node01 with key of spray, value of mortein and effect of NoSchedule
    kubectl taint nodes node01 spray=mortein:NoSchedule
    
  4. Create a new pod with the nginx image and pod name as mosquito.
    kubectl run mosquito --image nginx
    
  5. What is the state of the POD?
    kubectl get pods
    

    Check the STATUS column

  6. Why do you think the pod is in a pending state?

    Mosqitoes don't like mortein!

    So the answer is that the pod cannot tolerate the taint on the node.

  7. Create another pod named bee with the nginx image, which has a toleration set to the taint mortein.

    Allegedly bees are immune to mortein!

    1. Create a YAML skeleton for the pod imperatively

      kubectl run bee --image nginx --dry-run=client -o yaml > bee.yaml
      
    2. Edit the file to add the toleration

      vi bee.yaml
      
    3. Add the toleration. This goes at the same indentation level as containers as it is a POD setting.

        tolerations:
        - key: spray
          value: mortein
          effect: NoSchedule
          operator: Equal
    4. Save and exit, then create pod

      kubectl create -f bee.yaml
      
  8. Information only.

  9. Do you see any taints on controlplane node?
    kubectl describe node controlplane
    

    Examine the Taints property.

  10. Remove the taint on controlplane, which currently has the taint effect of NoSchedule.
    kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule-
    
  11. What is the state of the pod mosquito now?
    $ kubectl get pods
    
  12. Which node is the POD mosquito on now?
    $ kubectl get pods -o wide
    

    This also explains why the mosquito pod colud schedule anywhere. It also could not tolerate controlplane taints, which we have now removed.