Started working on Docker and kubernetes lately. I ran into a problem which I don't actually understand fully.
The thing is when I execute my svc.yaml(service) and rc.yaml(replication controller) pods get created but its status is terminated.
I tried checking the possible reason for failure by using the command
docker ps -a
954c3ee817f9 localhost:5000/HelloService
"/bin/sh -c ./startSe" 2 minutes ago Exited (127) 2 minutes ago
k8s_HelloService.523e3b04_HelloService-64789_default_40e92b63-707a-11e7-9b96-080027f96241_195f2fee
then tried running docker run -i -t localhost:5000/HelloService
/bin/sh: ./startService.sh: not found
what is the possible reason I am getting these errors.
Docker File:
FROM alpine:3.2
VOLUME /tmp
ADD HelloService-0.0.1-SNAPSHOT.jar app.jar
VOLUME /etc
ADD /etc/ /etc/
ADD startService.sh /startService.sh
RUN chmod 700 /startService.sh
ENTRYPOINT ./startService.sh
startService.sh
#!/bin/sh
touch /app.jar
java -Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx256m -jar /app.jar
Also I would like to know if there any specific way I can access the logs from kubernetes for the terminated pods?
Update : on running below command
kubectl describe pods HelloService-522qw
24s 24s 1 {default-scheduler } Normal Scheduled Successfully
assigned HelloService-522qw to ssantosh.centos7 17s 17s 1 {kubelet ssantosh.centos7} spec.containers{HelloService} Normal Created Created container with docker id b550557f4c17; Security:[seccomp=unconfined]
17s 17s 1 {kubelet
ssantosh.centos7} spec.containers{HelloService} Normal Started Started container with docker id b550557f4c17 18s 16s 2 {kubelet
ssantosh.centos7} spec.containers{HelloService} Normal Pulling pulling image "localhost:5000/HelloService" 18s 16s 2 {kubelet
ssantosh.centos7} spec.containers{HelloService} Normal Pulled Successfully pulled image "localhost:5000/HelloService" 15s 15s 1 {kubelet
ssantosh.centos7} spec.containers{HelloService} Normal Created Created container with docker id d30b10211b1b; Security:[seccomp=unconfined]
14s 14s 1 {kubelet
ssantosh.centos7} spec.containers{HelloService} Normal Started Started container with docker id d30b10211b1b 12s 11s 2 {kubelet
ssantosh.centos7} spec.containers{HelloService} Warning BackOff Back-off restarting failed docker container 12s 11s 2 {kubelet
ssantosh.centos7} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "HelloService" with CrashLoopBackOff:
"Back-off 10s restarting failed container=HelloService
pod=HelloService-522qw_default(1e951b45-7116-11e7-9b96-080027f96241)"
you need jdk on the machine also need to update the Dockerfile, remove the . infront of startService.sh command. like below
ENTRYPOINT /startService.sh
this will fix this error message.
/bin/sh: ./startService.sh: not found
The issue was there is no java as a part of alpine image.
So modified the
FROM alpine:3.2
to
FROM anapsix/alpine-java