Add --restart flag to pod create

Add --restart flag to pod create to allow users to set the
restart policy for the pod, which applies to all the containers
in the pod. This reuses the restart policy already there for
containers and has the same restart policy options.
Add "never" to the restart policy options to match k8s syntax.
It is a synonym for "no" and does the exact same thing where the
containers are not restarted once exited.
Only the containers that have exited will be restarted based on the
restart policy, running containers will not be restarted when an exited
container is restarted in the same pod (same as is done in k8s).

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
This commit is contained in:
Urvashi Mohnani
2023-03-19 20:07:19 -04:00
parent 867639e84d
commit edbeee5238
18 changed files with 264 additions and 33 deletions

View File

@ -1,5 +1,5 @@
####> This option file is used in:
####> podman create, run
####> podman create, pod clone, pod create, run
####> If file is edited, make sure the changes
####> are applicable to all of those.
#### **--restart**=*policy*
@ -10,6 +10,7 @@ Restart policy will not take effect if a container is stopped via the **podman k
Valid _policy_ values are:
- `no` : Do not restart containers on exit
- `never` : Synonym for **no**; do not restart containers on exit
- `on-failure[:max_retries]` : Restart containers when they exit with a non-zero exit code, retrying indefinitely or until the optional *max_retries* count is hit
- `always` : Restart containers when they exit, regardless of status, retrying indefinitely
- `unless-stopped` : Identical to **always**

View File

@ -67,6 +67,10 @@ Set a custom name for the cloned pod. The default if not specified is of the syn
@@option pid.pod
@@option restart
Default restart policy for all the containers in a pod.
@@option security-opt
@@option shm-size

View File

@ -143,6 +143,10 @@ but only by the pod itself.
@@option replace
@@option restart
Default restart policy for all the containers in a pod.
@@option security-opt
#### **--share**=*namespace*

View File

@ -50,6 +50,7 @@ Valid placeholders for the Go template are listed below:
| .Name | Pod name |
| .Namespace | Namespace |
| .NumContainers | Number of containers in the pod |
| .RestartPolicy | Restart policy of the pod |
| .SecurityOpts | Security options |
| .SharedNamespaces | Pod shared namespaces |
| .State | Pod state |