Restart Policy¶
The restart policy of a workload enables the user to determine whether a workload is automatically restarted when it terminates. By default, workloads are not restarted. However, the restart policy can be configured to always restart the workload, or to restart the workload under certain conditions.
Supported Restart Policies¶
The following restart policies are available for a workload:
Restart Policy | Description | Restart on ExecutionState |
---|---|---|
NEVER | The workload is never restarted. Once the workload exits, it remains in the exited state. | - |
ON_FAILURE | If the workload exits with a non-zero exit code, it will be restarted. | Failed(ExecFailed) |
ALWAYS | The workload is restarted upon termination, regardless of the exit code. | Succeeded(Ok) or Failed(ExecFailed) |
Ankaios restarts the workload when the workload has exited and the configured restart policy aligns with the workload's ExecutionState
, as detailed in the aforementioned table. It does not restart the workload if the user explicitly deletes the workload via the Ankaios CLI or if Ankaios receives a delete request for that workload via the Control Interface.
Note
Ankaios does not consider inter-workload dependencies when restarting a workload because it was already running before it has exited.
Configure Restart Policies¶
The field restartPolicy
enables the user to define the restart policy for each workload within the Ankaios manifest. The field is optional. If the field is not provided, the default restart policy NEVER
is applied.
The following Ankaios manifest contains workloads with different restart policies:
- This workload is always restarted upon termination.
- This workload is never restarted regardless of the exit code.
- This workload is restarted only when it exits with a non-zero exit code.