【发布时间】:2020-06-19 23:44:55
【问题描述】:
我正在尝试通过 Helm 图表将应用程序部署到 Kubernetes 集群。每次我尝试部署应用程序时,我都会得到 p>
"Liveness probe failed: Get http://172.17.0.7:80/: dial tcp 172.17.0.7:80:连接:连接被拒绝”和“就绪探测失败:获取http://172.17.0.7:80/:拨号 tcp 172.17.0.7:80:连接: 连接被拒绝”
。
这是我的部署.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mychart.fullname" . }}
labels:
{{- include "mychart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "mychart.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "mychart.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "mychart.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: nikovlyubomir/docker-spring-boot:latest
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
initialDelaySeconds: 200
httpGet:
path: /
port: 80
readinessProbe:
initialDelaySeconds: 200
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
我读到可能的解决方案可能是在两个探针中添加更多的 initialDelaySecond,但这仍然没有解决我的问题。
有什么意见吗?
【问题讨论】:
-
探针是一直失败还是最终会变成绿色?应用程序是否正确启动?日志是怎么说的?
-
探测一直失败,每当我部署应用程序时,我都会看到部署绿色大约 1-2 分钟,但过了一段时间(可能是延迟)它又变回红色。我认为应用程序已正确启动,这些是我的事件:1)成功将默认/examplee-mychart-67f9c7c485-47zw8 分配给 minikube 2)容器映像“nikovlyubomir/docker-spring-boot:latest”已经存在于机器 3)创建容器 mychart
-
4) 启动容器 mychart
-
5) Liveness probe failed: Get 172.17.0.7:80: dial tcp 172.17.0.7:80: connect: connection denied 6) Liveness probe failed: Get 172.17.0.7:80: dial tcp 172.17.0.7:80:连接:连接被拒绝 7 ) 容器 mychart 失败的活性探测,将被重新启动 8 ) 回退重新启动失败的容器
-
应用程序是否真的在端口 80 上运行?通常,默认端口是 8080。请检查 pod 的日志。应用程序应说明是否已成功启动或因错误而终止。
标签: java spring-boot kubernetes deployment kubernetes-helm