Database needs bootstrap; run 'kong migrations bootstrap'

Hi I running KONG in kubernetes.

for 6 month our Kong pod is OK and doesn’t has an error. But today my kong pod already crash and we try to fix it by build a new pod. But we got following error :

2019/03/30 05:41:23 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:337: database needs bootstrap; run 'kong migrations bootstrap'
stack traceback:
    [C]: in function 'error'
    /usr/local/share/lua/5.1/kong/init.lua:337: in function 'init'
    init_by_lua:3: in main chunk
nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:337: database needs bootstrap; run 'kong migrations bootstrap'
stack traceback:
    [C]: in function 'error'
    /usr/local/share/lua/5.1/kong/init.lua:337: in function 'init'
    init_by_lua:3: in main chunk

I’ve read similar cases like this. and they said this is a bug in kong version 1.0.x.
Then we try to upgrading our version to 1.1.1 and still got same error.

this is our simple yml

spec:
     containers:
     - name: prd-kong
       image: kong:1.1.1
       env:

really appreciate the answers and suggestions

Hi @widada

Did you upgrade your Kong cluster before you got this error? You need to run kong migrations bootstrap only once in the entire lifecycle of a database for Kong.

Hi,

I had the same problem more than one time; happens when the pods and or the host is restarted; so I have to run kong migrations bootstrap and this will wipe all my configuration in Kong.

Regards,

Do you have persistence enabled for your Postgres pod? Is it backed by a persistent volume?
If not, then you need to enable that to persist Kong’s configuration in the DB pod.

1 Like

Hi @hbagdi,

Yes, we do have a PV enable for the Postgres DB.

Regards,

This is the error we faced.

2019/05/28 12:29:09 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:337: database needs bootstrap; run 'kong migrations bootstrap'
stack traceback:
	[C]: in function 'error'
	/usr/local/share/lua/5.1/kong/init.lua:337: in function 'init'
	init_by_lua:3: in main chunk
nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:337: database needs bootstrap; run 'kong migrations bootstrap'
stack traceback:
	[C]: in function 'error'
	/usr/local/share/lua/5.1/kong/init.lua:337: in function 'init'
	init_by_lua:3: in main chunk

We found the issue, and was about configuration; the volume mount path it wasn’t set in the deployment config.

          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgresql

Thank @hbagdi

Hi I hava same issue
I use satable charts kong and postgress

PV is enable and mounted
/dev/rbd3 on /bitnami/postgresql type xfs (rw,relatime,seclabel,attr2,inode64,sunit=8192,swidth=8192,noquota)

cd /bitnami/postgresql/data <== mountpath ls
base pg_dynshmem pg_multixact pg_serial pg_stat_tmp pg_twophase pg_xact postmaster.pid
global pg_ident.conf pg_notify pg_snapshots pg_subtrans PG_VERSION postgresql.auto.conf
pg_commit_ts pg_logical pg_replslot pg_stat pg_tblspc pg_wal postmaster.opts

[Error Message in wait-for-db container]
database needs bootstrapping; run ‘kong migrations bootstrap’
Error: /usr/local/share/lua/5.1/kong/cmd/start.lua:50: nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:337: database needs bootstrap; run ‘kong migrations bootstrap’
stack traceback:
[C]: in function ‘error’
/usr/local/share/lua/5.1/kong/init.lua:337: in function ‘init’
init_by_lua:3: in main chunk
_lua:3: in main chunk

I tried enable migration
but there are same issue
BusyBox v1.22.1 (2014-05-22 23:22:11 UTC) multi-call binary.
Usage: nc [-iN] [-wN] [-l] [-p PORT] [-f FILE|IPADDR PORT] [-e PROG]
Open a pipe to IP:PORT or FILE
-l Listen mode, for inbound connects
(use -ll with -e for persistent server)
waiting for db
-p PORT Local port
-w SEC Connect timeout
-i SEC Delay interval for lines sent
-f FILE Use file (ala /dev/ttyS0) instead of network
-e PROG Run PROG after connect
nc: invalid option – z

I use this command after adding postgresql stable chart in ./kong/charts

helm install --name kong
–set ‘ingressController.enabled=true’
./kong