Kubernetes 入口控制器中的错误"没有与这些值匹配的路由"



我成功部署了一个kubernetes服务。最重要的是,我创建了一个k8s入口控制器,它映射到端口80上部署的服务,路径只有前斜杠(/(。例如,ingress的主机名是kubernetes-app.local,url是http://kubernetes-app.local:80或http://kubernetes-app.local.然而,突然两天后,我无法获得相同网址的成功回复。入口和服务没有任何变化,我也可以看到入口和服务正在成功运行。不确定发生了什么,突然我开始犯错误,称";没有与那些值匹配的路由";。我重新部署了应用程序,但仍然面临同样的问题。问题任何线索都会有所帮助。

以下信息供您参考

$kubectl版本

Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.4", GitCommit:"SOME_STRING", GitTreeState:"clean", BuildDate:"2021-11-17T15:48:33Z", GoVersion:"go1.16.10", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5+k3s2", GitCommit:"SOME_STRING", GitTreeState:"clean", BuildDate:"2021-10-05T19:59:14Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}

service.yaml

apiVersion: v1
kind: Service # Specify the type of manifest this is.  In this case a service, which is used to allow network access to pods.
metadata:
labels:
app: kubernetes-app-service
name: kubernetes-app-service
namespace: my-app-plus # Specify the name of the namespace to run this object under.
spec:
type: ClusterIP # Type of Service.  Options are ClusterIP or NodePort
clusterIP: None  # Specify an IP for the service.  None means K8S will auto assign an IP.
selector:
app: kubernetes-app-pod # Traffic to this service will be routed to pod(s) with this label.
sessionAffinity: None
ports:
- name: default
port: 80 # Port the service will be listening on
protocol: TCP
targetPort: 80 # Port that pod(s) will be listening on

部署人员

apiVersion: apps/v1
kind: Deployment  # Specify the type of manifest this is.  In this case a deployment, which is used to get and keep pods running.
metadata:
labels:
app: kubernetes-app
name: kubernetes-app
namespace: my-app-plus  # Specify the name of the namespace to run this object under.
spec:
replicas: 1 # Specify how many copies of the pods we want running.
selector:
matchLabels:
app: kubernetes-app-pod  # Pods matching this label are part of this deployment
strategy:  # Specify the rules for updating or replacing pods.
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:  # Here is where we will define the pods that the deployment will use.
metadata:
labels:
app: kubernetes-app-pod  # Set the label of the pod.  This is what the deployment selector up above is referencing. Services will also reference this.
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "kubernetes-app"
dapr.io/app-port: "80"
dapr.io/config: "tracing"
spec:      
containers:  # Specify how the container(s) in this pod are created. 
- name: kubernetes-app          
image: ghcr.io/myuseridORorgName/app:1.1.0 # Docker image to create the container from.
imagePullPolicy: Always
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "1000Mi"
cpu: "1000m"
volumeMounts:
- name: kubernetes-app-git-volume
mountPath: /root/.gitconfig  # Creating the .gitconfig from the configmap we created earlier
subPath: .gitconfig
env:
- name: dev
value: "true"
envFrom:
- configMapRef:
name: kubernetes-app-configmap
- secretRef:
name: kubernetes-app-secret
imagePullSecrets:
- name: mysecrethub        
volumes:
- name: kubernetes-app-git-volume
configMap:
name: gitconfig

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubernetes-app-ingress
namespace: my-app-plus # Specify the name of the namespace to run this object under.
spec:
rules:
- host: kubernetes-app.local  # Traffic arriving at the load balancer to this Domain Name will get routed according to this ingress spec.
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kubernetes-app-service # Traffic will be sent to a service with this label.
port:
number: 80  # Port on the service to route traffic to.

问题是由于其他入侵使用了相同的端口(80(。只需运行以下命令,它将向您显示具有相同端口和ip 的其他入口

$kubectl获取入口

ingress-1  IP-1 80
ingress-2  IP-1 80
ingress-3  IP-1 80

所以我只是删除了我们不使用的ingress-2和3,它起了作用。如果这对你不起作用,只需从你的命名空间中删除所有内容以及所有入口,并重新部署你的应用程序,它肯定会起作用。

相关内容

  • 没有找到相关文章

最新更新