summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-18 06:19:19 -0400
committerGitHub <noreply@github.com>2020-09-18 06:19:19 -0400
commitfc131a207ebaf6aa16717781bf78c78690f0408e (patch)
tree01d147dc5f5a12a380d1f795d6f9e2c58a7012bf /libpod
parent4b037d2acccd0de8a09fff91be6c266739e68694 (diff)
parentf0ccac199bd500729dabc8948bbd4ddd0124231e (diff)
downloadpodman-fc131a207ebaf6aa16717781bf78c78690f0408e.tar.gz
podman-fc131a207ebaf6aa16717781bf78c78690f0408e.tar.bz2
podman-fc131a207ebaf6aa16717781bf78c78690f0408e.zip
Merge pull request #7671 from zhangguanzhang/play-kube-handle-restartPolicy
handle the restartPolicy for play kube and generate kube
Diffstat (limited to 'libpod')
-rw-r--r--libpod/kube.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/libpod/kube.go b/libpod/kube.go
index 9d5cbe68b..f83e99d82 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -77,6 +77,24 @@ func (p *Pod) GenerateForKube() (*v1.Pod, []v1.ServicePort, error) {
}
pod.Spec.HostAliases = extraHost
+ // vendor/k8s.io/api/core/v1/types.go: v1.Container cannot save restartPolicy
+ // so set it at here
+ for _, ctr := range allContainers {
+ if !ctr.IsInfra() {
+ switch ctr.Config().RestartPolicy {
+ case RestartPolicyAlways:
+ pod.Spec.RestartPolicy = v1.RestartPolicyAlways
+ case RestartPolicyOnFailure:
+ pod.Spec.RestartPolicy = v1.RestartPolicyOnFailure
+ case RestartPolicyNo:
+ pod.Spec.RestartPolicy = v1.RestartPolicyNever
+ default: // some pod create from cmdline, such as "", so set it to Never
+ pod.Spec.RestartPolicy = v1.RestartPolicyNever
+ }
+ break
+ }
+ }
+
if p.SharesPID() {
// unfortunately, go doesn't have a nice way to specify a pointer to a bool
b := true