I am creating several microservices on Azure (Kubernetes) and I have the following problem: if I do not put this command inside the YAML container it shows the message of BackOff or CrashloopBack and does not leave there.
The command I place is this:
command: [ "sleep" ]
args: [ "infinity" ]
This is the error that shows if I do not put this code
Warning BackOff 7s (x4 over 37s) kubelet, aks-agentpool-29153703-2 Back-off restarting the failed container
My DockerFile for one of this microservices:
FROM node:10
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD npm start EXPOSE 6060
My YAML:
apiVersion: apps/v1
kind: Deployment
metadata:
name: permis-deployment
labels:
app: permis-deployment
spec:
replicas: 1
selector:
matchLabels:
app: permis
template:
metadata:
labels:
app: permis
spec:
containers:
- name: permis
image: myacr.azurecr.io/permission-container:latest
command: [ "sleep" ]
args: [ "infinity" ]
ports:
- containerPort: 6060
apiVersion: v1
kind: Service
metadata:
name: permis-service
spec:
selector:
app: permis
ports:
- protocol: TCP
port: 6060
targetPort: 6060
type: LoadBalancer
Can you tell me what I am doing wrong or what is wrong?
Thank you!
If your app is running fine, change the Dockerfile
by this one and re-create the image. Should work:
FROM node:10
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
EXPOSE 6060
CMD ["npm", "start"]
i suggest you do the following:
containers:
- args:
- -ec
- sleep 1000
command:
- /bin/sh
invoking sleep
directly didnt work for me