假设我们有许多在 k8s 上运行的微服务,其部署、服务和入口可通过 api.localhost 上的 kong 入口网关访问。
每个微服务都在特定路径上运行,例如
api.localhost/foo
对于 foo 微服务api.localhost/bar
用于酒吧微服务
如何使用带有 Kong 网络层的 Knative 来实现这一点?像这样的东西不起作用:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: foo-api
labels:
networking.knative.dev/visibility: cluster-local
spec:
template:
spec:
containers:
- image: foo-image
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: kong
konghq.com/strip-path: "true"
ingress.kubernetes.io/service-upstream: "true"
name: foo
spec:
rules:
- host: api.localhost
http:
paths:
- backend:
service:
name: foo-api
port:
number: 80
path: /foo
pathType: ImplementationSpecific
https://github.com/Kong/kubernetes-ingress-controller/issues/584 https://knative.dev/docs/serving/samples/knative-routing-go/