google-kubernetes-enginekubernetes-ingressgoogle-cloud-cdn

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


Is it possible to setup cloud CDN storageBucket as ingress backend in 1.21.5-gke.1302? I was trying :

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

But getting:

[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]

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


Solution

  • According to documentation:

    if you are using GKE version 1.16-gke. 3 or later, you should use the cloud.google.com/backend-config annotation, even though the beta.cloud.google.com/backend-config annotation will also work.

    For GKE versions 1.16.8-gke.3 and higher, it's recommend you use the cloud.google.com/v1 API version. If you are using an earlier GKE version, use cloud.google.com/v1beta1.

    I think that this PR contains the change you're looking for.

    `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
    

    Refer to the GitHub issue and Stackexchange post for more detailed information.