【发布时间】:2022-07-11 23:02:34
【问题描述】:
当我尝试运行 kubectl apply -f frontend.yaml 时,我收到来自 kubectl get pods 和 kubectl describe pods 的以下响应
// frontend.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: malvacom-frontend
labels:
app: malvacom-frontend
spec:
replicas: 1
selector:
matchLabels:
app: malvacom-frontend
template:
metadata:
labels:
app: malvacom-frontend
spec:
containers:
- name: malvacom-frontend
image: docker.io/forsrobin/malvacom_frontend
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
resources:
limits:
memory: "128Mi"
cpu: "200m"
livenessProbe:
httpGet:
path: /index.html
port: 80
initialDelaySeconds: 15
timeoutSeconds: 2
periodSeconds: 5
failureThreshold: 1
readinessProbe:
httpGet:
path: /index.html
port: 80
initialDelaySeconds: 15
periodSeconds: 5
failureThreshold: 1
command: [ "sleep" ]
args: [ "infinity" ]
然后响应是
kubectl get pods
malvacom-frontend-8575c8548b-n959r 0/1 CrashLoopBackOff 5 (95s ago) 4m38s
kubectl describe pods
QoS Class: Guaranteed
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 17s default-scheduler Successfully assigned default/malvacom-frontend-8575c8548b-n959r to shoot--p1622--malvacom-web-xdmoi2-z1-54776-bpjpw
Normal Pulled 15s (x2 over 16s) kubelet Container image "docker.io/forsrobin/malvacom_frontend" already present on machine
Normal Created 15s (x2 over 16s) kubelet Created container malvacom-frontend
Normal Started 15s (x2 over 16s) kubelet Started container malvacom-frontend
Warning BackOff 11s (x4 over 14s) kubelet Back-off restarting failed container
正如我所理解的,pod 启动了,但是因为它没有继续执行的任务,kubernetes 删除/停止了 pod。我可以毫无问题地在本地运行图像,例如,如果我使用另一个图像thenetworkchuck/nccoffee:pourover ,它可以毫无问题地工作。这是我的 Dockerfile
FROM node:alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY ./package.json /app/
RUN yarn --silent
COPY . /app
RUN yarn build
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
【问题讨论】:
标签: reactjs docker nginx kubernetes networking