Skip to content

Latest commit

 

History

History
67 lines (45 loc) · 1.81 KB

05-Practice-Test-Labels-and-Selectors.md

File metadata and controls

67 lines (45 loc) · 1.81 KB

Practice Test - Labels and Selectors

Solutions to Practice Test - Labels and Selectors

  1. We have deployed a number of PODs. They are labelled with tier, env and bu. How many PODs exist in the dev environment (env)?

    Here we are filtering pods by the value olf a label

    kubectl get pods --selector env=dev
    

    Count the pods (if any)

  2. How many PODs are in the finance business unit (bu)?

    Similarly ...

    kubectl get pods --selector bu=finance
    

    Count the pods (if any)

  3. How many objects are in the prod environment including PODs, ReplicaSets and any other objects?
    kubectl get all --selector env=prod
    

    Count everything (if anything)

  4. Identify the POD which is part of the prod environment, the finance BU and of frontend tier?

    We can combine label expressions with comma. Only items with all the given label/value pairs will be returned, i.e. it is an and condition.

    kubectl get all --selector env=prod,bu=finance,tier=frontend
    
  5. A ReplicaSet definition file is given replicaset-definition-1.yaml. Try to create the replicaset. There is an issue with the file. Try to fix it.
    kubectl create -f replicaset-definition-1.yaml
    

    Note the error message.

    Selector matchLabels should match with POD labels - Update replicaset-definition-2.yaml

    The values for labels on lines 9 and 13 should match.

    $ kubectl create -f replicaset-definition-2.yaml