错误:找不到终结点“Default-http-Backend”

9fkzdhlc  于 2022-10-06  发布在  Kubernetes
关注(0)|答案(1)|浏览(514)

环境:-

(Kubernetes+Nginx-入口控制器+HAProxy+Jenkins)

我已经在裸机Ubuntu-18.04服务器上设置了Kubernetes cluster v1.19.16,目前我想通过http://jenkins.company.com连接集群Jenkins服务。HaProxy服务器端前端和后端已配置。

我的jenkins-service.yaml文件内容如下:

apiVersion: v1
kind: Service
metadata:
  name: jenkins-svc
  namespace: jenkins
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/path:   /
      prometheus.io/port:   '8080'
spec:
  selector: 
    app: jenkins-server
  type: ClusterIP
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 80

jenkins-ingress-resource.yaml文件内容如下,

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: jenkins-ingress
  namespace: jenkins
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: "jenkins.company.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          serviceName: jenkins-svc
          servicePort: 8080

# kubectl get service -n jenkins

NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
jenkins-svc   ClusterIP   10.96.136.255   <none>        8080/TCP   20m

# kubectl get ing jenkins-ingress

Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
NAME              CLASS    HOSTS                ADDRESS   PORTS   AGE
jenkins-ingress   <none>   jenkins.company.com            80      5h42m

# kubectl describe ingress  -n jenkins

Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Name:             jenkins-ingress
Namespace:        jenkins
Address:
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host             Path  Backends
  ----             ----  --------
  jenkins.dpi.com
                   /   jenkins-svc:8080 (10.244.0.16:80)
Annotations:       ingress.kubernetes.io/rewrite-target: /
                   kubernetes.io/ingress.class: nginx
Events:            <none>

当我尝试访问http://jenkins.company.com时,它在浏览器上显示以下错误消息。

请让我知道我错过了什么?

flvlnr44

flvlnr441#

service portcontainer port的问题。Jenkins默认端口是8080,所以我假设您的服务端口是80

ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

入口应该是

spec:
  rules:
  - host: "jenkins.company.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          serviceName: jenkins-svc
          servicePort: 80

port:此服务的端口targetPort要将流量转发到的Pod上的目标端口

Difference between targetPort and port in Kubernetes Service definition

相关问题