[MiniKube] Cant connect postgres database for Mendix app deployment

0
Hi all, I’ve been playing around with MiniKube to try deploying a Mendix app locally, but have been having issues with connecting my postgres database to the Mendix app. I’ve read the documentation from Mendix and the github READMEs thoroughly and they haven’t been helpful.   I followed the instructions from the documentation and pulled the default postgres database ($ docker pull postgres). There doesn’t seem to be any default details provided.   This is the error I’m getting:  $ kubectl logs postgres-7cdbd79f8b-2w9w6 2020-07-31 15:21:21.254 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2020-07-31 15:21:21.254 UTC [1] LOG: listening on IPv6 address "::", port 5432 2020-07-31 15:21:21.257 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2020-07-31 15:21:21.265 UTC [21] LOG: database system was shut down at 2020-07-31 15:20:51 UTC 2020-07-31 15:21:21.269 UTC [1] LOG: database system is ready to accept connections 2020-07-31 15:22:56.922 UTC [29] FATAL: password authentication failed for user "MxAdmin" 2020-07-31 15:22:56.922 UTC [29] DETAIL: Role "MxAdmin" does not exist.   And here’s the env section of my mendix-app.yaml, with the endpoint of my postgres-service: env: - name: ADMIN_PASSWORD value: "T3stP4ssword" - name: DATABASE_ENDPOINT value: postgres://MxAdmin:T3stP4ssword@172.17.0.4:5432/mendix  
asked
5 answers
2
  1. The error that you mentioned about “password needed 8 characters”, I think this must have been reported from Mendix for the MxAdmin password. This you configure in mendix-app-secrets.yaml with ADMIN_PASSWORD which is totally different.
  2. The password you provide in postgres-deployment.yaml is for your DB user for postgres which should not complain about 8 characters. 

 

To be more precise about the errors you reported till now:

  1. Role "MxAdmin" does not exist: The first error you reported. This means the user MxAdmin does not exist in your database. Here your configuration of DATABASE_ENDPOINT was wrong. You used MxAdmin username and password. But in the logs there is also “database system is ready to accept connections” which means your DB server is up and running properly.
  2. database "mendix" does not exist: Later, you configured postgres-deployment.yaml with proper user name and password. But you configured a wrong DB name in the DATABASE_ENDPOINT. This means, your username and password actually worked and Mendix was able to connect to postgres server. But the database does not exist.
  3. password authentication failed for user "mendix": The last error you reported, this means your username and password does not match. But what you did in Step 2 along with proper DB name must work. 
answered
0

Are you really sure that the database instance you created has the user MxAdmin with T3stP4ssword?

https://docs.mendix.com/developerportal/deploy/run-mendix-on-kubernetes#4-1-deploying-the-postgresql-database

In postgres-deployment.yaml file, the DB related env must be set properly. The same username and password must be used in your DB end point URL. 

Also please check the database URL. 

env:
            - name: POSTGRES_DB
              value: db0
            - name: POSTGRES_USER
              value: mendix
            - name: POSTGRES_PASSWORD
              value: mendix
answered
0

Thanks for your response. When I use the username and password then I get the following error:

INFO - Services: Adding 0 authority certificate(s)
ERROR - M2EE: An error occurred while initializing the Runtime: Error on initializing database connection.
ERROR - M2EE: com.mendix.m2ee.api.AdminException: An error occurred while initializing the Runtime: Error on initializing database connection.
        at com.mendix.basis.impl.MxRuntimeImpl.start(MxRuntimeImpl.java:428)

Caused by: com.mendix.connectionbus.ConnectionBusRuntimeException: Error on initializing database connection.
        at com.mendix.connectionbus.ConnectionBusInitializer.throwDefault$1(ConnectionBusInitializer.scala:58)

Caused by: org.postgresql.util.PSQLException: FATAL: database "mendix" does not exist
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
        at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2559)
        at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:133)
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:250)
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
        at org.postgresql.Driver.makeConnection(Driver.java:454)
        at org.postgresql.Driver.connect(Driver.java:256)
        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
        at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:94)
        at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:79)
        at org.apache.commons.dbcp2.DataSourceConnectionFactory.createConnection(DataSourceConnectionFactory.java:83)
        at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:355)
        at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:874)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:417)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:346)
        at org.apache.commons.dbcp2.PoolingDataSource.getConnection(PoolingDataSource.java:134)
        at com.mendix.connectionbus.connections.jdbc.ConnectionManager.getConnection(ConnectionManager.java:49)
        at com.mendix.connectionbus.ConnectionBusInitializer.$anonfun$createConnection$1(ConnectionBusInitializer.scala:52)
        at scala.util.Try$.apply(Try.scala:213)
        at com.mendix.connectionbus.ConnectionBusInitializer.retry(ConnectionBusInitializer.scala:60)
        at com.mendix.connectionbus.ConnectionBusInitializer.createConnection(ConnectionBusInitializer.scala:52)
        at com.mendix.connectionbus.ConnectionBusInitializer.initialize(ConnectionBusInitializer.scala:42)
        at com.mendix.connectionbus.ConnectionBusImpl.initialize(ConnectionBusImpl.java:350)
        at com.mendix.basis.impl.MxRuntimeImpl.initializeConnectionBus(MxRuntimeImpl.java:569)
        at com.mendix.basis.impl.MxRuntimeImpl.start(MxRuntimeImpl.java:396)
        at com.mendix.m2ee.appcontainer.actions.StartAction.startRuntime(StartAction.java:49)
        at com.mendix.m2ee.appcontainer.actions.StartAction.execute(StartAction.java:30)
        at com.mendix.m2ee.appcontainer.server.handler.HttpAdminHandler.handle(HttpAdminHandler.java:129)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.Server.handle(Server.java:502)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
        at java.base/java.lang.Thread.run(Unknown Source)

