kubernetes 使用Knative自动创建Ingress资源

k2fxgqgv  于 2023-04-29  发布在  Kubernetes
关注(0)|答案(1)|浏览(116)

是否可以让Knative自动创建K8s Ingress资源?

大家好,根据documentation的下面几行,我想知道我是否可以让Knative自动为我的服务创建Ingress资源?我在文档中没有找到关于这方面的细节。

After the service has been created, Knative performs the following tasks:

- Creates a new immutable revision for this version of the app.
- Performs network programming to create a route, ingress, service, and load balancer for your app.
- Automatically scales your pods up and down based on traffic, including to zero active pods.

示例:以下面的Service和Ingress定义为例,是否可以抽象出Ingress yaml,并让knative自动为服务创建它?

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: hello
  namespace: knative
spec:
  template:
    metadata:
      labels:
        app: nonprofit
      annotations:
        queue.sidecar.serving.knative.dev/resourcePercentage: "10"
        autoscaling.knative.dev/class: "kpa.autoscaling.knative.dev"
        autoscaling.knative.dev/target: "40"
        autoscaling.knative.dev/min-scale: "1"
        autoscaling.knative.dev/max-scale: "3"
    spec:
      containers:
        - image: gcr.io/knative-samples/helloworld-java
          resources:
            requests:
              cpu: 50m
              memory: 100M
            limits:
              cpu: 200m
              memory: 200M
          ports:
            - containerPort: 8080
          env:
            - name: TARGET
              value: "Sunny Day"
  traffic:
  - tag: latest
    latestRevision: true
    percent: 100
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: knative-hello-ingress
  namespace: knative
  annotations:
    nginx.ingress.kubernetes.io/upstream-vhost: "hello.knative"
spec:
  ingressClassName: "ingress-generic"
  rules:
  - host: "hello-knative.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: hello
            port:
              number: 80

谢谢大家
没有尝试过任何东西,因为我没有在文档中找到有关此的详细信息。

hiz5n14c

hiz5n14c1#

不幸的是,Kubernetes中的v1 Ingress API没有足够的能力来表达Knative的路由要求。Knative * 确实 * 支持几个ingress实现(包括Istio,Contour和Gateway API),但没有人为Nginx Ingress注解编写插件。
Kubernetes Ingress API中缺少的一些Knative所需的功能包括:

  • 后端流量拆分/权重
  • 设置后端服务器的请求头
  • 请求HTTP/2或websockets协议支持

如果你愿意使用bets软件,Gateway API插件的大部分功能都是完整的,应该插入variety of ingress providers。不幸的是,Nginx似乎不在这个名单上。

相关问题