我正在嘗試在 kubernetes 上部署 Angular 前端應用程式,但我總是收到此錯誤:
NAME READY STATUS RESTARTS AGE
common-frontend-f74c899cc-p6tdn 0/1 CrashLoopBackOff 7 15m
當我嘗試查看 pod 的日志時,它只列印空行,所以我怎么才能找出問題所在
這是 dockerfile,始終通過此 dockerfile 構建管道:
### STAGE 1: Build ###
# We label our stage as 'builder'
FROM node:10.11 as builder
COPY package.json ./
COPY package-lock.json ./
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
ARG NODE_OPTIONS="--max_old_space_size=4096"
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app
WORKDIR /ng-app
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN $(npm bin)/ng build --prod --output-hashing=all
### STAGE 2: Setup ###
FROM nginx:1.13.3-alpine
## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From 'builder' stage copy the artifacts in dist folder to default nginx public folder
COPY --from=builder /ng-app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
和部署.yaml
---
apiVersion: v1
kind: Service
metadata:
name: common-frontend
labels:
app: common-frontend
spec:
type: ClusterIP
selector:
app: common-frontend
ports:
- port: 80
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: common-frontend
labels:
app: common-frontend
spec:
replicas: 1
selector:
matchLabels:
app: common-frontend
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 33%
template:
metadata:
labels:
app: common-frontend
spec:
containers:
- name: common-frontend
image: skunkstechnologies/common-frontend:<VERSION>
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
timeoutSeconds: 1
我真的不知道可能是什么問題,有人可以幫忙嗎?謝謝!
uj5u.com熱心網友回復:
看起來 Kubernetes 未能通過 liveness 探測并將重新啟動 pod。嘗試評論“活性探測”部分并重新啟動它。如果有幫助,請更正探測引數——超時、延遲等。
uj5u.com熱心網友回復:
唔。您的容器死亡并嘗試重新啟動。首先,嘗試查看他的日志和狀態:
kubectl logs <container_name>
kubectl describe pod <container_name>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/383895.html
標籤:有角的 码头工人 Kubernetes 文件