ERROR: Executing start did not succeed: result: 1, message: An error occurred while initializing the Runtime: Error on initializing database connection., caused by: Error on initializing database connection.
WARNING: start failed, stopping
INFO: stopping app...
INFO: Waiting for the application to shutdown...
INFO - Core: Mendix Runtime is shutting down now...
INFO - Core: Mendix Runtime is now shut down.
INFO: The application has been stopped successfully.


And for reference here are my postgres env:

          env:
            - name: POSTGRES_DB
              value: db0
            - name: POSTGRES_USER
              value: mendix
            - name: POSTGRES_PASSWORD
              value: mendix

& in my mendix-app yaml:

          env:
            - name: ADMIN_PASSWORD
              value: mendix
            - name: DATABASE_ENDPOINT
              value: postgres://mendix:mendix@172.17.0.4:5432/mendix

 

answered
0

In the postgres env, you configured the database as db0. Change that value to mendix. 

Or change the database_endpoint to postgres://mendix:mendix@172.17.0.4:5432/db0

Then it should work

answered
0

Thanks for your help so far. I get the same error as in my first post, unfortunately. I initially got an error that the password needed 8 characters, so I changed it from mendix to MendixP4ssword! .

 

Logs from mendix pod:

WARNING - ConnectionBus: Database connections: 0 active, 0 idle.
ERROR - ConnectionBus: Opening JDBC connection to Some(172.17.0.4:5432) failed with SQLState: 28P01 Error code: 0 Message: FATAL: password authentication failed for user "mendix" Retrying...(1/4)
WARNING - ConnectionBus: Database connections: 0 active, 0 idle.
ERROR - ConnectionBus: Opening JDBC connection to Some(172.17.0.4:5432) failed with SQLState: 28P01 Error code: 0 Message: FATAL: password authentication failed for user "mendix" Retrying...(2/4)
WARNING - ConnectionBus: Database connections: 0 active, 0 idle.
ERROR - ConnectionBus: Opening JDBC connection to Some(172.17.0.4:5432) failed with SQLState: 28P01 Error code: 0 Message: FATAL: password authentication failed for user "mendix" Retrying...(3/4)
WARNING - ConnectionBus: Database connections: 0 active, 0 idle.
ERROR - ConnectionBus: Opening JDBC connection to Some(172.17.0.4:5432) failed with SQLState: 28P01 Error code: 0 Message: FATAL: password authentication failed for user "mendix", giving up...(4/4)
ERROR - M2EE: An error occurred while initializing the Runtime: Error on initializing database connection.
ERROR - M2EE: com.mendix.m2ee.api.AdminException: An error occurred while initializing the Runtime: Error on initializing database connection.
        at com.mendix.basis.impl.MxRuntimeImpl.start(MxRuntimeImpl.java:428)

 

Logs from postgres pod:

$ kubectl logs postgres-76546884d7-p2ccw
2020-08-03 09:40:42.375 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-08-03 09:40:42.375 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2020-08-03 09:40:42.383 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-08-03 09:40:42.390 UTC [22] LOG:  database system was shut down at 2020-08-03 09:39:26 UTC
2020-08-03 09:40:42.393 UTC [1] LOG:  database system is ready to accept connections
2020-08-03 09:41:15.382 UTC [30] FATAL:  password authentication failed for user "mendix"
2020-08-03 09:41:15.382 UTC [30] DETAIL:  Password does not match for user "mendix".
        Connection matched pg_hba.conf line 95: "host all all all md5"

 

 

& my mendix-app.yaml:

          env:
            - name: ADMIN_PASSWORD
              value: MendixP4ssword!
            - name: DATABASE_ENDPOINT
              value: postgres://mendix:MendixP4ssword!@172.17.0.4:5432/db0

& my postgres-deployment.yaml:

          env:
            - name: POSTGRES_DB
              value: db0
            - name: POSTGRES_USER
              value: mendix
            - name: POSTGRES_PASSWORD
              value: MendixP4ssword!

 

answered