有没有办法将 Cloud CDN(后端存储桶)与 "GKE ingress" 一起使用?

Is there a way to use Cloud CDN(backend bucket) with "GKE ingress"?

是否可以在 1.21.5-gke.1302 中将云 CDN storageBucket 设置为入口后端? 我在尝试 :

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  namespace: test-namespace
  annotations:
    kubernetes.io/ingress.global-static-ip-name: >
      test-gke-ingress,
      test-backendconfig
    kubernetes.io/ingress.allow-http: "false"
    networking.gke.io/managed-certificates: "test-ssl,"
spec:
  rules:
- host: test.example.com
  http:
    paths:
    - path: /*
      backend:
        serviceName: test-cdn-service
        servicePort: 80
    - path: /test
      backend:
        resource:
              kind: StorageBucket
              name: test-bucket

但是得到:

[ValidationError(Ingress.spec.rules[7].http.paths[1].backend): unknown field "kind" in io.k8s.api.networking.v1beta1.IngressBackend, ValidationError(Ingress.spec.rules[7].http.paths[1].backend): unknown field "name" in io.k8s.api.networking.v1beta1.IngressBackend]

有没有办法将 Cloud CDN(后端存储桶)与“GKE ingress”一起使用?

根据documentation

如果您使用的是 GKE 版本 1.16-gke。 3 或更高版本,您应该使用 cloud.google.com/backend-config 注释,即使 beta.cloud.google.com/backend-config 注释也可以。

GKE 1.16.8-gke.3及以上版本,推荐使用cloud.google.com/v1 API版本.如果您使用的是较早的 GKE 版本,请使用 cloud.google.com/v1beta1.

我认为这个 PR 包含您正在寻找的更改。

`Ingress` and `IngressClass` resources have graduated to `networking.k8s.io/v1`. Ingress and IngressClass types in the `extensions/v1beta1` and `networking.k8s.io/v1beta1` API versions are deprecated and will no longer be served in 1.22+. Persisted objects can be accessed via the `networking.k8s.io/v1` API. Notable changes in v1 Ingress objects (v1beta1 field names are unchanged):
* `spec.backend` -> `spec.defaultBackend`
* `serviceName` -> `service.name`
* `servicePort` -> `service.port.name` (for string values)
* `servicePort` -> `service.port.number` (for numeric values)
* `pathType` no longer has a default value in v1; "Exact", "Prefix", or "ImplementationSpecific" must be specified
Other Ingress API updates:
* backends can now be resource or service backends
* `path` is no longer required to be a valid regular expression

请参阅 GitHub issue and Stackexchange 了解更多详细信息。