I upgraded my .Net Core 2.1 to 3.1. After upgrade Liveness and Readiness probe to pods failed. Below is my docker file snippet:
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"]
When I check logs of the pod I get below errors:
Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'
Liveness probe failed: Get http://yyyy:80/: dial tcp yyyy:80: connect: connection refused
Here is my Deployment.yaml file:
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 }}
127.0.0.1
instead oflocalhost
– Matt0.0.0.0:5000
and not tolocalhost:5000
so that its accessible from outside of the pod and also set your healthcheck to port 5000, not port 80 – Matt