How To Design A Container-Based Application?
Dear Friend,
Container is an important moving part of microservices architecture.
You will need to place your application, and services into a container to get started in the Kubernetes world.
Containerising an application is an easier step, but designing it to use the full capability of cloud-native computing requires certain due diligence.
Let's discuss the guidelines which allow us to design a robust container that could withstand failure, be secure by design, decoupled so it can independently interact with other applications in a containerised environment.
??Single concern principle (SCP)
Each container should address a single concern effectively. For example, if you have a 3-tier application, then you would pack them in each container than all together in a single container.
In the micro-services world, each of your REST services would go into a container.
??High observability principle (HOP)
Containerized applications must offer APIs for health checks, and logging, and integrate with tracing and metrics-gathering libraries.
Logging important events into STDERR and STDOUT is crucial for log aggregation.
??Life-cycle conformance principle (LCP):
Containers should react to events from the platform, such as signal messages like SIGTERM for clean shutdown processes.
Handling events like PostStart and PreStop is essential for application life-cycle management.
??Image immutability principle (IIP):
领英推荐
Containerized applications should be immutable and rely on externalized configurations, preventing the creation of similar container images for different environments.
??Process disposability principle (PDP):
Containers should be ephemeral, ready to be replaced at any time due to various reasons like failing health checks or scaling down.
Keeping the state externalized or distributed helps in implementing this principle.
??Self-containment principle (S-CP):
Containers should contain everything they need at build time, relying only on the Linux kernel and having additional libraries added during build.
Exceptions include configurations, which are provided at runtime through Kubernetes ConfigMap.
??Runtime confinement principle (RCP):
Containers must declare resource requirements to the platform, influencing scheduling, auto-scaling, and SLAs.
Staying within indicated resource requirements reduces the likelihood of termination or migration during resource starvation.
What's Next?
In addition to the discussion above, read about general for writing docker files
Share your thoughts, and questions in the comment