Migrating from Docker Compose to Kubernetes: Concepts and Tools Quiz

Explore the process, challenges, and best practices for migrating application stacks from Docker Compose to Kubernetes. This quiz helps you identify key differences, select appropriate tools, and understand YAML translation for effective deployment orchestration in modern container ecosystems.

  1. Kubernetes Objects vs Docker Compose Services

    When migrating a multi-service app from Docker Compose to Kubernetes, which Kubernetes object most closely matches the 'services' defined in a compose file?

    1. Deployment
    2. ConfigMap
    3. Service
    4. Volume

    Explanation: A Deployment object in Kubernetes defines how to run and manage a set of replicated Pods, just as a service in Docker Compose specifies how to run a container. 'Service' in Kubernetes is used for networking and exposing applications, not for running containers. 'ConfigMap' is for configurations and 'Volume' handles persistent storage. Therefore, 'Deployment' is the closest match to Docker Compose's notion of running and managing services.

  2. Translating Environment Variables

    How should environment variables from a Docker Compose file’s 'environment' section be represented in Kubernetes configuration?

    1. As command line arguments to Pods
    2. As environment variables in Pod specifications
    3. Only as annotations on Services
    4. As resource requests for Containers

    Explanation: Environment variables set in Docker Compose can be directly translated into environment variables within Kubernetes Pod specifications. Command line arguments are a different method and may be used for different configuration patterns. Annotations are not used for operating environment variables, and resource requests are for CPU and memory, not environment variables. Using environment variables in the Pod spec ensures consistent configuration.

  3. YAML File Differences

    Which difference exists between Docker Compose and Kubernetes YAML files when describing application stacks?

    1. Kubernetes YAML typically requires defining multiple separate files for objects
    2. Docker Compose YAML uses uppercase keys exclusively
    3. Kubernetes YAML files are exclusively written in JSON format
    4. Both require an 'apiKey' block for authentication

    Explanation: Kubernetes discourages monolithic files and encourages separate YAML files for different objects like Deployments, Services, and ConfigMaps. Docker Compose usually has one YAML file aggregating all services. Docker Compose does not use uppercase keys, Kubernetes accepts both YAML and JSON but not exclusively JSON, and neither requires an 'apiKey' block for basic stack definitions.

  4. Persistent Data Migration

    When converting a Docker Compose volume used for persistent data to Kubernetes, which resource should you use to ensure persistent storage across Pod restarts?

    1. PersistentVolumeClaim
    2. Ingress
    3. NodePort
    4. Job

    Explanation: A PersistentVolumeClaim in Kubernetes is used to request and bind persistent storage, mirroring how a volume in Docker Compose maintains data across restarts. 'Ingress' is used for external routing, 'NodePort' exposes a service, and 'Job' handles batch processing, not persistent storage. Only PersistentVolumeClaim guarantees storage persistence through container restarts.

  5. Automatic Translation Tools

    Which tool is commonly used to convert Docker Compose YAML files into Kubernetes manifests, facilitating migration efforts?

    1. kompose
    2. kubify
    3. compose-up
    4. dockershift

    Explanation: The tool 'kompose' is designed specifically for converting Docker Compose files into Kubernetes manifests, simplifying migrations. 'Kubify', 'compose-up', and 'dockershift' are not standard or widely recognized tools for this migration and may refer to different or unrelated utilities. Using kompose automates much of the YAML translation process.