https://github.com/ehsaniara/spring-cloud-pcf-sample
Spring Cloud example for Tanzu Application Service (TAZ)
https://github.com/ehsaniara/spring-cloud-pcf-sample
pcf spring-boot spring-cloud tanzu-application-service
Last synced: 23 days ago
JSON representation
Spring Cloud example for Tanzu Application Service (TAZ)
- Host: GitHub
- URL: https://github.com/ehsaniara/spring-cloud-pcf-sample
- Owner: ehsaniara
- License: apache-2.0
- Created: 2022-04-16T04:40:54.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-19T09:10:35.000Z (about 4 years ago)
- Last Synced: 2025-01-07T19:53:27.576Z (over 1 year ago)
- Topics: pcf, spring-boot, spring-cloud, tanzu-application-service
- Language: Java
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Cloud for Tanzu Application Service (TAS)
First we need to create `manifest.yml` for every project which go into TAS
For this example we are using [java-buildpack](https://github.com/cloudfoundry/java-buildpack).
```yaml
---
applications:
- name: gw
buildpack: https://github.com/cloudfoundry/java-buildpack.git#v4.48.2
instances: 1
memory: 512M
env:
SPRING_PROFILES_ACTIVE: cloud
JAVA_OPTS: -Xms256m -Xmx256m -Xss64m
JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+}}'
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'
```
For More details, please visit [VMware Tanzu Application Service](https://docs.pivotal.io/application-service/).
### URL base routing
In project `gw`
```java
@Bean
public RouteLocator MyRoute(RouteLocatorBuilder builder) {
return builder//
.routes()//
.route("svc1", r -> r.path("/svc1/**")
//
.filters(f -> f.stripPrefix(1))
//
.uri("lb://svc1"))//
.route("svc2", r -> r.path("/svc2/**")
//
.filters(f -> f.filter(authFilter).stripPrefix(1))
//
.uri("lb://svc2"))//
.build();
}
```
### Service 1
🚦All traffics from the given URL pattern will be forwarded into `SVC1` microservice
```shell
curl -i http://localhost:8080/svc1
```
### Service 2
🚦All traffics from the given URL pattern will be forwarded into `SVC2` microservice.
In addition request should carry the `Authorization` header otherwise return 🛑`401 Error`
> 🚧 You can impediment desire auth logic in `AuthFilter.java` from `gw` project
```shell
curl -i -H "Authorization: Bearer jayWTea..." http://localhost:8080/svc2
```