Table of contents
- 1. The benefits of using Docker deployment
- 2. Comparison between Docker and Kubernetes
- Three, Redis cluster deployment actual combat
- 4. Spring Boot project packaging image
- ?summary
1. The benefits of using Docker deployment
The advantage of Docker is: running the same container on different instances
Five advantages of Docker: 持续部署与测试
, 多云服务平台支持
, 环境标准化和版本控制
, 隔离
,安全
2. Comparison between Docker and Kubernetes
Docker is suitable for relatively small applications. When the amount of concurrency is not large, there are more than 10 microservices . It is recommended to apply Docker deployment, which also saves resources and reduces development costs.
K8S is suitable for large clusters, with high concurrency and more than 10 microservices. At the same time, the performance is also very good. Under the premise of good performance, the development cost has also increased a lot !
Three, Redis cluster deployment actual combat
The following deploys a Redis cluster with three masters and three slaves as shown in the figure
Stop all containers and delete all records
1 |
|
Create a custom network redis
1 |
|
Create six redis basic information through scripts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Start 6 redis containers and mount data
1 2 3 4 5 6 7 8 |
|
Enter the settings in redis-1 to create a cluster
1 2 3 4 5 |
|
into the container
1 2 3 4 |
|
view nodes
1 |
|
Settings
1 |
|
We can see that the value is set on node 13, we stop the node, and get the value again to view
1 2 |
|
Get k1 in the original window
1 2 |
|
It can be seen that the value has been synchronized to other nodes. After the master node hangs up, we can still get the value!
4. Spring Boot project packaging image
Create a SpringBoot project
TestController
1 2 3 4 5 6 7 8 |
|
The local test is successfully accessed, and then the project is compiled as a jar package
1 2 |
|
Download the Docker image
Write Dockerfile
1 2 3 4 5 |
|
Upload the jar package and Dockerfile to the server
server file
compile Dockerfile
1 |
|
test access
1 |
|
The image uploaded successfully!
?summary
The above is [ Bug Terminator ] a brief introduction to Docker's actual combat - deploying Redis clusters and deploying microservice projects . Using Docker to deploy our applications is very convenient and fast , but if the architecture is huge, it is not recommended to use Docker. You can use our k8s cluster deployment is the most popular technology at present!