containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.03k stars 2.35k forks source link

Add an option to run podman play kube in the foreground. Stop pod when process is terminated. #14522

Closed 1player closed 1 year ago

1player commented 2 years ago

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description

Requesting a command line option to run podman play kube in the foreground. All containers are started normally, and when the podman process is terminated, all pods are stopped. This is so I don't have to remember to run podman play kube --down every time.

The goal is to have a similar behaviour as docker-compose up, which runs all services and stops them when the process is stopped, unless --detach is passed.

The use case is for local development. I would like to start my dev pods, and for them to be stopped automatically if I close the terminal. With the current behaviour, more than one time I've forgot to call podman play kube --down and I had my dev containers consuming resources in the background.

rhatdan commented 2 years ago

Makes sense to me. but we may need to default to --detach=true, since we would not wan to break existing scripts.

vrothberg commented 2 years ago

Starting with Podman v4.2, the pods terminate on their own. They won't be removed but they terminate. Would that address your issue?

1player commented 2 years ago

Starting with Podman v4.2, the pods terminate on their own. They won't be removed but they terminate. Would that address your issue?

Does this mean that on Podman 4.2 play kube stays in the foreground until stopped with Ctrl-C, and at that point pods are terminated? That would indeed address this issue.

vrothberg commented 2 years ago

Does this mean that on Podman 4.2 play kube stays in the foreground until stopped with Ctrl-C, and at that point pods are terminated? That would indeed address this issue.

No, nothing runs in the foreground. But if all containers in a pod exited, then the pod gets stopped automatically.

1player commented 2 years ago

Ah, then what I'm requesting is different. This issue is to have a mode that all pods are started with play kube, and they stay running until the play kube process is stopped. At that point the pod is terminated. In other words:

  1. Start pod
  2. Wait for signal
  3. Stop pod

Currently play kube only provides a "detach" mode, and users need to remember to do a play kube --down manually or everything keeps running indefinitely.

vrothberg commented 2 years ago

Thanks for elaborating. That sounds doable: play kube waits for a sigstop and runs play kube --down when receiving the signal.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

1player commented 2 years ago

Ugh. Not stale.

rhatdan commented 2 years ago

@umohnani8 Could you take a look at this or assign an intern? @ashley-cui @vrothberg ^^

karthikelango137 commented 2 years ago

I can look at this one

1player commented 2 years ago

You can assign this to me, I have a PR ready to go but I can't test properly until #15071 is fixed.

vrothberg commented 2 years ago

@1player for testing, you could ./bin/podman system service -t0. That will work around the issue in #15071.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 2 years ago

@1player What is the status of this?

1player commented 2 years ago

The PR is still open, I've answered there, but I don't see why this issue needs to be closed. It's still a valid request with related PR.

rhatdan commented 2 years ago

It does not need to be closed. I like the proposed fix, just want to get it's status.

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.