To add API routes to a Spring Cloud Gateway for Kubernetes instance, you must create a resource of type SpringCloudGateway and SpringCloudGatewayMapping.

Resource specification

To add API routes to a Spring Cloud Gateway for Kubernetes instance, you must create a resource of type SpringCloudGatewayMapping which references both a SpringCloudGateway and a SpringCloudGatewayRouteConfig resource. The definition for SpringCloudGatewayMapping specifies:

apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGatewayMapping
metadata:
  name:            # (Required) Name given to this route mapping
spec:
  gatewayRef:      # Gateway instance which will serve traffic using the referenced route config
    name:          # Name of the Gateway instance
    namespace:     # (Optional) If not set will use the Mapping's namespace
  routeConfigRef:  # Route configuration containing the routes to apply to the referenced gateway instance
    name:          # Name of the route configuration resource
    namespace:     # (Optional) If not set will use the Mapping's namespace

See the Getting Started guide for examples of how to populate these fields.

Example

In the example below, we define a SpringCloudGatewayMapping myapp-mapping, that maps the SpringCloudGatewayRouteConfig myapp-route-config to the SpringCloudGateway my-gateway:

apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGatewayMapping
metadata:
  name: myapp-mapping
spec:
  gatewayRef:
    name: my-gateway
    namespace: my-gateway-ns
  routeConfigRef:
    name: myapp-route-config
check-circle-line exclamation-circle-line close-line
Scroll to top icon