You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article shows you how to migrate Spring Cloud Gateway for VMWare Tanzu in Azure Spring Apps Enterprise plan to self-hosted Open Source (OSS) Spring Cloud Gateway running as an Azure Container Apps application.
18
+
This article shows you how to migrate a Spring Cloud Gateway for VMWare Tanzu project running on an Azure Spring Apps Enterprise plan to a project running as a self-hosted Open Source (OSS) Spring Cloud Gateway running as an Azure Container Apps application.
19
19
20
20
The OSS version of Spring Cloud Gateway mentioned in this page is provided as an example for reference. Users can choose other distributions of Spring Cloud Gateway based on their requirements.
21
21
22
-
Note that the features offered by Spring Cloud Gateway for VMWare Tanzu are more extensive than those in the OSS version, so it is essential to verify the differences and ensure compatibility before moving to production.
22
+
> [!NOTE]
23
+
> The features offered by Spring Cloud Gateway for VMWare Tanzu are more extensive than the features in the OSS version, so it's essential to verify the differences and ensure compatibility before moving to production.
23
24
24
25
## Prerequisites
25
26
@@ -28,79 +29,87 @@ Note that the features offered by Spring Cloud Gateway for VMWare Tanzu are more
28
29
-[Azure CLI](/cli/azure/install-azure-cli)
29
30
- An Azure container registry with sufficient permissions to build and push Docker images. For more information, see [Create a container registry](/azure/container-registry/container-registry-get-started-azure-cli#create-a-container-registry).
30
31
31
-
## Prepare the code of self-hosted Spring Cloud Gateway application
32
+
## Prepare the code of the self-hosted Spring Cloud Gateway application
32
33
33
-
To get the code of the Spring Cloud Gateway:
34
+
To get the code of the Spring Cloud Gateway application, use the following steps:
34
35
35
36
1. Navigate to https://start.spring.io.
36
-
1. Update the project metadata by setting the **Group** to your orgnization's name. Change the **Artifact** and **Name** to **gateway**.
37
+
1. Update the project metadata by setting the **Group** to your organization's name. Change the **Artifact** and **Name** to **gateway**.
37
38
1. Add dependencies **Reactive Gateway** and **Spring Boot Actuator**.
38
39
1. Leave the other properties at their default values.
39
40
1. Click **Generate** to download the project.
40
-
41
-
Extract the project when it's downloaded.
41
+
1. Extract the project when it's downloaded.
42
42
43
43
## Configure the Spring Cloud Gateway
44
44
45
-
Once the Spring Cloud Gateway code is ready, navigate to the **gateway/src/main/resources** directory of the project. Rename the **application.properties** file with **application.yml**. You can migrate from Spring Cloud Gateway for VMWare Tanzu by configuring the **application.yml**.
46
-
47
-
The example of **application.yml** is like:
48
-
49
-
```yaml
50
-
spring:
51
-
application:
52
-
name: gateway
53
-
cloud:
54
-
gateway:
55
-
globalcors:
56
-
corsConfigurations:
57
-
'[/**]':
58
-
allowedOriginPatterns: "*"
59
-
allowedMethods:
60
-
- GET
61
-
- POST
62
-
- PUT
63
-
- DELETE
64
-
allowedHeaders:
65
-
- "*"
66
-
allowCredentials: true
67
-
maxAge: 3600
68
-
routes:
69
-
- id: front
70
-
uri: http://front-app
71
-
predicates:
72
-
- Path=/**
73
-
- Method=GET
74
-
order: 1000
75
-
filters:
76
-
- StripPrefix=0
77
-
tags:
78
-
- front
79
-
```
45
+
Now that the Spring Cloud Gateway code is ready, you configure it in the next sections.
46
+
47
+
### Configure the application properties file
48
+
49
+
To configure the application properties file, use the following steps:
50
+
51
+
1. Navigate to the **gateway/src/main/resources** directory of the project.
52
+
53
+
1. Rename the **application.properties** file to **application.yml**.
54
+
55
+
1. Edit the **application.yml**. The following **application.yml** file is typical:
56
+
57
+
```yaml
58
+
spring:
59
+
application:
60
+
name: gateway
61
+
cloud:
62
+
gateway:
63
+
globalcors:
64
+
corsConfigurations:
65
+
'[/**]':
66
+
allowedOriginPatterns: "*"
67
+
allowedMethods:
68
+
- GET
69
+
- POST
70
+
- PUT
71
+
- DELETE
72
+
allowedHeaders:
73
+
- "*"
74
+
allowCredentials: true
75
+
maxAge: 3600
76
+
routes:
77
+
- id: front
78
+
uri: http://front-app
79
+
predicates:
80
+
- Path=/**
81
+
- Method=GET
82
+
order: 1000
83
+
filters:
84
+
- StripPrefix=0
85
+
tags:
86
+
- front
87
+
```
80
88
81
89
### CORS configuration
82
90
83
-
To migrate the Cross-Origin Resource Sharing (CORS) configuration of Spring Cloud Gateway for VMWare Tanzu, you can refer to [CORS Configuration for Spring Cloud Gateway](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#cors-configuration) for global CORS configuration and route CORS configuration.
91
+
To migrate the Cross-Origin Resource Sharing (CORS) configuration of your Spring Cloud Gateway for VMWare Tanzu project, see [CORS Configuration for Spring Cloud Gateway](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#cors-configuration) for global CORS configuration and route CORS configuration.
84
92
85
93
### Scale
86
94
87
-
When migrating to Spring Cloud Gateway application in Azure Container Apps, the scaling behavior should align with Azure Container Apps' model. The instance count from Spring Cloud Gateway for VMWare Tanzu maps to `min-replica` and `max-replica` in Azure Container Apps. You can configure automatic scaling for the gateway application by defining scaling rules. For more details, refer to [Set scaling rules in Azure Container Apps](/azure/container-apps/scale-app).
95
+
When migrating to a Spring Cloud Gateway application in Azure Container Apps, the scaling behavior should align with the Azure Container Apps model. The instance count from Spring Cloud Gateway for VMWare Tanzu maps to `min-replica` and `max-replica` in Azure Container Apps. You can configure automatic scaling for the gateway application by defining scaling rules. For more information, see [Set scaling rules in Azure Container Apps](/azure/container-apps/scale-app).
88
96
89
-
The CPU and memory combinations available in Azure Spring Apps differs from those in Azure Container Apps. When mapping resource allocations, ensure that the selected CPU and memory configurations in Azure Container Apps fit both performance needs and supported options.
97
+
The CPU and memory combinations available in Azure Spring Apps differ from those in Azure Container Apps. When mapping resource allocations, ensure that the selected CPU and memory configurations in Azure Container Apps fit both your performance needs and the supported options.
90
98
91
-
### Custom domain & certificates
99
+
### Custom domains & certificates
92
100
93
-
Azure Container Apps supports custom domains and certificates, you can refer to [Domains & certificates](/azure/container-apps/certificates-overview) to migrate custom domains configured on Spring Cloud Gateway for VMWare Tanzu.
101
+
Azure Container Apps supports custom domains and certificates. For more information on migrating custom domains configured on Spring Cloud Gateway for VMWare Tanzu, see [Certificates in Azure Container Apps](/azure/container-apps/certificates-overview).
94
102
95
103
### Routes
96
104
97
-
You can migrate the routes in Spring Cloud Gatewy for Tanzu to Spring Cloud Gateway as the example of **application.yml** shows. The following list describes the mapping relationship between routes of Spring Cloud Gateway for VMWare Tanzu and routes of Spring Cloud Gateway:
105
+
You can migrate the routes in Spring Cloud Gatewy for Tanzu to Spring Cloud Gateway, as the **application.yml** example shows. The following list describes the mapping relationship between the routes of Spring Cloud Gateway for VMWare Tanzu and the routes of Spring Cloud Gateway:
98
106
99
-
- The `name` of the route is mapped to `id`.
100
-
- The `appName` and `protocol` are mapped to the URI of the route, which should be the accessible URI for the Azure Container Apps instance, make sure that the Azure Container Apps applications enable the ingress.
101
-
- Predicates and filters of Spring Cloud Gateway for VMWare Tanzu are mapped to that of Spring Cloud Gateway. Commercial predicates and filters are not supported, refer to [Commercial route filters in Spring Cloud Gateway for K8s](https://techdocs.broadcom.com/us/en/vmware-tanzu/spring/spring-cloud-gateway-for-kubernetes/2-2/scg-k8s/developer-filters.html) for more details.
107
+
- The `name` property of the route is mapped to `id`.
102
108
103
-
For example, consider the following route config JSON file, **test-api.json**, which defines the `test-api` route in Spring Cloud Gateway for VMWare Tanzu for the `test` app:
109
+
- The `appName` and `protocol` properties are mapped to the URI of the route, which should be the accessible URI for the Azure Container Apps instance. Make sure the Azure Container Apps applications enable the ingress.
110
+
- Predicates and filters of Spring Cloud Gateway for VMWare Tanzu are mapped to those of Spring Cloud Gateway. Commercial predicates and filters aren't supported. For more information, see [Commercial route filters in Spring Cloud Gateway for K8s](https://techdocs.broadcom.com/us/en/vmware-tanzu/spring/spring-cloud-gateway-for-kubernetes/2-2/scg-k8s/developer-filters.html).
111
+
112
+
As an example, consider the following route config JSON file, **test-api.json**, which defines the `test-api` route in Spring Cloud Gateway for VMWare Tanzu for the `test` app:
104
113
105
114
```json
106
115
{
@@ -120,7 +129,7 @@ For example, consider the following route config JSON file, **test-api.json**, w
120
129
}
121
130
```
122
131
123
-
Then, the following yaml shows the corresponding route configuration for Spring Cloud Gateway:
132
+
Then, the following YAML file shows the corresponding route configuration for Spring Cloud Gateway:
124
133
125
134
```yaml
126
135
spring:
@@ -139,13 +148,13 @@ spring:
139
148
140
149
Spring Cloud Gateway for VMWare Tanzu sets `StripPrefix=1` by default on every route. To migrate to Spring Cloud Gateway, you need to explicitly set `StripPrefix=1` in the filter configuration.
141
150
142
-
To allow your Spring Cloud Gateway application to access other applications through the app name, you need to enable ingress for your Azure Container App applications. You can also use for the accessible FQDN of Azure Container Apps application as the uri of the route, following the format:`https://<app-name>.<container-app-env-name>.<region>.azurecontainerapps.io`.
151
+
To allow your Spring Cloud Gateway application to access other applications through the app name, you need to enable ingress for your Azure Container App applications. You can also set the accessible FQDN of the Azure Container Apps application to be the URI of the route, following the format `https://<app-name>.<container-app-env-name>.<region>.azurecontainerapps.io`.
143
152
144
153
There are some [commercial predicates](https://docs.vmware.com/en/VMware-Spring-Cloud-Gateway-for-Kubernetes/2.2/scg-k8s/GUID-guides-predicates.html) and [commercial filters](https://docs.vmware.com/en/VMware-Spring-Cloud-Gateway-for-Kubernetes/2.2/scg-k8s/GUID-guides-filters.html) that aren't supported on Spring Cloud Gateway.
145
154
146
155
### Response cache
147
156
148
-
If you enable the response cache globally in Spring Cloud Gateway for VMWare Tanzu, use the following configuration in Spring Cloud Gateway and see [local cache response global filter](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#local-cache-response-global-filter) for more details:
157
+
If you enable the response cache globally in Spring Cloud Gateway for VMWare Tanzu, use the following configuration in Spring Cloud Gateway. For more information, see [The Local Response Cache Filter](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#local-cache-response-global-filter).
149
158
150
159
```yaml
151
160
spring:
@@ -158,7 +167,7 @@ spring:
158
167
size: <response-cache-size>
159
168
```
160
169
161
-
If you enable the response cache for the route, you can use the [`LocalResponseCache`](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#local-cache-response-filter) filter in the routing rule configuration of managed Gateway for Spring as the following YAML:
170
+
If you enable the response cache for the route, you can use the [`LocalResponseCache`](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#local-cache-response-filter) filter in the routing rule configuration of the managed gateway for your Spring project by using the following example:
162
171
163
172
```yaml
164
173
spring:
@@ -175,13 +184,15 @@ spring:
175
184
176
185
### Integrate with APM
177
186
178
-
To enable application performance monitoring (APM) for Spring Cloud Gateway application, refer to [Integrate application performance monitoring into container images](./migrate-to-azure-container-apps-build-application-performance-monitoring.md).
187
+
You can enable application performance monitoring (APM) for Spring Cloud Gateway application. For more information, see [Integrate application performance monitoring into container images](migrate-to-azure-container-apps-build-application-performance-monitoring.md).
188
+
189
+
## Deploy to Azure Container Apps
179
190
180
-
## Deploy to Azure Continer Apps
191
+
After the Spring Cloud Gateway configuration is ready, build the image using Azure Container Registry and deploy it to Azure Container Apps.
181
192
182
-
Once the Spring Cloud Gateway configuration is ready, build the image using Azure Container Registry and deploy it to Azure Container Apps.
193
+
### Build and push the Docker image
183
194
184
-
### Build and Push the Docker Image
195
+
To build and push the Docker image, use the following steps:
185
196
186
197
In the Spring Cloud Gateway project directory, create a **Dockerfile** with the following contents:
Alternatively, you can refer to the sample [Dockerfile](https://github.com/Azure-Samples/acme-fitness-store/blob/Azure/azure-kubernetes-service/resources/gateway/gateway/Dockerfile) for guidance.
226
+
Alternatively, see the [ACME Fitness Store sample Dockerfile](https://github.com/Azure-Samples/acme-fitness-store/blob/Azure/azure-kubernetes-service/resources/gateway/gateway/Dockerfile) for guidance.
216
227
217
-
Run the following command to build the image of gateway using your Azure Container Registry:
228
+
Use the following commands to build the image of the gateway:
218
229
219
-
```azurecli
220
-
az acr login --name <azure-container-registry-name>
Ensure the gateway image is created and get the image tag, which follows the format: `<azure-container-registry-name>.azurecr.io/gateway:acrbuild-spring-cloud-gateway-0.0.1-SNAPSHOT`.
239
+
Ensure the gateway image is created, and get the image tag, which ues the following format: `<azure-container-registry-name>.azurecr.io/gateway:acrbuild-spring-cloud-gateway-0.0.1-SNAPSHOT`.
225
240
226
241
### Deploy the image in Azure Container Apps
227
242
228
-
Once your gateway application image is ready, deploy it as an Azure Container Apps application `gateway`. Replace the <container-image-of-gateway>with the image tag retrieved in the previous step:
243
+
After your gateway application image is ready, deploy it as an Azure Container Apps application by using the following command. Replace the `<container-image-of-gateway>` placeholder with the image tag retrieved in the previous step.
Access the FQDN of the Spring Cloud Gateway application to verify that it is running.
255
+
Access the FQDN of the Spring Cloud Gateway application to verify that it's running.
241
256
242
257
## Troubleshooting
243
258
244
-
If you encounter issues when running the Spring Cloud Gateway application, you can view real time and historical logs of the application `gateway` in Azure Container Apps following [Application Logging in Azure Container Apps](/azure/container-apps/logging).
259
+
If you encounter issues when running the Spring Cloud Gateway application, you can view real time and historical logs of the `gateway`application in Azure Container Apps. For more information, see [Application Logging in Azure Container Apps](/azure/container-apps/logging).
245
260
246
-
To monitor gateway application's metrics, refer to [Monitor Azure Container Apps metrics](/azure/container-apps/metrics)
261
+
You can also monitor a gateway application's metrics. For more information, see [Monitor Azure Container Apps metrics](/azure/container-apps/metrics)
247
262
248
263
## Known limitation
249
264
250
265
As far as we know, Spring Cloud Gateway does not support the following commercial features:
251
266
252
-
- Metadata used to generate OpenAPI documentation
253
-
- Single sign-on (SSO) functionality
267
+
- Metadata used to generate OpenAPI documentation.
268
+
- Single sign-on (SSO) functionality.
254
269
255
-
If these features are required, you may need to consider other commercial solutions, such as Spring Cloud Gateway for VMWare Tanzu.
270
+
If you require these features, you may need to consider other commercial solutions, such as Spring Cloud Gateway for VMWare Tanzu.
0 commit comments