Launching jobs
Hue has a lot of long-running processes deployed as microservices, but it also has a lot of tasks that run, accomplish some goal, and exit. Kubernetes supports this functionality via the Job resource. A Kubernetes job manages one or more pods and ensures that they run until success. If one of the pods managed by the job fails or is deleted, then the job will run a new pod until it succeeds.
Here is a job that runs a Python process to compute the factorial of 5
(hint: it's 120):
apiVersion: batch/v1 kind: Job metadata: name: factorial5 spec: template: metadata: name: factorial5 spec: containers: - name: factorial5 image: python:3.5 command: ["python", "-c", "import math; print(math.factorial(5))"] restartPolicy: Never
Note that the restartPolicy
must be either Never
or OnFailure
The default Always
value is invalid because a job shouldn't restart after a successful completion.
Let...