Challenge, Easy,  on  Kubernetes

Run a Short Task as a Standalone Pod Without a Job Controller

Scenario

The processing team needs a pod that runs a short task and exits cleanly on its own — without using a Job controller to manage it. The pod should print its hostname and the current date, then stop. Once done, it should appear as 0/1 Completed in the cluster.


Task

Create a Pod named data-processing-pod in the processing namespace with the following requirements:

  • Container name: data-processor
  • Image: public.ecr.aws/docker/library/busybox:latest
  • Command: print the pod hostname and current date, then exit
  • The Pod must reach 0/1 Completed status on its own without using a Job controller.

Do not use a Job controller — the pod must be created directly as a Pod resource.


Hint — Create a Pod That Completes Successfully

Create a standalone Pod resource — not a Job. The key is setting the correct restartPolicy so the pod does not restart after the container exits successfully.

There are two values that allow a pod to reach 0/1 Completed:

  • restartPolicy: Never — pod never restarts regardless of exit code
  • restartPolicy: OnFailure — pod only restarts if the container exits with a non-zero code

If you leave restartPolicy unset, it defaults to Always — the container will be restarted endlessly after each run and the pod will never reach Completed.

For the command, use sh -c to run multiple commands in one container:

command:
- sh
- -c
- hostname && date

Documentation


💡 Test Cases