# Microservices with Spring Boot and Spring Cloud on Kubernetes Demo Project [![Twitter](https://img.shields.io/twitter/follow/piotr_minkowski.svg?style=social&logo=twitter&label=Follow%20Me)](https://twitter.com/piotr_minkowski)
[![CircleCI](https://circleci.com/gh/piomin/sample-spring-microservices-kubernetes.svg?style=svg)](https://circleci.com/gh/piomin/sample-spring-microservices-kubernetes)
[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-black.svg)](https://sonarcloud.io/dashboard?id=piomin_spring-microservices-kubernetes)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=piomin_spring-microservices-kubernetes&metric=bugs)](https://sonarcloud.io/dashboard?id=piomin_spring-microservices-kubernetes)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=piomin_spring-microservices-kubernetes&metric=coverage)](https://sonarcloud.io/dashboard?id=piomin_spring-microservices-kubernetes)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=piomin_spring-microservices-kubernetes&metric=ncloc)](https://sonarcloud.io/dashboard?id=piomin_spring-microservices-kubernetes)
In this project I'm demonstrating you the most interesting features of [Spring Cloud Project](https://spring.io/projects/spring-cloud) for building microservice-based architecture that is deployed on Kubernetes. All the samples may be easily deployed on local Kubernetes single-node cluster - Minikube.
## Getting Started
Currently you may find here some examples of microservices implementation using different projects from Spring Cloud. All the examples are divided into the branches and described in a separated articles on my blog. Here's a full list of available examples:
1. Using Spring Boot and Spring Cloud for building microservices that may be easily deployed on Kubernetes. The example is available in the branch [master](https://github.com/piomin/sample-spring-microservices-kubernetes/tree/master). A detailed guide may be find in the following article: Detailed description can be found here: [Quick Guide to Microservices with Kubernetes, Spring Boot 2.0 and Docker](https://piotrminkowski.com/2018/08/02/quick-guide-to-microservices-with-kubernetes-spring-boot-2-0-and-docker/)
2. An introduction to Spring Cloud Kubernetes project, that shows its the most interesting features like discovery across many namespaces or Spring Boot property sources based on ConfigMap and Secret. The example is available in the branch [hybrid](https://github.com/piomin/sample-spring-microservices-kubernetes/tree/hybrid). A detailed guide may be find in the following article: Detailed description can be found here: [Microservices with Spring Cloud Kubernetes](https://piotrminkowski.com/2019/12/20/microservices-with-spring-cloud-kubernetes/)
3. Using Spring Boot Admin to monitor Spring Boot applications running on Kubernetes. The example is available in the branch [master](https://github.com/piomin/sample-spring-microservices-kubernetes/tree/master). A detailed guide may be find in the following article: [Spring Boot Admin on Kubernetes](https://piotrminkowski.com/2020/02/18/spring-boot-admin-on-kubernetes/)
### Usage
1. Download and run **Minikube** using command: `minikube start --vm-driver=virtualbox --memory='4000mb'`
2. Build Maven project with using command: `mvn clean install`
3. Build Docker images for each module using command, for example: `docker build -t piomin/employee:1.1 .`
4. Go to `/kubernetes` directory in repository
5. Apply all templates to Minikube using command: `kubectl apply -f <filename>.yaml`
6. Check status with `kubectl get pods`
## Architecture
Our sample microservices-based system consists of the following modules:
- **gateway-service** - a module that Spring Cloud Netflix Zuul for running Spring Boot application that acts as a proxy/gateway in our architecture.
- **employee-service** - a module containing the first of our sample microservices that allows to perform CRUD operation on Mongo repository of employees
- **department-service** - a module containing the second of our sample microservices that allows to perform CRUD operation on Mongo repository of departments. It communicates with employee-service.
- **organization-service** - a module containing the third of our sample microservices that allows to perform CRUD operation on Mongo repository of organizations. It communicates with both employee-service and department-service.
- **admin-service** - a module containing embedded Spring Boot Admin Server used for monitoring Spring Boot microservices running on Kubernetes
The following picture illustrates the architecture described above including Kubernetes objects.
<img src="https://piotrminkowski.files.wordpress.com/2018/07/micro-kube-1.png" title="Architecture1">
You can distribute applications across multiple namespaces and use Spring Cloud Kubernetes `DiscoveryClient` and `Ribbon` for inter-service communication.
<img src="https://piotrminkowski.files.wordpress.com/2019/12/microservices-with-spring-cloud-kubernetes-discovery.png" title="Architecture2" >
## Before you start
Go to the `k8s` directory. You will find there several YAML scripts you need to apply before running applications.
1. `privileges.yaml` - `Role` and `RoleBinding` for Spring Cloud Kubernetes to allow access Kubernetes API from pod
2. `mongo-secret.yaml` - credentials for MongoDB
3. `mongo-configmap.yaml` - user for MongoDB
4. `mongo-deployment.yaml` - `Deployment` for MongoDB
Just apply those scripts using `kubectl apply`.
You can easily deploy all applications using `skaffold dev` command.
没有合适的资源?快使用搜索试试~ 我知道了~
Spring Boot 与 Spring Cloud 在 Kubernetes 上的微服务示例项目.zip
共80个文件
yaml:29个
java:28个
yml:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 197 浏览量
2024-11-15
22:43:30
上传
评论
收藏 49KB ZIP 举报
温馨提示
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
资源推荐
资源详情
资源评论
收起资源包目录
Spring Boot 与 Spring Cloud 在 Kubernetes 上的微服务示例项目.zip (80个子文件)
sample-spring-microservices-kubernetes
pom.xml 3KB
renovate.json 296B
.circleci
config.yml 2KB
skaffold.yaml 970B
admin-service
pom.xml 1KB
src
main
resources
bootstrap.yml 169B
java
pl
piomin
services
admin
AdminApplication.java 602B
config
SecurityConfiguration.java 602B
skaffold.yaml 246B
k8s
configmap.yaml 242B
service.yaml 161B
deployment.yaml 453B
readme.md 6KB
gateway-service
pom.xml 2KB
src
main
resources
application.yml 1KB
java
pl
piomin
services
gateway
api
GatewayApi.java 1KB
GatewayApplication.java 436B
skaffold.yaml 252B
Dockerfile 209B
k8s
configmap.yaml 892B
service.yaml 191B
deployment.yaml 414B
.gitignore 47B
k8s
ingress.yaml 619B
mongodb-secret.yaml 139B
mongodb-configmap.yaml 90B
privileges.yaml 669B
mongodb-deployment.yaml 1023B
organization-service
pom.xml 2KB
src
main
resources
application.yml 275B
java
pl
piomin
services
organization
OrganizationApplication.java 644B
repository
OrganizationRepository.java 273B
client
EmployeeClient.java 537B
DepartmentClient.java 723B
controller
OrganizationController.java 3KB
model
Department.java 947B
Organization.java 2KB
Employee.java 1KB
skaffold.yaml 329B
Dockerfile 214B
k8s
configmap.yaml 237B
secret.yaml 170B
service.yaml 232B
deployment.yaml 623B
.gitignore 47B
.gitignore 12KB
employee-service
pom.xml 4KB
src
test
java
pl
piomin
services
employee
EmployeeKubernetesTest.java 5KB
EmployeeKubernetesMockTest.java 4KB
EmployeeAPITest.java 3KB
main
resources
application.yml 316B
java
pl
piomin
services
employee
repository
EmployeeRepository.java 408B
EmployeeApplication.java 557B
controller
EmployeeController.java 2KB
model
Employee.java 2KB
skaffold.yaml 321B
Dockerfile 210B
k8s
configmap.yaml 233B
secret.yaml 166B
service.yaml 220B
deployment.yaml 675B
.gitignore 47B
department-service
pom.xml 3KB
src
test
java
pl
piomin
services
department
DepartmentAPITest.java 2KB
DepartmentAPIAdvancedTest.java 6KB
main
resources
application.yml 472B
java
pl
piomin
services
department
repository
DepartmentRepository.java 355B
client
EmployeeClient.java 677B
controller
DepartmentController.java 4KB
DepartmentWithRestTemplateController.java 3KB
DepartmentApplication.java 2KB
model
Department.java 1KB
Employee.java 922B
skaffold.yaml 295B
Dockerfile 212B
k8s
configmap.yaml 235B
secret.yaml 168B
service.yaml 226B
deployment.yaml 611B
.gitignore 47B
共 80 条
- 1
资源评论
pk_xz123456
- 粉丝: 2159
- 资源: 1837
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Arduino的盲人碰撞预警系统.zip
- 自己学习java安全的一些总结,主要是安全审计相关.zip
- (源码)基于C++的多线程外部数据排序与归并系统.zip
- 编译的 FFmpeg 二进制 Android Java 库.zip
- 纯 Java git 解决方案.zip
- (源码)基于Spring Boot和Vue的后台管理系统.zip
- 用于将 Power BI 嵌入到您的应用中的 JavaScript 库 查看文档网站和 Wiki 了解更多信息 .zip
- (源码)基于Arduino、Python和Web技术的太阳能监控数据管理系统.zip
- (源码)基于Arduino的CAN总线传感器与执行器通信系统.zip
- (源码)基于C++的智能电力系统通信协议实现.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功