Skip to content

Commit cb8dac5

Browse files
committed
implement simple external load balancer with cloud gateway
1 parent 6d2fdbe commit cb8dac5

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed

.idea/encodings.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apigw/pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.hrk</groupId>
8+
<artifactId>microservices-tutorial</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>apigw</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>20</maven.compiler.source>
16+
<maven.compiler.target>20</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.springframework.cloud</groupId>
23+
<artifactId>spring-cloud-starter-gateway</artifactId>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.springframework.cloud</groupId>
28+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>org.springframework.cloud</groupId>
33+
<artifactId>spring-cloud-starter-sleuth</artifactId>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>org.springframework.cloud</groupId>
38+
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
39+
</dependency>
40+
</dependencies>
41+
42+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.hrk.apigw;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6+
7+
@SpringBootApplication
8+
@EnableEurekaClient
9+
public class ApiGWApplication {
10+
public static void main(String[] args) {
11+
SpringApplication.run(ApiGWApplication.class, args);
12+
}
13+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
server:
2+
port: 8083
3+
4+
spring:
5+
application:
6+
name: api-gateway
7+
8+
zipkin:
9+
base-url: http://localhost:9411
10+
11+
cloud:
12+
gateway:
13+
routes:
14+
- id: customer
15+
uri: lb://CUSTOMER
16+
predicates:
17+
- Path=/api/v1/customer/**
18+
19+
eureka:
20+
client:
21+
service-url:
22+
defaultZone: http://localhost:8761/eureka
23+
fetch-registry: true
24+
register-with-eureka: true

apigw/src/main/resources/banner.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
,---. ,------. ,--. ,----. ,--.
2+
/ O \ | .--. '| |,-----.' .-./ ,--,--.,-' '-. ,---. ,--. ,--. ,--,--.,--. ,--.
3+
| .-. || '--' || |'-----'| | .---.' ,-. |'-. .-'| .-. :| |.'.| |' ,-. | \ ' /
4+
| | | || | --' | | ' '--' |\ '-' | | | \ --.| .'. |\ '-' | \ '
5+
`--' `--'`--' `--' `------' `--`--' `--' `----''--' '--' `--`--'.-' /
6+
`---'

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<module>eureka-server</module>
1717
<module>clients</module>
1818
<module>notification</module>
19+
<module>apigw</module>
1920
</modules>
2021

2122
<properties>

0 commit comments

Comments
 (0)