gpt4 book ai didi

Kubernetes Ingress - 服务路由的入口不起作用

转载 作者:行者123 更新时间:2023-12-02 11:35:57 26 4
gpt4 key购买 nike

我有一个像下面这样的入口。

kubectl get ing test-ingress -o yaml


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.class":"tectonic"},"name":"test-ingress","namespace":"nstest"},"spec":{"rules":[{"host":"test.nstest.k8s.privatecloud.com","http":{"paths":[{"backend":{"serviceName":"test","servicePort":8080},"path":"/"}]}}]}}
kubernetes.io/ingress.class: tectonic
creationTimestamp: 2018-03-27T17:57:02Z
generation: 1
name: test-ingress
namespace: "nstest"
resourceVersion: "19985087"
selfLink: /apis/extensions/v1beta1/namespaces/nstest/ingresses/test-ingress
uid: 4100bd04-31e8-11e8-8f7b-5cb9018ebebc
spec:
rules:
- host: test.nstest.k8s.privatecloud.com
http:
paths:
- backend:
serviceName: test
servicePort: 8080
path: /
status:
loadBalancer: {}

我的服务如下,

kubectl get svc test -o yaml


apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"test"},"name":"test","namespace":"nstest"},"spec":{"ports":[{"port":8080,"protocol":"TCP","targetPort":8080}],"selector":{"app":"test"}}}
creationTimestamp: 2018-03-27T17:57:02Z
labels:
app: test
name: test
namespace: "nstest"
resourceVersion: "19985067"
selfLink: /api/v1/namespaces/nstest/services/test
uid: 40f975f3-31e8-11e8-8f7b-5cb9018ebebc
spec:
clusterIP: 172.158.50.20
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: test
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}

pod 运行良好。这有什么问题?为什么从入口到服务的路由不起作用。

访问入口端点时出错,

Ingress Error
No healthy backends could be found.
Check pod liveness probes for more details.


谢谢,

最佳答案

你应该在你的服务规范中给端口一个“名称”,并在你的 Ingress 中引用它:

---
apiVersion: v1
kind: Service
metadata:
name: myApp
spec:
selector:
app: myApp
ports:
- name: http
port: 80
targetPort: 80

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myApp
spec:
rules:
- host: myapp.domain.com
http:
paths:
- path: /
backend:
serviceName: myApp
servicePort: http

关于Kubernetes Ingress - 服务路由的入口不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49519965/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com