Skip to content

Commit 4fe4534

Browse files
Comprehensive edits.
1 parent a91f407 commit 4fe4534

File tree

1 file changed

+90
-75
lines changed

1 file changed

+90
-75
lines changed

articles/spring-apps/migration/migrate-to-azure-container-apps-components-gateway.md

Lines changed: 90 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ ms.custom: devx-track-java
1515

1616
**This article applies to:** ❎ Basic/Standard ✅ Enterprise
1717

18-
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.
1919

2020
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.
2121

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.
2324
2425
## Prerequisites
2526

@@ -28,79 +29,87 @@ Note that the features offered by Spring Cloud Gateway for VMWare Tanzu are more
2829
- [Azure CLI](/cli/azure/install-azure-cli)
2930
- 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).
3031

31-
## Prepare the code of self-hosted Spring Cloud Gateway application
32+
## Prepare the code of the self-hosted Spring Cloud Gateway application
3233

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:
3435

3536
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**.
3738
1. Add dependencies **Reactive Gateway** and **Spring Boot Actuator**.
3839
1. Leave the other properties at their default values.
3940
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.
4242

4343
## Configure the Spring Cloud Gateway
4444

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+
```
8088
8189
### CORS configuration
8290
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.
8492
8593
### Scale
8694
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).
8896

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.
9098

91-
### Custom domain & certificates
99+
### Custom domains & certificates
92100

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).
94102

95103
### Routes
96104

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:
98106

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`.
102108

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:
104113

105114
```json
106115
{
@@ -120,7 +129,7 @@ For example, consider the following route config JSON file, **test-api.json**, w
120129
}
121130
```
122131

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:
124133

125134
```yaml
126135
spring:
@@ -139,13 +148,13 @@ spring:
139148

140149
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.
141150

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`.
143152

144153
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.
145154

146155
### Response cache
147156

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).
149158

150159
```yaml
151160
spring:
@@ -158,7 +167,7 @@ spring:
158167
size: <response-cache-size>
159168
```
160169

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:
162171

163172
```yaml
164173
spring:
@@ -175,13 +184,15 @@ spring:
175184

176185
### Integrate with APM
177186

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
179190

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.
181192

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
183194

184-
### Build and Push the Docker Image
195+
To build and push the Docker image, use the following steps:
185196

186197
In the Spring Cloud Gateway project directory, create a **Dockerfile** with the following contents:
187198

@@ -212,44 +223,48 @@ COPY --from=build /staging/build/libs/gateway-0.0.1-SNAPSHOT.jar .
212223
ENTRYPOINT ["java", "-jar", "gateway-0.0.1-SNAPSHOT.jar"]
213224
```
214225

215-
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.
216227

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:
218229

219-
```azurecli
220-
az acr login --name <azure-container-registry-name>
221-
az acr build --image gateway:acrbuild-spring-cloud-gateway-0.0.1-SNAPSHOT --registry <azure-container-registry-name> --file Dockerfile . --resource-group <resource-group-name>
222-
```
230+
```azurecli
231+
az acr login --name <azure-container-registry-name>
232+
az acr build \
233+
--resource-group <resource-group-name> \
234+
--image gateway:acrbuild-spring-cloud-gateway-0.0.1-SNAPSHOT \
235+
--registry <azure-container-registry-name> \
236+
--file Dockerfile .
237+
```
223238

224-
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`.
225240

226241
### Deploy the image in Azure Container Apps
227242

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.
229244

230245
```azurecli
231246
az containerapp up \
232-
--name gateway \
233247
--resource-group <resource-group-name> \
248+
--name gateway \
234249
--environment <azure-container-app-environment-name> \
235250
--image <container-image-of-gateway> \
236251
--target-port 8080 \
237252
--ingress external
238253
```
239254

240-
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.
241256

242257
## Troubleshooting
243258

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).
245260

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)
247262

248263
## Known limitation
249264

250265
As far as we know, Spring Cloud Gateway does not support the following commercial features:
251266

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.
254269

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

Comments
 (0)