Not found 404 nginx:无法通过入口ip连接到minikube



我是Kubernetes和helm的新手,最近尝试了Pluralsight的一个教程。

根据教程,我的入口文件看起来像这样-
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress
spec:
rules:
{{- range .Values.ingress.hosts }}
- host: {{ $.Release.Name }}.{{ .host.domain }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $.Release.Name}}-{{ .host.chart }}
port:
number: 80
{{- end }}

当我尝试连接到minikube ip时,它给我这个错误-

404 Not Found
----
nginx

我已经使用helm install dev guestbook安装了helm chart这是我的舱和入口日志命令-kubectl get ingress-

NAME                    CLASS    HOSTS                                                    ADDRESS          PORTS   AGE
dev-guestbook-ingress   <none>   dev.frontend.minikube.local,dev.backend.minikube.local   192.168.99.104   80      136m

命令-kubectl describe ingress dev-guestbook-ingress

Name:             dev-guestbook-ingress
Namespace:        default
Address:          192.168.99.104
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host                         Path  Backends
----                         ----  --------
dev.frontend.minikube.local
/*   dev-frontend:80 (172.17.0.3:4200)
dev.backend.minikube.local
/*   dev-backend:80 (172.17.0.5:3000)
Annotations:                   meta.helm.sh/release-name: dev
meta.helm.sh/release-namespace: default
Events:
Type    Reason  Age                From                      Message
----    ------  ----               ----                      -------
Normal  Sync    32m (x2 over 33m)  nginx-ingress-controller  Scheduled for sync

这些是我使用命令-

后进入pod的日志
kubectl logs ingress-nginx-controller-69bdbc4d57-jnswj  --namespace=ingress-nginx
-------------------------------------------------------------------------------
NGINX Ingress controller
Release:       v1.0.0-beta.1
Build:         a091b01f436b4ab4f3d04264df93962432a02450
Repository:    https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.20.1
-------------------------------------------------------------------------------
W0928 13:00:25.824832       8 client_config.go:615] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0928 13:00:25.825340       8 main.go:221] "Creating API client" host="https://10.96.0.1:443"
W0928 13:00:56.974273       8 main.go:262] Initial connection to the Kubernetes API server was retried 1 times.
I0928 13:00:56.974428       8 main.go:265] "Running in Kubernetes cluster" major="1" minor="22" git="v1.22.2" state="clean" commit="8b5a19147530eaac9476b0ab82980b4088bbc1b2" platform="linux/amd64"
I0928 13:00:57.378459       8 main.go:104] "SSL fake certificate created" file="/etc/ingress-controller/ssl/default-fake-certificate.pem"
I0928 13:00:57.401933       8 ssl.go:531] "loading tls certificate" path="/usr/local/certificates/cert" key="/usr/local/certificates/key"
I0928 13:00:57.426834       8 nginx.go:253] "Starting NGINX Ingress controller"
I0928 13:00:57.451326       8 event.go:282] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"udp-services", UID:"3fd79ae9-35c2-4147-aa8c-b8bdb94a46e7", APIVersion:"v1", ResourceVersion:"787", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/udp-services
I0928 13:00:57.451353       8 event.go:282] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"ingress-nginx-controller", UID:"dc2450e0-6542-4b42-81e3-0b68598bdb8d", APIVersion:"v1", ResourceVersion:"785", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/ingress-nginx-controller
I0928 13:00:57.453791       8 event.go:282] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"tcp-services", UID:"c22ae05e-ac70-47da-9573-087394876f41", APIVersion:"v1", ResourceVersion:"786", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/tcp-services
I0928 13:00:58.543719       8 store.go:361] "Ignoring ingress because of error while validating ingress class" ingress="default/dev-guestbook-ingress" error="ingress does not contain a valid IngressClass"
I0928 13:00:58.640831       8 nginx.go:295] "Starting NGINX process"
I0928 13:00:58.640960       8 leaderelection.go:243] attempting to acquire leader lease ingress-nginx/ingress-controller-leader...
I0928 13:00:58.641293       8 nginx.go:315] "Starting validation webhook" address=":8443" certPath="/usr/local/certificates/cert" keyPath="/usr/local/certificates/key"
I0928 13:00:58.641425       8 controller.go:150] "Configuration changes detected, backend reload required"
I0928 13:00:58.657350       8 leaderelection.go:253] successfully acquired lease ingress-nginx/ingress-controller-leader
I0928 13:00:58.657383       8 status.go:84] "New leader elected" identity="ingress-nginx-controller-69bdbc4d57-jnswj"
I0928 13:00:58.668104       8 status.go:204] "POD is not ready" pod="ingress-nginx/ingress-nginx-controller-69bdbc4d57-jnswj" node="minikube"
I0928 13:00:59.289049       8 controller.go:167] "Backend successfully reloaded"
I0928 13:00:59.289288       8 controller.go:178] "Initial sync, sleeping for 1 second"
I0928 13:00:59.289389       8 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"ingress-nginx", Name:"ingress-nginx-controller-69bdbc4d57-jnswj", UID:"84ad1680-72e1-4733-a1e7-9c314527d810", APIVersion:"v1", ResourceVersion:"2634", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
I0928 13:06:22.563182       8 main.go:101] "successfully validated configuration, accepting" ingress="dev-guestbook-ingress/default"
I0928 13:06:22.568356       8 store.go:396] "creating ingress" ingress="default/dev-guestbook-ingress" ingressclass="nginx"
I0928 13:06:22.568860       8 controller.go:150] "Configuration changes detected, backend reload required"
I0928 13:06:22.569014       8 event.go:282] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"dev-guestbook-ingress", UID:"519a99af-aec5-4316-ae38-d1bcc1127c59", APIVersion:"networking.k8s.io/v1", ResourceVersion:"3001", FieldPath:""}): type: 'Normal' reason: 'Sync' Scheduled for sync
I0928 13:06:22.639189       8 controller.go:167] "Backend successfully reloaded"
I0928 13:06:22.639649       8 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"ingress-nginx", Name:"ingress-nginx-controller-69bdbc4d57-jnswj", UID:"84ad1680-72e1-4733-a1e7-9c314527d810", APIVersion:"v1", ResourceVersion:"2634", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration
I0928 13:06:58.702705       8 status.go:284] "updating Ingress status" namespace="default" ingress="dev-guestbook-ingress" currentValue=[] newValue=[{IP:192.168.99.104 Hostname: Ports:[]}]
I0928 13:06:58.708447       8 event.go:282] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"dev-guestbook-ingress", UID:"519a99af-aec5-4316-ae38-d1bcc1127c59", APIVersion:"networking.k8s.io/v1", ResourceVersion:"3034", FieldPath:""}): type: 'Normal' reason: 'Sync' Scheduled for sync
192.168.99.1 - - [28/Sep/2021:13:07:19 +0000] "GET / HTTP/1.1" 404 548 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36" 444 0.001 [upstream-default-backend] [] 127.0.0.1:8181 548 0.000 404 0fa63d31eee2d30a43ec3e4a810692e2
192.168.99.1 - - [28/Sep/2021:13:07:19 +0000] "GET /favicon.ico HTTP/1.1" 404 548 "http://dev.backend.minikube.local/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36" 399 0.000 [upstream-default-backend] [] 127.0.0.1:8181 548 0.000 404 7578f34eb36a0624571b59ace7874748
192.168.99.1 - - [28/Sep/2021:13:27:37 +0000] "HEAD / HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36 Edg/94.0.992.31" 287 0.001 [upstream-default-backend] [] 127.0.0.1:8181 0 0.001 404 de62ff190e82ba05a6614dd727f1170a
192.168.99.1 - - [28/Sep/2021:13:27:40 +0000] "GET / HTTP/1.1" 404 548 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36 Edg/94.0.992.31" 458 0.001 [upstream-default-backend] [] 127.0.0.1:8181 548 0.001 404 a4ebeb4dfadea97778a6394e218e99b0
192.168.99.1 - - [28/Sep/2021:13:27:40 +0000] "GET /favicon.ico HTTP/1.1" 404 548 "http://dev.frontend.minikube.local/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36 Edg/94.0.992.31" 414 0.001 [upstream-default-backend] [] 127.0.0.1:8181 548 0.000 404 e39c1bbc38591ec1e33ba0ca074e8127
I0928 13:32:41.441620       8 main.go:101] "successfully validated configuration, accepting" ingress="dev-guestbook-ingress/default"
I0928 13:32:41.445673       8 store.go:399] "removing ingress because of unknown ingressclass" ingress="default/dev-guestbook-ingress"
I0928 13:32:41.445785       8 controller.go:150] "Configuration changes detected, backend reload required"
I0928 13:32:41.565590       8 controller.go:167] "Backend successfully reloaded"
I0928 13:32:41.566233       8 event.go:282] Event(v1.ObjectReference{Kind:"Pod", Namespace:"ingress-nginx", Name:"ingress-nginx-controller-69bdbc4d57-jnswj", UID:"84ad1680-72e1-4733-a1e7-9c314527d810", APIVersion:"v1", ResourceVersion:"2634", FieldPath:""}): type: 'Normal' reason: 'RELOAD' NGINX reload triggered due to a change in configuration

我的kubernetes版本是-

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.4", GitCommit:"3cce4a82b44f032d0cd1a1790e6d2f5a55d20aae", GitTreeState:"clean", BuildDate:"2021-08-11T18:16:05Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:32:41Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}

我的minikube版本是-

minikube version: v1.23.0
commit: 5931455374810b1bbeb222a9713ae2c756daee10

我确实在etc/hosts中添加了带有host的minikube ip,所以问题不存在

尝试添加下面来修复默认后端错误,看看是否解决了问题。此外,检查您的入口IP是否值得。

spec:
defaultBackend:
service:
name: {{ $.Release.Name}}-{{ .host.chart }}
port:
number: 80

相关内容

  • 没有找到相关文章

最新更新