1

下面是我的 knative 服务示例

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: test-svc
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/minScale: "1"
    spec:
      serviceAccountName: default
      containers:
      - image: ******************
        imagePullPolicy: IfNotPresent
        name: test-svc
        envFrom:
        - secretRef:
           name: test-env

kubectl get ksvc

NAME       URL                                   LATESTCREATED    LATESTREADY      READY     REASON
test-svc   http://test-svc.kube-system.kasl.io   test-svc-8v6gv   test-svc-8v6gv   True

网关+虚拟服务

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: httpbin-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
  - "*"
  gateways:
  - httpbin-gateway
  http:
  - match:
    - uri:
        prefix: /headers
    route:
    - destination:
        host: istio-ingressgateway.istio-system.svc.cluster.local

如果我在集群内执行curl -v http://test-svc.kube-system.kasl.io它工作得很好下面是我的 knative 服务示例

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: test-svc
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/minScale: "1"
    spec:
      serviceAccountName: default
      containers:
      - image: ******************
        imagePullPolicy: IfNotPresent
        name: test-svc
        envFrom:
        - secretRef:
           name: test-env

kubectl get ksvc

NAME       URL                                   LATESTCREATED    LATESTREADY      READY     REASON
test-svc   http://test-svc.kube-system.kasl.io   test-svc-8v6gv   test-svc-8v6gv   True

网关+虚拟服务

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: httpbin-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin
spec:
  hosts:
  - "*"
  gateways:
  - httpbin-gateway
  http:
  - match:
    - uri:
        prefix: /headers
    route:
    - destination:
        host: istio-ingressgateway.istio-system.svc.cluster.local

如果我在集群内执行curl -v http://test-svc.kube-system.kasl.io它的工作

现在我想将这些服务公开给外部集群

4

1 回答 1

0

Knative 使用共享入口网关来服务 Knative 服务网格内的所有传入流量,它是 knative-serving 命名空间下的 knative-ingress-gateway 网关。默认情况下,它使用 istio-system 命名空间下的 Istio 网关服务 istio-ingressgateway 作为其底层服务。您可以将服务替换为您自己的服务,如下所示[1],更详细的步骤请参阅链接[2]。

[1] https://knative.dev/docs/serving/setting-up-custom-ingress-gateway/ [2] https://starkandwayne.com/blog/public-traffic-into-knative-on-gke/

于 2019-11-20T20:49:52.820 回答