Microservices could be built and tested using CI/CD tools such as Jenkins, TeamCity, and so on. In microservices, each microservice is like a small application.
For example, once you commit the code in the repository(SCM), CI/CD tools trigger the build process:
- Cleaning Code
- Code Compilation
- Unit Test Execution
- Contract/Acceptance Test Execution
- Building the application container images/archives
- Publishing the archives
- Deployment in various environments such as Dev, QA, STAGE, and PROD, etc.
- Integration and Functional test execution
So after this release-build triggers that change the SNAPSHOT version in pom.xml build the artifacts. Publish the artifacts to the repository. Tag this version in the repository.If you are using the container image then build the container image as a part of the build.
Deployment using Docker
Previously, VMs(Virtual Machines) were used to create software images that could be deployed wherever needed. As of now, Container such as Docker becomes very popular as it is compatible with old vs new(cloud) build environments.
Containers
So containers provide a lightweight runtime environment that consists of the core features of VMs and isolated service of operating systems. So a container basically runs as an application(microservice) within the OS. The OS is basically on top of the hardware and each OS could have multiple containers, with a container running the application.
A container uses kernel interfaces such as cnames and namespaces that allow multiple containers to share the same kernel while running in complete isolation to one another.
Docker
Docker is open-source and it makes use of the Linux Kernel features such as groups and namespaces because to ensure resource isolation and packaging of the application you can with its dependencies.
you can also run as expected across different Linux OS/distributions.SO you can develop an application in any language and then easily deploy it.
Containers are made of just the application and its dependencies including the basic OS. In docker container, everything executes natively on the host and uses the host kernel directly.That's why each container has its own user namespace.
Docker uses a client-server architecture. the docker client is a user interface that is used by an end-user and it communicates back and forth with a Docker daemon. Docker daemon actually does the building, running, and distributing of your docker containers.at the same time docker client and docker daemon can run on the same system or different machines.
The Docker client and daemon communicate via sockets or through a RESTful API.
Docker Architecture
Main components of Docker :
1)Docker Image: This is basically a read-only template like an image that could contain an Ubuntu OS with an apache web server and your web application installed. So it is a build component of Docker and images are used to create docker containers.
2)Docker container: A docker container is created from a Docker image. The docker container can only see its own process and its own filesystem layered onto a host filesystem and a networking stack that pipes to the host-networking stack. Docker containers can be run started stopped moved or deleted.
Microservices deployment with docker deals with 3 parts:
- Application packaging like JAR
- Building Docker Image with a JAR and dependencies using a Docker instruction file, the Dockerfile and command docker build.
- Docker container execution from this newly build image using command docker run.
So ultimately Containerization is an efficient way to simplify microservices deployment.
The detail concept will cover in the next blog. Thanks.
No comments:
Post a Comment