Skip to content

Latest commit

 

History

History
155 lines (108 loc) · 3.16 KB

17-Practice-Tests-Deployments.md

File metadata and controls

155 lines (108 loc) · 3.16 KB

Practice Test - Deployments

Solutions to the deployments practice test

  1. How many pods exist on the system?
    kubectl get pods

    Count the number of pods (if any)

  2. How many ReplicaSets exist on the system?
    kubectl get replicasets

    Count the number of ReplicaSets (if any)

  3. How many Deployments exist on the system?
    kubectl get deployments

    Count the number of Deployments (if any)

  4. How many Deployments exist on the system now?
    kubectl get deployments

    Count the number of Deployments (if any)

  5. How many ReplicaSets exist on the system now?
    kubectl get replicasets

    Count the number of ReplicaSets (if any)

  6. How many Pods exist on the system?
    kubectl get pods

    Count the number of pods (if any)

  7. Out of all the existing PODs, how many are ready?

    From the output of the previous command, check the READY column

  8. What is the image used to create the pods in the new deployment?
    kubectl describe deployment
    

    Look under the containers section.

    Another way - run the following and check the IMAGES column

    kubectl get deployment -o wide
    
  9. Why do you think the deployment is not ready?
    kubectl describe pods
    

    Look under the events section.

  10. Create a new Deployment using the deployment-definition-1.yaml file located at /root/.
    There is an issue with the file, so try to fix it.
    kubectl create -f deployment-definition-1.yaml
    

    Note the error

    Edit the file with vi...

    The value for kind is incorrect. It should be Deployment with a capital D. Update the deployment definition and create the deployment with the above command.

  11. Create a new Deployment with the below attributes using your own deployment definition file.

    Create a deployment definition file in vi, e.g. my-deployment.yaml with the following

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: httpd-frontend
      name: httpd-frontend
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: httpd-frontend
      template:
        metadata:
          labels:
            app: httpd-frontend
        spec:
          containers:
          - image: httpd:2.4-alpine
            name: httpd
    kubectl create -f my-deployment.yaml
    

    Or we could create it imperatively...

    kubectl create deployment httpd-frontend --image=httpd:2.4-alpine --replicas=3