TL;DR:设置与部署名称相同的服务,入口端口都匹配,仍在获取:
error: endpoints "default-http-backend" not found
这是服务yaml:
apiVersion: v1
kind: Service
metadata:
name: sonarr
namespace: media
spec:
selector:
app: sonarr
ports:
- protocol: TCP
port: 8989
targetPort: 80
kubectl应用-f svc.yaml结果
kubectl describe svc sonarr -n media
Name: sonarr
Namespace: media
Labels: <none>
Annotations: <none>
Selector: app=sonarr
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.184.97
IPs: 10.43.184.97
Port: <unset> 8989/TCP
TargetPort: 80/TCP
Endpoints: 10.42.1.10:80
Session Affinity: None
Events: <none>
部署Yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sonarr
namespace: media
spec:
selector:
matchLabels:
app: sonarr
template:
metadata:
labels:
app: sonarr
spec:
containers:
- name: sonarr
image: ghcr.io/linuxserver/sonarr:arm32v7-latest
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 8989
部署结果
kubectl get deployments -n media
NAME READY UP-TO-DATE AVAILABLE AGE
sonarr 1/1 1 1 37m
入口yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: sonarr-ingress
namespace: media
labels:
name: sonarr-ingress
spec:
rules:
- host: sonarr.smrtrock.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: sonarr
port:
number: 8989
入口描述
kubectl describe ing sonarr -n media
Name: sonarr
Namespace: media
Address:
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
sonarr.smrtrock.com
/ sonarr:8989 (10.42.1.10:80)
Annotations: <none>
Events: <none>
不确定我错过了什么,这对K8来说是个全新的东西。
这是意料之中的事。默认的http后端是所有请求所在的位置,如果它们与任何入口规则都不匹配。很可能没有这种追索权在您的nginx安装中,针对您的确切版本使用yamls。
没有规则的入口将所有流量发送到一个默认值后端。defaultBackend通常是一个配置选项的Ingress控制器,并且没有在您的Ingress中指定资源。
如果没有主机或路径与Ingress中的HTTP请求匹配对象,则流量将路由到您的默认后端。
检查一下可能很有趣:
-
默认后端-GKE 上的404
-
在Ingress资源中找不到端点"默认http后端">