Home Explore Blog CI



kubernetes

3rd chunk of `content/en/blog/_posts/2015-06-00-The-Distributed-System-Toolkit-Patterns.md`
4cedc6f90902e765b5481fdd46593f33123b33c484cad5d20000000100000bf9
![Sidecar Containers](/Users/baehyunsol/Documents/Rust/ragit/sample/kubernetes/./images/blog/2015-06-00-The-Distributed-System-Toolkit-Patterns/sidecar-containers.png)

## Example #2: Ambassador containers

Ambassador containers proxy a local connection to the world.  As an example, consider a Redis cluster with read-replicas and a single write master.  You can create a Pod that groups your main application with a Redis ambassador container.  The ambassador is a proxy is responsible for splitting reads and writes and sending them on to the appropriate servers.  Because these two containers share a network namespace, they share an IP address and your application can open a connection on “localhost” and find the proxy without any service discovery.  As far as your main application is concerned, it is simply connecting to a Redis server on localhost.  This is powerful, not just because of separation of concerns and the fact that different teams can easily own the components, but also because in the development environment, you can simply skip the proxy and connect directly to a Redis server that is running on localhost.

![Ambassador Containers](/Users/baehyunsol/Documents/Rust/ragit/sample/kubernetes/./images/blog/2015-06-00-The-Distributed-System-Toolkit-Patterns/ambassador-containers.png)

## Example #3: Adapter containers

Adapter containers standardize and normalize output.  Consider the task of monitoring N different applications.  Each application may be built with a different way of exporting monitoring data. (e.g. JMX, StatsD, application specific statistics) but every monitoring system expects a consistent and uniform data model for the monitoring data it collects.  By using the adapter pattern of composite containers, you can transform the heterogeneous monitoring data from different systems into a single unified representation by creating Pods that groups the application containers with adapters that know how to do the transformation.  Again because these Pods share namespaces and file systems, the coordination of these two containers is simple and straightforward.

![Adapter Containers](/Users/baehyunsol/Documents/Rust/ragit/sample/kubernetes/./images/blog/2015-06-00-The-Distributed-System-Toolkit-Patterns/adapter-containers.png)


In all of these cases, we've used the container boundary as an encapsulation/abstraction boundary that allows us to build modular, reusable components that we combine to build out applications.  This reuse enables us to more effectively share containers between different developers, reuse our code across multiple applications, and generally build more reliable, robust distributed systems more quickly.  I hope you’ve seen how Pods and composite container patterns can enable you to build robust distributed systems more quickly, and achieve container code re-use.  To try these patterns out yourself in your own applications. I encourage you to go check out open source Kubernetes or Google Container Engine.

Title: Modular Container Patterns: Ambassador and Adapter Containers
Summary
Ambassador containers proxy local connections, exemplified by a Redis ambassador managing read/write splits to a Redis cluster, allowing the main application to connect to 'localhost' as if it were a Redis server. Adapter containers standardize output, such as transforming heterogeneous monitoring data from different applications into a unified format for monitoring systems. Both patterns promote modularity, reusability, and simplified coordination through shared namespaces within Pods, enabling faster development of robust distributed systems.