Kubernetes Assignment– 4
Advanced Workloads & Scheduling
Basic Questions
- Create a DaemonSet that deploys an nginx Pod on every node in the cluster.
- Verify that the DaemonSet has exactly one Pod running on each node.
- Delete a DaemonSet Pod and observe if it gets recreated automatically.
- Create a StatefulSet with 2 replicas of nginx Pods.
- Check the difference in Pod names created by StatefulSet vs Deployment.
- Scale the StatefulSet from 2 replicas to 3 and observe naming convention.
- Delete one Pod from the StatefulSet and verify it comes back with the same name.
- Create a Job that runs a simple command (echo “Hello Kubernetes”).
- Verify that the Job Pod completes successfully.
- Create a CronJob that runs every minute and prints the current date.
- Verify completed Pods created by the CronJob.
- Suspend the CronJob and confirm no new Pods are created.
- Resume the CronJob and confirm Pods start again.
- Add a taint to a node and verify normal Pods are not scheduled on it.
- Deploy a Pod with a toleration to run on the tainted node.
- Add a node affinity rule to schedule a Pod only on nodes with label disk=ssd.
- Add a node anti-affinity rule to ensure two Pods don’t run on the same node.
- Create a namespace workloads-demo and deploy a Job inside it.
- View logs of a completed Job Pod.
- Document the difference between DaemonSets, StatefulSets, Deployments, and Jobs.
Intermediate Questions
- Create a DaemonSet to run fluentd Pods for log collection on all nodes.
- Add resource limits (CPU/memory) to the DaemonSet Pods.
- Create a StatefulSet with 3 replicas of busybox running infinite sleep.
- Attach a PVC to each StatefulSet Pod and verify persistence.
- Scale the StatefulSet down to 1 replica and then back up to 3, checking if data persists.
- Create a Job that runs a Pod to calculate factorial of 5.
- Create a Job with completions=3 and parallelism=2 to run tasks in parallel.
- Create a CronJob that runs every 5 minutes and writes logs to a file.
- Set successfulJobsHistoryLimit=2 for the CronJob and verify cleanup.
- Set failedJobsHistoryLimit=1 for the CronJob and test failure cases.
- Add a taint role=db:NoSchedule to a node.
- Deploy a MongoDB Pod with a toleration to run on the tainted node.
- Add required node affinity so the MongoDB Pod runs only on nodes labeled role=db.
- Deploy a Deployment with anti-affinity to spread Pods across nodes.
- Combine affinity and tolerations in a single Pod specification.
- Create a StatefulSet with headless Service for Pod DNS resolution.
- Verify Pod-to-Pod communication using StatefulSet DNS names.
- Delete and recreate StatefulSet Pods to confirm stable network identity.
- Use kubectl describe to verify affinity and tolerations applied to a Pod.
- Document best practices for scheduling Pods with taints, tolerations, and affinity.
Advanced Questions
- Create a DaemonSet to deploy a monitoring agent (cAdvisor or node-exporter) on every node.
- Create a StatefulSet for a MongoDB cluster with 3 replicas and persistent storage.
- Configure a headless Service to expose MongoDB StatefulSet Pods individually.
- Verify that each MongoDB Pod gets a stable network identity.
- Initialize MongoDB replica set inside the StatefulSet Pods.
- Create a Job that seeds initial data into the MongoDB cluster.
- Create a CronJob that backs up MongoDB data every hour to a volume.
- Configure taints and tolerations so that MongoDB Pods run only on dedicated nodes.
- Apply node affinity rules to ensure MongoDB Pods run on high-memory nodes.
- 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.