Deploying a Docker Application to Kubernetes Quiz

Learn the essential steps for deploying a Dockerized application on Kubernetes clusters, from private registry preparation to exposing your service efficiently. Test your understanding of best practices in cloud-based DevOps deployment workflows.

  1. Authenticating with a private Docker registry

    What command should you run first to authenticate your Docker client with a private registry before pushing images?

    1. kubectl authenticate
    2. docker authenticate
    3. docker login
    4. kubectl login

    Explanation: The 'docker login' command is used to authenticate with a Docker registry using your credentials, which is required before pushing images. 'kubectl login' and 'kubectl authenticate' are not valid commands for this purpose, and 'docker authenticate' is not recognized by Docker.

  2. Tagging a Docker image for a private registry

    Which docker command syntax correctly tags a local Docker image so it can be pushed to a private registry on IP 192.168.1.100 at port 5000?

    1. docker tag my-app 192.168.1.100:5000/my-app
    2. docker label my-app 192.168.1.100:5000/my-app
    3. docker move my-app 192.168.1.100:5000/my-app
    4. docker push my-app 192.168.1.100:5000/my-app

    Explanation: The 'docker tag' command assigns a registry address and repository tag to the image, making it ready to be pushed. 'docker label' adds metadata and does not tag for a registry, 'docker move' is not a valid Docker command, and 'docker push' uploads rather than tags an image.

  3. Verifying image availability in the registry

    After pushing a Docker image to a private registry, how can you verify it is accessible and works as expected locally?

    1. docker pull --test 192.168.1.100:5000/my-app
    2. docker run 192.168.1.100:5000/my-app
    3. docker exec 192.168.1.100:5000/my-app
    4. kubectl apply 192.168.1.100:5000/my-app

    Explanation: 'docker run [image]' launches a container from the specified image to check if it works. 'kubectl apply' is for Kubernetes resources, 'docker pull --test' is not a valid flag, and 'docker exec' requires an already running container.

  4. Creating a Kubernetes pod for your application

    Which command creates a Kubernetes pod that runs a container from your private registry's image?

    1. kubectl deploy my-app 192.168.1.100:5000/my-app:latest
    2. kubectl run my-app --restart=Never --image=192.168.1.100:5000/my-app --port=80
    3. kubectl create pod my-app --from=192.168.1.100:5000/my-app
    4. docker run -d 192.168.1.100:5000/my-app

    Explanation: 'kubectl run ...' initializes a pod with the specified image and settings. 'docker run' is for local Docker, not Kubernetes. 'kubectl create pod' with '--from' is not a valid syntax. 'kubectl deploy' is not a recognized command.

  5. Exposing your application within Kubernetes

    To make your deployed pod reachable over the network, which command exposes the pod as a service of type NodePort?

    1. docker run --expose=80 my-app
    2. kubectl expose pods my-app --type=NodePort --port=80
    3. docker expose my-app --type=NodePort
    4. kubectl publish my-app --type=NodePort --port=80

    Explanation: 'kubectl expose pods ...' creates a Kubernetes service and assigns it a NodePort for external access. 'docker expose' and 'docker run --expose' are used with Docker, not Kubernetes. 'kubectl publish' is not a valid Kubernetes command.