With the increasing adoption of containers and microservices in the enterprises, there is a need now to focus on structuring the containers and other distributed building blocks so that we can solve some of the common design challenges. In this post, we take look at some of the key design principles that could be used in Docker, Kubernetes, and other container platforms.
These principles are based on SOLID (Single responsibility, Open/closed, Liskov substitution, Interface segregation, Dependency inversion) principles that were introduced by Robert C. Martin, which represent guidelines for writing better object-oriented software.
Following these principles would ensure that the resulting containers behave like a good cloud-native citizen in most container orchestration engines, allowing them to be scheduled, scaled, and monitored in an automated fashion.
Quick Snapshot
Every container should address ONLY a single concern. This principle is more like the single responsibility principle (SRP), which advises that a class should have only one responsibility.
A container should rely only on the presence of the Linux kernel and have any additional libraries added to it at the time the container is built.
Some applications are composed of multiple containerized components. For example, a containerized web application may also require a database container. This principle does not suggest merging both containers. Instead, it suggests that the database container contains everything needed to run the database, and the web application container contains everything needed to run the web application, such as the webserver. At runtime, the web application container will depend on and access the database container as needed.
Containerized applications are meant to be immutable, and once built are not expected to change between different environments.
We should prevent the creation of similar container images for different environments but stick to one container image configured for each environment.
Every container must implement all necessary APIs to help the platform observe and manage the application in the best way possible.
A container should have a way to read the events coming from the platform and conform by reacting to those events.
Containerized applications need to be as ephemeral as possible and ready to be replaced by another container instance at any point in time. This means that containerized applications must keep their state externalized or distributed and redundant.
Every container should declare its resource requirements and it is also important that the application stay confined to the indicated resource requirements.
In addition to passing the resource requirements of the container, it is also important that the application stay confined to the indicated resource requirements.
In addition to the above principles, follow the common container-related best practices:
sudo
command or requiring a specific userid
to run your container.EXPOSE
command makes it easier for both humans and software to use your image.Like this post? Don’t forget to share it!
There are few things as valuable to a business as well-designed software. Organizations today rely…
The cryptocurrency industry is being reshaped by the fusion of blockchain technology and artificial intelligence…
Introduction Artificial Intelligence (AI) has also found its relevance in graphic design and is quickly…
Imagine a world where the brilliance of Artificial Intelligence (AI) meets the unbreakable security of…
In today’s fast-paced digital landscape, automation is not just a luxury but a necessity for…
The world of casino gaming has leveraged the emerging technology advancements to create immersive and…
This website uses cookies.