Akashii
Akashii

Reputation: 2281

Back-off restarting failed container openshift kubernetes

I have a Dockerfile running Kong-api to deploy on openshift. It build okay, but when I check pods I get Back-off restarting failed container. Here is my dockerfile

FROM ubuntu:18.04
RUN apt-get update && apt-get install -y apt-transport-https curl lsb-core
RUN echo "deb https://kong.bintray.com/kong-deb `lsb_release -sc` main" | tee -a /etc/apt/sources.list
RUN curl -o bintray.key https://bintray.com/user/downloadSubjectPublicKey?username=bintray
RUN apt-key add bintray.key
RUN apt-get update && apt-get install -y kong

COPY kong.conf /etc/kong/
RUN kong migrations bootstrap [-c /etc/kong/kong.conf]

EXPOSE 8000 8443 8001 8444
ENTRYPOINT ["kong", "start", "[-c /etc/kong/kong.conf]"]

Where is my wrong? Please help me. Thanks in advance

Upvotes: 1

Views: 1362

Answers (1)

Mostafa Hussein
Mostafa Hussein

Reputation: 11940

In order to make the kong start correctly, you need to execute these commands when you have an active Postgres connection:

kong migrations bootstrap && kong migrations up

Also, note that the format of the current Dockerfile is not valid if you would like to pass options within the ENTRYPOINT you can write it like that:

ENTRYPOINT ["kong", "start","-c", "/etc/kong/kong.conf"]

Also, you need to remove this line:

RUN kong migrations bootstrap [-c /etc/kong/kong.conf]

Note that the format of the above line is not valid as RUN expects a normal shell command so using [] in this case is not correct.

So as you deploy to Openshift there are several ways to achieve what you need.

  • You can make use of initContainers which allows you to execute the required commands before the actual service is up.
  • You can check the official helm chart for Kong in order to know how it works or use helm to install Kong itself.

Upvotes: 2

Related Questions