See below for steps to get started using Spring Cloud Gateway for VMware Tanzu. The examples below use Spring Cloud Gateway for VMware Tanzu to quickly create an API gateway.
To use single sign-on, you must install the Single Sign-On for VMware Tanzu tile and create a Single Sign-On for VMware Tanzu service plan that is available to the p-spring-cloud-gateway-service
org.
For more information about using Single Sign-On for VMware Tanzu with Spring Cloud Gateway for VMware Tanzu, see Using Single Sign-On.
Create a new Spring Cloud Gateway for VMware Tanzu service instance, using the -c
flag to pass the Single Sign-On for VMware Tanzu plan to use (via the sso.plan
parameter) and the host to use (via the host
parameter). In the following example, the service instance is named my-gateway
, the Single Sign-On for VMware Tanzu plan is named my-sso-plan
, and the host for the service instance is my-gateway
:
$ cf create-service p.gateway standard my-gateway -c '{"sso": { "plan": "my-sso-plan" }, "host": "my-gateway"}'
You can also specify the domain to use for the service instance, using the domain
parameter. Omitting the domain
parameter, as in this example, will create the service instance's route using the specified host
and the default external domain for the platform.
For more information about creating and managing service instances, see Managing Service Instances.
Given an existing microservice app myservice
, bind the my-gateway
service instance to the myservice
app, using the -c
flag to include route configuration for the app:
$ cf bind-service myservice my-gateway -c '{"routes": [{"path": "/myservice/**", "sso-enabled": true}]}'
In this example, the app is bound and the Gateway service instance adds a route for the myservice
app. The route uses the path /myservice/**
for the myservice
app and uses SSO (provided by the my-sso-plan
service plan of the Single Sign-On for VMware Tanzu tile).
For more information about configuring routes for service apps on a Gateway service instance, see Configuring Routes.
In a browser, access an endpoint on the myservice
app, using the path provided for the app's route in the Gateway service instance. The path consists of:
In this example, the Gateway service instance uses the host my-gateway
(the name of the service instance) and the PAS default external domain, and the Gateway service instance's route for the myservice
app uses the path /myservice/**
. To access the myservice
app's customers
endpoint in this example, you would visit:
https://my-gateway.[DEFAULT_DOMAIN]/myservice/customers
where [DEFAULT_DOMAIN]
is the PAS default external domain.
If you have configured a custom host (for example, my-custom-host
) for the service instance, you might access the customers
endpoint by visiting:
https://my-custom-host.[DEFAULT_DOMAIN]/myservice/customers
If you have configured a custom domain (for example, example.com
) for the service instance, you might access the endpoint by visiting:
https://my-gateway.example.com/myservice/customers
For information about configuring a Gateway service instance's host and domain, see the Host and Domain or Base URLs sections of Managing Service Instances.
To find the dashboard for the Gateway service instance, you can use the cf service
command:
$ cf service my-gateway
Showing info of service my-gateway in org myorg / space dev as user...
name: my-gateway
service: p.gateway
tags:
plan: standard
description: Spring Cloud Gateway for VMware Tanzu
documentation:
dashboard: https://gateway-07157e2a-c89f-4bfa-bc1b-dc781563c9b6.apps.example.com/dashboard
service broker: scg-service-broker
...
Visit the URL given for dashboard
.
For more information about the Gateway dashboard, see Using the Dashboard.