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