博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
k8s sidecar, Ambassador, Adapter containers
阅读量:6637 次
发布时间:2019-06-25

本文共 3564 字,大约阅读时间需要 11 分钟。

When you start thinking in terms of Pods, there are naturally some general patterns of modular application development that re-occur multiple times.  I’m confident that as we move forward in the development of Kubernetes more of these patterns will be identified, but here are three that we see commonly:

Example #1: Sidecar containers

Sidecar containers extend and enhance the "main" container, they take existing containers and make them better.  As an example, consider a container that runs the Nginx web server.  Add a different container that syncs the file system with a git repository, share the file system between the containers and you have built Git push-to-deploy.  But you’ve done it in a modular manner where the git synchronizer can be built by a different team, and can be reused across many different web servers (Apache, Python, Tomcat, etc).  Because of this modularity, you only have to write and test your git synchronizer once and reuse it across numerous apps. And if someone else writes it, you don’t even need to do that.

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.

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.

 

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.
 
more to see:  

转载于:https://www.cnblogs.com/pinganzi/p/7389854.html

你可能感兴趣的文章
JAVA设计模式:简单工厂、工厂方法、抽象工厂之小结与区别 .
查看>>
.NET概念:消息机制
查看>>
面试官提问最常见的问题与影片在回答分享-70问
查看>>
Java annotation源码解读
查看>>
前端功能资料
查看>>
《数据结构与算法分析--c语言描述》之第一章:引论
查看>>
DAHDI 卡安装配置
查看>>
IE 8下的pdf打不开
查看>>
openwrt linux portal 实现 支持 https 支持基于时长和流量控制
查看>>
RSF 分布式服务框架设计
查看>>
solaris学习9:NFS
查看>>
充电第二天
查看>>
JAX-WS
查看>>
easyrec——一个开源推荐系统
查看>>
C++ wait/notify机制
查看>>
Java线程
查看>>
spring cloud
查看>>
Binder进程间通信(二)---- 驱动程序初始化
查看>>
redis sentinel 主从切换(failover)解决方案,详细配置
查看>>
Java 8: 从永久代(PermGen)到元空间(Metaspace)
查看>>