Configure a custom Spring Cloud Gateway Trait

The api-gateway.spring.tanzu.vmware.com Trait provides a Spring Cloud Gateway resource to enable application HTTP traffic routing by default. The resource is backed by the latest Spring Cloud Gateway for Kubernetes. For more information, see Spring Cloud Gateway for Kubernetes.

By default, api-gateway.spring.tanzu.vmware.com does not add any requirement to the workloads in the namespace. However, you can add the following configurations:

  • Dynamic application route configuration, activating API route updates for continuous integration (CI) and continuous delivery (CD) pipelines.
  • Gateway-defined Single Sign-On (SSO) configuration combined with commercial SSO route filters.
  • Configurable API route response cache that can be integrated with distributed cache components such as Redis.
  • Commercial API route filters for SSO authentication, role-based access control, scopes authorization, authorized token relay, client certificate authorization, rate limiting, circuit breaker, GraphQL, and much more.
  • Monitoring of API gateway metrics for error rates, performance, SSO, rate limiting, circuit breaker status, and more can be captured using Prometheus or Tanzu Observability for Wavefront.
  • HTTP/2 and gRPC API support, including support for JSON request to gRPC call translation.

Before you begin

VMware Tanzu provides the spring-dev.tanzu.vmware.com and spring-prod.tanzu.vmware.com Profiles that use the api-gateway.spring.tanzu.vmware.com Trait. However, the Profiles have minimal configurations. To take full advantage of the api-gateway.spring.tanzu.vmware.com Trait, you will have to create a custom Profile.

For information about the configurable properties in the Spring Gateway Trait, see Spring Gateway Trait configurable properties.

Create a custom Profile for the Spring Cloud Gateway Trait

The following provides the steps for creating a custom Profile that uses the Spring Cloud Gateway Trait.

UI-based steps
Do the following on the Tanzu Hub console:
  1. On Tanzu Platform hub, set the project context to your project.
  2. On the left navigation pane, expand Application Spaces.
  3. Click Profiles.
  4. Click Create Profile > Step by Step.
  5. For Profile Name, enter my-custom-gateway and click Next.
  6. For Traits, select the check box for api-gateway.spring.tanzu.vmware.com.

    When you select a trait, the configuration for the trait displays below the grid table.

  7. Expand Configure api-gateway.spring.tanzu.vmware.com.
  8. Update the configuration as needed.

    For example, you can customize the count and resources values.

    • Set count as 3.
    • Set Resources Requests Memory as 1024Mi.
    • Set Resources Requests Cpu as 1000m.
  9. Click Next.

  10. In Additional Required Capabilities, the Capabilities required by the Traits you selected are selected by default, so you can click Next.
  11. Review the information the Summary information.
  12. Click Create.
Tanzu CLI-based steps
Use Tanzu CLI commands to install packages in the Cluster Group.
  1. Use the Tanzu CLI to ensure that your project context is set correctly.

    tanzu project use PROJECT-NAME
    
  2. Create a my-custom-gateway.yaml file with the following contents.

    ---
    apiVersion: spaces.tanzu.vmware.com/v1alpha1
    kind: Profile
    metadata:
     name: my-custom-gateway
    spec:
     requiredCapabilities:
     - name: spring-cloud-gateway.tanzu.vmware.com
     traits:
     - name: api-gateway.spring.tanzu.vmware.com
       values:
         inline:
           gateway:
             count: 3
             resources:
               requests:
                 cpu: 1000m
                 memory: 1024Mi
    
  3. Run the following command to create the profile.

    tanzu deploy --only my-custom-gateway.yaml
    
  4. Type y to confirm. The following message will appear confirming the creation.

    ✓ Successfully created profile my-custom-gateway
    

You will see the newly created Profile, my-custom-gateway, on Tanzu Platform hub in Application Spaces > Profiles.

After you have created the custom Profile, you can apply the profile to a Space by following the steps in Create a Space. Make sure to add my-custom-gateway to the Profiles you select for the Space.

check-circle-line exclamation-circle-line close-line
Scroll to top icon