Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the relationship between microservices, containers, and DevOps?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "what is the relationship between micro services, containers and DevOps". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1 disadvantages of micro-service

1.1 the workload of testing and publishing has increased dramatically

After a single application is split into multiple micro-services, although it can achieve rapid development and iteration, it brings greater costs for testing and operation and maintenance deployment.

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

Many businesses are a large single Web application in the early days. When testing and operation and maintenance, you only need to package the Web application to WAR and deploy it to Tomcat.

After breaking up into micro-services, many business requirements need to modify the code of multiple services at the same time, so these services need to be packaged, tested and released online, and the functions of these service interfaces will be tested. Finally, multiple systems will be released and launched. The workload of testing and operation and maintenance has increased dramatically. At this point, there needs to be a way to reduce the burden of testing and operation and maintenance. The solution I gave in the last lecture is DevOps.

DevOps can be understood as the combination of development and operation and maintenance. Service developers are no longer only responsible for the code development of the service, but also responsible for the whole lifecycle process of service testing, online release, and even fault handling, thus liberating the testing and operation and maintenance from the complex work brought about by the split of micro-services.

DevOps requires automation of the development, test and release process, which ensures that developers can copy the code and running environment passed by their local deployment tests to the test environment, and then copy them to the online environment for release after passing the tests. Although it seems to copy the code, in fact, the local environment, test environment and online environment are often isolated, and the software configuration environment is very different, resulting in fragmentation of the development, test and release processes.

1.2 the complexity of machine initialization has increased dramatically

The increase of machine initialization complexity caused by the difference of software running environment required by different microservices during elastic expansion and reduction. The split micro-service is more flexible than the original large-cell application, and often needs to be scaled up and down online according to the actual number of visitors, and the ECS created on the public cloud is usually used.

This brings challenges to OPS, because the ECS created on the public cloud usually contains only the basic os environment, and the software configuration on which the microservice runs need to be initialized separately. Because the software configuration of different microservices varies, for example, if the Java service depends on JDK, you need to install JDK on the ECS, and different microservice JDK versions may be different, so the initialization of service deployment is very complicated.

2 it's a good thing you: the container

Container technology solves the isolation of local, test and online environment, and solves the tedious problem of deployment service initialization.

Containers, or Container, can be translated into containers. The goods are encapsulated in containers at the port, then transported by cargo ships from sea to another port, and then unloaded at the port and transported to the destination by large trucks. In this way, when the goods can be transferred anywhere, they can be encapsulated in a container without having to reassemble the goods according to whether they are on a freighter or a large truck.

This is the function of the software container, which encapsulates the running environment of the software. The container is essentially a process in Linux, but through Namespace and Cgroups, the container can have its own root file system, network configuration, process space, and even its own user ID space, so that the processes in the container are like running in another separate os on the host, thus isolating them from other processes running in the host os.

Docker is the encapsulation and isolation of Cgroups and Namespace implementation processes based on Linux kernel.

Although the container solves the problem of application runtime isolation, to enable applications to migrate from one machine to another and function properly, you must ensure that the os on the other machine is consistent, and the various environments on which the application depends must be consistent. Docker mirroring solves this pain point.

That is, the Docker image can package not only the application itself, but also all the dependencies of the application, even the entire os. By running the passed application on the local machine, you can use the Docker image to package the application files, all dependent software, and os into a single image, which can be run anywhere Docker is installed.

Docker image solves the problem that it is difficult to maintain consistency among local environment, test environment and online environment in the running environment of micro-services in DevOps. In this way, the developer can package the code that runs the test in the local environment, as well as the dependent software and operating system itself into an image, and then automatically deploy it in the test environment for testing. after the test is passed, it is automatically released to the online environment, and the whole process of development, testing and release is opened.

Whether you use internal physical machines or public cloud machine deployment services, you can use Docker images to encapsulate the running environment of micro services, thus shielding the differences between the running environments of internal physical machines and public cloud machines, achieving equal treatment and reducing the complexity of operation and maintenance.

(3) the practice of micro-service containerization

Docker solves the problem of service runtime environment migration, because when using Docker images, the business code, dependent software environment and os are not packaged directly, but the layered mechanism of Docker images is used to package the Dockerfile images layer by layer at each layer.

Because different microservices depend on different software environments, they still exist in the same environment, so when packaging Docker images, you can design them layer by layer, reuse them layer by layer, and reduce the image file size of each layer.

4 Business case

See how Docker mirroring is used in a production environment. A Docker image is divided into four layers.

Basic environment layer

Define the version, time zone, language, Yum source, TERM, etc., that the operating system is running

Runtime environment layer

Defines the runtime environment for business code, such as the version of JDK, the runtime environment for Java code.

Web container layer

Defines the configuration of the container in which the business code runs, such as the JVM parameter of the Tomcat container

Business code layer

Defines the version of the actual business code, such as V4 business or blossom business.

In this way, each layer of image is based on adding new content to the upper layer, such as the Dockerfile of V4 service.

FROM registry.intra.xxx.com/xxx_rd_content/tomcat_feed:jdk8.0.40_tomcat7.0.81_g1_dns ADD confs/ data1/confs/ ADD node_pool/ data1/node_pool/ ADD authconfs/ data1/authconfs/ ADD authkey.properties / data1/ ADD watchman.properties / data1/ ADD 200.sh / data1/xxx/bin/200.sh ADD 503.sh / data1/xxx/bin/503.sh ADD catalina.sh / data1/xxx/bin/catalina.sh ADD server.xml / Data1/xxx/conf/server.xml ADD logging.properties / data1/xxx/conf/logging.properties ADD ROOT/ data1/xxx/webapps/ROOT/ RUN chmod + x / data1/xxx/bin/200.sh / data1/xxx/bin/503.sh / data1/xxx/bin/catalina.sh WORKDIR / data1/xxx/bin

FROM represents that the upper image file is tomcat_feed:jdk8.0.40_tomcat7.0.81_g1_dns ". It can be seen that this layer contains Java runtime environment JDK, Web container Tomcat, Tomcat version and JVM parameters.

ADD, that is, the file to be added in this layer image, which mainly contains the code and configuration of the business

RUN, the command that needs to be executed when the layer image is started

WORKDIR, the working directory after the layer image is started. In this way, the image creation of this layer can be completed based on the upper layer image through Dockerfile.

This is the end of the content of "what is the relationship between microservices, containers, and DevOps". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report