英文:
Probes in K8's failed with 404
问题
我在akkaHttp应用程序中运行一个Deployment,pod已成功创建并处于就绪状态,但当我在Deployment中添加了livenessProbe、readinessProbe和startupProbe后,应用程序处于running状态但不是ready状态。在描述pod后,我看到了一个错误:Startup probe failed: HTTP probe failed with statuscode: 404
,Readiness probe failed: HTTP probe failed with statuscode: 404
,Liveness probe failed: HTTP probe failed with statuscode: 404
。我也增加了初始延迟,但仍然遇到相同的问题。
这是我的YAML文件:
apiVersion: apps/v1
kind: Deployment
metadata:
name: akka-deployment
spec:
replicas: 1
selector:
matchLabels:
app: akka-label
template:
metadata:
name: akka-pod
labels:
app: akka-label
spec:
containers:
- name: akka-container
image: elasticdeployment:0.1.0-SNAPSHOT
ports:
- containerPort: 8083
name: elastic-port
livenessProbe:
httpGet:
path: /
port: 8083
initialDelaySeconds: 50
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 8083
initialDelaySeconds: 50
periodSeconds: 10
startupProbe:
httpGet:
path: /
port: 8083
failureThreshold: 30
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: akka-service
spec:
type: LoadBalancer
selector:
app: akka-label
ports:
- protocol: TCP
port: 8080
targetPort: 8083
我做错了什么?
英文:
I'm running an akkaHttp application in a Deployment the pod created and running successfully and in a ready state but when in the deployment I added livenessProbe, readinessProbe and startupProbe the app is in running state but not in a ready state, After describing the pod I saw an error Startup probe failed: HTTP probe failed with statuscode: 404
, Readiness probe failed: HTTP probe failed with statuscode: 404
Liveness probe failed: HTTP probe failed with statuscode: 404
. I increase the initial delay as well but still getting same problem.
here are my yaml files:
apiVersion: apps/v1
kind: Deployment
metadata:
name: akka-deployment
spec:
replicas: 1
selector:
matchLabels:
app: akka-label
template:
metadata:
name: akka-pod
labels:
app: akka-label
spec:
containers:
- name: akka-container
image: elasticdeployment:0.1.0-SNAPSHOT
ports:
- containerPort: 8083
name: elastic-port
livenessProbe:
httpGet:
path: /
port: 8083
initialDelaySeconds: 50
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 8083
initialDelaySeconds: 50
periodSeconds: 10
startupProbe:
httpGet:
path: /
port: 8083
failureThreshold: 30
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: akka-service
spec:
type: LoadBalancer
selector:
app: akka-label
ports:
- protocol: TCP
port: 8080
targetPort: 8083
Where I'm doing wrong?
答案1
得分: 1
你的探测在端口 8083
上命中 /
,返回 404
。你可以通过端口转发到该 Pod 来进行检查。由于你只有一个副本,可以这样操作:
kubectl port-forward -n {namespace} deployment/akka-deployment 8083:8083
然后在另一个终端中执行:
curl -I localhost:8083/
这个 curl 命令模拟了探测的操作。除非探测检查成功(即返回 200
),你的 Pod 将永远无法准备就绪。
实际上,由于你还为存活探测设置了相同的内容,集群会开始终止你的 Pod,因为它认为它已经死了。
你应该调查容器为何返回 404
。也许你正在针对错误的端口进行探测,或者也许你需要使用不同的路径来检查(也许是 /health
或 /status
?)。
英文:
Your probes are hitting /
on port 8083
and that is returning a 404
. You can check this by port-forwarding into the pod. Since you only have one replica, you can do it this way:
kubectl port-forward -n {namespace} deployment/akka-deployment 8083:8083
Then in another terminal:
curl -I localhost:8083/
This curl replicates what the probes are trying to do. Unless the probe check succeeds (i.e. returns 200
), your pod will never be ready.
In fact, since you have also set this for the liveness probe, the cluster will start killing your pod since it thinks its dead.
You should investigate why the container is returning 404
. Maybe you're pinging the wrong port, or maybe you need to use a different path to check (perhaps /health
or /status
?)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论