Description
Feature request description
We are in the process of migrating our CI from using docker-compose to podman play kube
and we used the podman generate kube
command to generate a Kubernetes YAML file based on our existing docker-compose.yml. However, it appears that there is no container dependency functionality that is equivalent to the docker-compose depends_on
functionality.
We would like to create a dependency between our application container and a database container so that the application container does not attempt to start until the database container is created and has a healthy healthcheck. This would guarantee that the application container can connect to the database container. Currently both containers are started in parallel using the podman play kube
command and it is possible that the database container is not available by the time that the application container attempts to connect and causes issues.
Suggest potential solution
No response
Have you considered any alternatives?
An alternative would be adding database connection retry logic to the application to give the database container more time to get to a healthy state and then make a connection. This will work as alternative and I have a PR out for these changes (candlepin/candlepin#4656), but I was wondering if this would be helpful functionality for others.
Additional context
Example docker-compose.yml using depends_on
:
version: '3.8'
services:
postgres:
image: postgres:latest
container_name: postgres
environment:
POSTGRES_USER: candlepin
POSTGRES_PASSWORD: candlepin
POSTGRES_DB: candlepin
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U candlepin -d candlepin"]
interval: 5s
timeout: 5s
retries: 10
candlepin:
image: quay.io/candlepin/candlepin:dev-latest
container_name: candlepin
environment:
JPA_CONFIG_HIBERNATE_CONNECTION_URL: jdbc:postgresql://postgres/candlepin
CANDLEPIN_AUTH_CLOUD_ENABLE: "false"
CANDLEPIN_AUTH_TRUSTED_ENABLE: "true"
CANDLEPIN_STANDALONE: "false"
MODULE_CONFIG_HOSTED_CONFIGURATION_MODULE: org.candlepin.testext.hostedtest.HostedTestModule
ports:
- "8443:8443"
healthcheck:
test: curl --fail -k https://localhost:8443/candlepin/status
timeout: 5s
retries: 10
start_period: 30s
depends_on:
postgres:
condition: service_healthy