Comments (7)
@ygalblum @umohnani8 @haircommander PTAL
from podman.
Is this the function of an init container? I think there is a special one that continues to run after init is complete.
from podman.
yeah initContainers are started and run to completion before the main containers. There's also the notion of sidecar containers which are also initContainers, but have restartPolicy Always, so they're started before the main containers but don't complete before the others are started
from podman.
yeah initContainers are started and run to completion before the main containers. There's also the notion of sidecar containers which are also initContainers, but have restartPolicy Always, so they're started before the main containers but don't complete before the others are started
If we added a sidecar container under initContainers
that was able to check the health of the database container in the postStart
lifecycle using a script, would that be able to halt only the application container from attempting to start while the database container is starting? One thing to note, is that the k8s yaml that is generated from the podman generate kube
puts the database and application containers in the same pod.
Our generated Kubernetes yaml file for reference:
https://github.com/candlepin/candlepin/blob/main/dev-container/candlepin-deployment.yaml
from podman.
Hi,
There's a pull request addressing sidecar containers. While it is not yet merged, @joshmalbrecht is this what you are looking for?
from podman.
@ygalblum are you suggesting to run the application image as a sidecar container? I think that would work with the pull request you linked and the added restart functionality. I believe the sidecar container would first startup and fail and then continue retrying to restart until the database container in the same pod is healthy and the application can make a database connection.
I'm not very familiar with Kubernetes, so please let me know if this isn't correct, but it seems like the database container and the application container should be in two separate pods. To get similar functionality to the docker-compose depends_on
, you would need an init container in the application pod that waits until the database pod is healthy before completing and allowing the application container to start. From doing some reading it seems like this is the Kubernetes equivalent of the docker compose depends_on
functionality, so maybe this is the pattern we should follow?
Both of these options should work for this use case!
from podman.
@joshmalbrecht first, my suggestion was the other way around (that is having the DB as a sidecar to the application). Having said that, I agree that ideally they should be in different pods. However, as you've mentioned podman does not handle dependencies between pods.
The second option you suggested does look promising. Podman will not start the main container until the init container has returned successfully (regular init containers, not the ones supported by the PR I linked). So, having an init container wait until the DB connection is up should do the trick.
Another option is to use Quadlet which allows you to define dependencies between containers (or pods) using Systemd. I actually wrote a blog post about it: https://www.redhat.com/sysadmin/multi-container-application-podman-quadlet which also has some code accompanying it: https://github.com/ygalblum/quadlet-demo along
from podman.
Related Issues (20)
- Podman stop container hanging HOT 4
- failed to execvp -podmansh: No such file or directory HOT 11
- Different cgroup controllers available in KDE/Wayland and a terminal login session HOT 2
- Can't upgrade core machine HOT 8
- Cannot run in a chroot environment (remount /, flags: 0x44000: invalid argument) HOT 2
- Permission denied while pasta tries to open network namespace HOT 3
- Podman-compose mount volume incorrectly under Windows with podman machine on WSL HOT 4
- Wrong link to MacOS Silicon binary artifact
- rawhide kernel 6.10.0 >=20240514 - podman update device-read-bps = 0 HOT 20
- Issue with run amd64 images on mac arm m1 after recreate podman machine HOT 5
- Command version exit code not zero HOT 4
- OCI runtime error: unable to start container: crun: cannot set memory swappiness with cgroupv2
- Podman build fails when label contains whitespace HOT 2
- [packit] Propose downstream failed for release v5.1.0-rc1 HOT 6
- Container not stopping or removed when console is terminated HOT 1
- window client访问 linux podman服务端linux服务端应该开放哪些端口?可否自行设定端口范围? HOT 2
- docker-compose network cannot access the host HOT 1
- Hostname written to /etc/hostname does not include new-line at end HOT 7
- podman build adds "variant" to all images when building multiarch images on MacOS (Apple Silicon) HOT 6
- unsupported image-specific operation on artifact with type "application/vnd.devcontainers" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from podman.