Kubernetes Assignment– 4

Advanced Workloads & Scheduling

Basic Questions

  1. Create a DaemonSet that deploys an nginx Pod on every node in the cluster.
  2. Verify that the DaemonSet has exactly one Pod running on each node.
  3. Delete a DaemonSet Pod and observe if it gets recreated automatically.
  4. Create a StatefulSet with 2 replicas of nginx Pods.
  5. Check the difference in Pod names created by StatefulSet vs Deployment.
  6. Scale the StatefulSet from 2 replicas to 3 and observe naming convention.
  7. Delete one Pod from the StatefulSet and verify it comes back with the same name.
  8. Create a Job that runs a simple command (echo “Hello Kubernetes”).
  9. Verify that the Job Pod completes successfully.
  10. Create a CronJob that runs every minute and prints the current date.
  11. Verify completed Pods created by the CronJob.
  12. Suspend the CronJob and confirm no new Pods are created.
  13. Resume the CronJob and confirm Pods start again.
  14. Add a taint to a node and verify normal Pods are not scheduled on it.
  15. Deploy a Pod with a toleration to run on the tainted node.
  16. Add a node affinity rule to schedule a Pod only on nodes with label disk=ssd.
  17. Add a node anti-affinity rule to ensure two Pods don’t run on the same node.
  18. Create a namespace workloads-demo and deploy a Job inside it.
  19. View logs of a completed Job Pod.
  20. Document the difference between DaemonSets, StatefulSets, Deployments, and Jobs.

Intermediate Questions

  1. Create a DaemonSet to run fluentd Pods for log collection on all nodes.
  2. Add resource limits (CPU/memory) to the DaemonSet Pods.
  3. Create a StatefulSet with 3 replicas of busybox running infinite sleep.
  4. Attach a PVC to each StatefulSet Pod and verify persistence.
  5. Scale the StatefulSet down to 1 replica and then back up to 3, checking if data persists.
  6. Create a Job that runs a Pod to calculate factorial of 5.
  7. Create a Job with completions=3 and parallelism=2 to run tasks in parallel.
  8. Create a CronJob that runs every 5 minutes and writes logs to a file.
  9. Set successfulJobsHistoryLimit=2 for the CronJob and verify cleanup.
  10. Set failedJobsHistoryLimit=1 for the CronJob and test failure cases.
  11. Add a taint role=db:NoSchedule to a node.
  12. Deploy a MongoDB Pod with a toleration to run on the tainted node.
  13. Add required node affinity so the MongoDB Pod runs only on nodes labeled role=db.
  14. Deploy a Deployment with anti-affinity to spread Pods across nodes.
  15. Combine affinity and tolerations in a single Pod specification.
  16. Create a StatefulSet with headless Service for Pod DNS resolution.
  17. Verify Pod-to-Pod communication using StatefulSet DNS names.
  18. Delete and recreate StatefulSet Pods to confirm stable network identity.
  19. Use kubectl describe to verify affinity and tolerations applied to a Pod.
  20. Document best practices for scheduling Pods with taints, tolerations, and affinity.

Advanced Questions

  1. Create a DaemonSet to deploy a monitoring agent (cAdvisor or node-exporter) on every node.
  2. Create a StatefulSet for a MongoDB cluster with 3 replicas and persistent storage.
  3. Configure a headless Service to expose MongoDB StatefulSet Pods individually.
  4. Verify that each MongoDB Pod gets a stable network identity.
  5. Initialize MongoDB replica set inside the StatefulSet Pods.
  6. Create a Job that seeds initial data into the MongoDB cluster.
  7. Create a CronJob that backs up MongoDB data every hour to a volume.
  8. Configure taints and tolerations so that MongoDB Pods run only on dedicated nodes.
  9. Apply node affinity rules to ensure MongoDB Pods run on high-memory nodes.
  10. Deliver a final hands-on project:
    • Deploy MongoDB StatefulSet with persistent PVCs
    • Headless Service for DNS resolution
    • Initialize replica set
    • Create backup CronJob
    • Apply taints, tolerations, and affinity for reliability.