camunda-community-hub / camunda-7-community-helm

Camunda public Kubernetes Helm repo and charts
Apache License 2.0
39 stars 38 forks source link

Support for initContainers to wait for database startup #18

Closed Sonny78 closed 2 years ago

Sonny78 commented 2 years ago

On first installing my resources I get sometimes the following exception in my camunda pod:

06-Oct-2021 14:21:56.462 SEVERE [main] org.postgresql.Driver.connect Connection error: 
    org.postgresql.util.PSQLException: FATAL: the database system is starting up

or even:

7-Oct-2021 09:58:29.075 SEVERE [main] org.postgresql.Driver.connect Connection error: 
    org.postgresql.util.PSQLException: Connection to db-cluster:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:265)
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)

To avoid this I want to use initcontainers, which wait until the service and database are started.

initContainers:
  - name: check-db-service-available
    image: busybox:1.34.0
    command: ['sh', '-c', 
      'until nslookup db-cluster; 
      do echo waiting for db-cluster; sleep 2; done; 
      echo db service found;']
  - name: check-db-ready
    image: postgres:13.4
    command: ['sh', '-c', 
    'until pg_isready -h db-cluster -d processEngine -p 5432; 
      do echo waiting for database; sleep 2; done; 
      echo database is ready']

Does this make sense for you? I tried it directly with the yaml files without using the helm chart and it worked quite well. But of cause I want rather to use your helm charts.

Perhaps it could be an option to include something like this in the development yaml:

{{- if .Values.initContainers }}
  {{- toYaml .Values.initContainers | nindent 6 }}
{{- end }}

So that I will be able to define my initContainers in the values file

aabouzaid commented 2 years ago

@Sonny78 Thanks for your suggestion :clap:

In v1.3.0 it's possible to define any initContainers.

Sonny78 commented 2 years ago

Thanks, works fine.