forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kong-k8s-springboot cleuton.sampaio (eugenp#13001)
Co-authored-by: cleutonsampaio <cleutonsampaio@cloud.upwork.com>
- Loading branch information
Showing
14 changed files
with
742 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
kubernetes-modules/kubernetes-spring/.mvn/wrapper/maven-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Kong Ingress Controller with Spring Boot | ||
|
||
This project was generated from Spring Initializer Website (https://start.spring.io/): | ||
|
||
Maven version Java latest: | ||
``` | ||
curl https://start.spring.io/starter.tgz -d dependencies=webflux,actuator -d type=maven-project | tar -xzvf - | ||
``` | ||
|
||
Maven version Java 11: | ||
``` | ||
curl https://start.spring.io/starter.tgz -d dependencies=webflux,actuator -d type=maven-project -d javaVersion=11 | tar -xzvf - | ||
``` | ||
|
||
## Steps to run the demonstration: | ||
|
||
1. Install minikube: https://www.baeldung.com/spring-boot-minikube | ||
|
||
2. Install Kong Ingress Controller on minikube: https://docs.konghq.com/kubernetes-ingress-controller/latest/deployment/minikube/ | ||
- Test wich echo-server | ||
- Create environment variable: export PROXY_IP=$(minikube service -n kong kong-proxy --url | head -1) | ||
|
||
3. build that Spring boot service: | ||
- Run ./mvnw install | ||
- Run jar: java -jar target/*.jar | ||
|
||
4. Create a Docker image: | ||
If using minikube and don't want to push image to a repository, then point your local Docker client to Minikube's implementation: eval $(minikube -p minikube docker-env) --- use the same shell. | ||
- Run: ./mvnw spring-boot:build-image | ||
|
||
5. Deploy the application, create a service and an ingress rule: | ||
``` | ||
kubectl apply -f serviceDeployment.yaml | ||
kubectl apply -f clusterIp.yaml | ||
kubectl apply -f ingress-rule.yaml | ||
``` | ||
|
||
6. Test access using the proxy IP: | ||
``` | ||
curl -i $PROXY_IP/actuator/health | ||
``` | ||
|
||
## Setting up a rate limiter on your api | ||
|
||
7. Create a plugin: | ||
|
||
kubectl apply -f rate-limiter.yaml | ||
|
||
8. Now test resource. Try more than 5 times a minute: | ||
``` | ||
curl -i $PROXY_IP/actuator/health | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
app: demo | ||
name: demo | ||
spec: | ||
ports: | ||
- name: 8080-8080 | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 8080 | ||
selector: | ||
app: demo | ||
type: ClusterIP | ||
status: | ||
loadBalancer: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: demo | ||
spec: | ||
ingressClassName: kong | ||
rules: | ||
- http: | ||
paths: | ||
- path: /actuator/health | ||
pathType: ImplementationSpecific | ||
backend: | ||
service: | ||
name: demo | ||
port: | ||
number: 8080 |
Oops, something went wrong.