FROM ubuntu
MAINTAINER user@gmail.com
RUN apt-get update
RUN apt-get install -y openjdk-8-jdk
ADD build/libs/micro-service-gradle-0.0.1-SNAPSHOT.jar /var/local/
ENTRYPOINT exec java $JAVA_OPTS \
-jar /var/local/micro-service-gradle-0.0.1-SNAPSHOT.jar
EXPOSE 8080
apiVersion: apps/v1
kind: Deployment
metadata:
name: micro-service-gradle
labels:
app: micro-service-gradle
spec:
replicas: 1
selector:
matchLabels:
app: micro-service-gradle
template:
metadata:
labels:
app: micro-service-gradle
spec:
containers:
- name: micro-service-gradle
image: micro-service-gradle:latest
ports:
- containerPort: 8080
Deploying spring boot application in Kubernetes . Pod is not getting created. When i check kubectl get pods. it says CrashLoopBackOff.
NAME READY STATUS RESTARTS AGE
micro-service-gradle-fc97c97b-8hwhg 0/1 CrashLoopBackOff 6 6m23s
I tried to check logs for the same container. Logs are empty
kubectl logs -p micro-service-gradle-fc97c97b-8hwhg
I created the container manually using docker run. There is no issues in image and containers works fine.
How to verify the logs for why the pods in crash status.
You deployment resource looks ok. As you are able to create the container manually using, problem is with the connection to the image repository. Setup the impage pull secret and you should be able to create the pod
I had the same problem, but using this worked for me:
image: Image:latest
command: [ "sleep" ]
args: [ "infinity" ]
I ran into a similar issue. When I run
kubectl describe pod <podname>
and read the events, Though the image was pulled, message outputted was 'restarting failed container' The pod was exciting because it was not performing any task. To keep it running, I add a sleep command based on similar example in the docs
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
This SO answer also mentions running an infinite could also solve the problem https://stackoverflow.com/a/55610769/7128032
I faced similar issue. Just verify if your container is able to run continuously. You have to run the process in foreground to keep container running.
You need to use
kubectl describe pod micro-service-gradle-fc97c97b-8hwhg
to get the relevant logs. This should guide you to your problem.