【发布时间】:2020-04-22 12:54:52
【问题描述】:
我将 .Net Core 2.1 升级到 3.1。升级后对 Pod 的 Liveness 和 Readiness 探测失败。 下面是我的docker文件sn-p:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
ENTRYPOINT ["dotnet", "Web.dll"]
当我检查 pod 的日志时,我得到以下错误:
无法绑定到 IPv6 环回接口上的 http://localhost:5000:“无法分配请求的地址”
Liveness probe failed: Get http://yyyy:80/: dial tcp yyyy:80: connect: connection denied
这是我的 Deployment.yaml 文件:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "staging.fullname" . }}
namespace: staging
labels:
app.kubernetes.io/name: {{ include "staging.name" . }}
helm.sh/chart: {{ include "staging.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "staging.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "staging.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
imagePullSecrets:
- name: {{ .Values.image.pullSecret }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- name: ASPNETCORE_ENVIRONMENT
value: "Staging"
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 10
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 }}
【问题讨论】:
-
提供完整的部署文件以及服务和pod
-
@ArghyaSadhu 添加了 deployment.yaml 文件内容
-
尝试绑定到
127.0.0.1而不是localhost -
@HelloWorld 我应该在哪个地方进行更改?现在仅供参考,我在项目中提到使用 url “localhost:5000”。
-
好的,所以您的应用程序在端口 5000 而不是 80 上工作。所以首先将您的应用程序绑定到
0.0.0.0:5000而不是localhost:5000以便它可以从 pod 外部访问并设置您的健康检查到端口 5000,而不是端口 80
标签: angular asp.net-mvc docker asp.net-core kubernetes