CDP CDP Containerization & Orchestration 2 — Questions and Answers
Question 1: Which command is used to scale a Kubernetes Deployment to 5 replicas using kubectl?
- kubectl scale deployment <name> --replicas=5 (Correct answer)
- kubectl set replicas deployment <name> 5
- kubectl resize deployment <name> --count=5
- kubectl update deployment <name> --replicas=5
Correct answer: kubectl scale deployment <name> --replicas=5
The `kubectl scale` command adjusts the number of replicas for a deployment, replicaset, or statefulset.
Question 2: In Docker Compose, what does the `depends_on` directive control?
- The startup order of services (Correct answer)
- The resource limits per service
- The network topology between services
- The image build sequence
Correct answer: The startup order of services
The `depends_on` directive specifies that one service should start only after the listed services have started.
Question 3: What is a Kubernetes DaemonSet used for?
- Ensuring one pod runs on every (or selected) node in the cluster (Correct answer)
- Running a batch job to completion
- Maintaining a fixed number of pod replicas globally
- Exposing pods externally via load balancer
Correct answer: Ensuring one pod runs on every (or selected) node in the cluster
A DaemonSet ensures that a copy of a pod runs on all (or some) nodes, commonly used for log collectors or monitoring agents.
Question 4: Which Kubernetes object should you use to manage stateful applications requiring stable storage and network identity?
- StatefulSet (Correct answer)
- Deployment
- ReplicaSet
- CronJob
Correct answer: StatefulSet
StatefulSets maintain a sticky identity for each pod and are designed for stateful applications that require stable, persistent storage.
Question 5: What does a Kubernetes Horizontal Pod Autoscaler (HPA) use by default to determine when to scale pods?
- CPU utilization (Correct answer)
- Memory usage
- Network throughput
- Disk I/O
Correct answer: CPU utilization
By default, HPA scales the number of pod replicas based on observed CPU utilization relative to a target threshold.
Question 6: In a DevOps container pipeline, what is the recommended practice for tagging Docker images pushed to production?
- Use immutable version tags such as git commit SHA or semantic version (Correct answer)
- Use the `latest` tag for all production images
- Use date-based tags formatted as YYYYMMDD
- Use branch name tags for production
Correct answer: Use immutable version tags such as git commit SHA or semantic version
Immutable tags like commit SHA or semantic versions ensure reproducibility and prevent silent overwrites that occur with mutable tags like `latest`.
Which command is used to scale a Kubernetes Deployment to 5 replicas using kubectl?