- Kubernetes Design Patterns and Extensions
- Onur Yilmaz
- 161字
- 2021-07-23 16:57:38
Job Pattern
The general use case of pods in Kubernetes is that they are used for long-running processes that are always up. To this aim, Kubernetes provides higher-level resources such as replication sets or deployments. These high-level resources manage the life cycles of pods by creating replicas, checking for health statuses, and controlling update mechanisms. On the other hand, there is a need for microservices that do one job and successfully exit upon completion. For instance, database initializations, backups, or converting a video should run once and exit without consuming any extra resources. For this requirement, Kubernetes provides a higher-level resource named Job. Kubernetes jobs represent an isolated work run until completion and are ideal for use cases that are required to only run once.
- For always running pods, the restartPolicy is set to Always
- For jobs, the restartPolicy could be set as OnFailure or Never