Multi-Container Pod Design Patterns in Kubernetes

Multi-Container Pod Design Patterns in Kubernetes

Pods

In Kubernetes Pods are the single deployable units. If any application must be deployed it has to be deployed in a Pod as a container. Though applications run in containers, container must be part of the Pod. The Pod specification has an attribute containers where container specifications are declared. The attribute is plural. That means we can declare more than one container in a Pod specification.

Multi-Container Design Consideration

But Kubernetes administrators always choose one container Pods over multi-container Pods. One Container Per Pod is an unwritten practice across the industry. Let’s see what advantage a multi-container pod has to offer.

The Pod has an IP. All containers in the Pod share the same IP. If any volume is created for the Pod all the containers those are part of the Pod could mount it. So, containers can share storage. They can also communicate with each other over localhost.

In that case why still One Container Pods are still preferred.  Let’s take a use case of a web application having UI, backend, database and messaging tiers. We will deploy all the four tiers as four containers in a single Pod. The resource, configuration, operation requirements are different for all the four containers. The backend and frontend are customer facing. If there would be a requirement to scale these to tiers, that can’t be done separately, as we can’t scale containers but pods. So, if we will scale up the Pod, multiple instances of database and messaging tier will also be created though that is not required.

Therefore, it is better to deploy them separately as managing and scaling them as individual Pods would be better.    

\"\"
 Figure 1: Use Case for Multi-Tier Application Deployment in Same Pod

In what case then we could use multiple containers in same Pod?

Case 1 – If the lifecycle of containers is same.

Case 2 – If two containers are very highly coupled

Case 3 – If   we need to make our application deployable to Kubernetes without any code change. It would be in such cases where the application code lacks something to take advantage of Kubernetes features.  In that case we can bring in a secondary container along with our application container which will break such barrier.

Multi-Container Design Patterns

Adapter Pattern

Our homes are supplied power in AC mode whereas the laptops we use consume power in DC mode. In that case we use AC adapters which draws power from AC outlets, then converts it to DC and supplies to the laptop. Without changing the power supply mode at our home, we could charge our laptops with the help of an adapter.

How can we relate it to Kubernetes? For example, if we have installed a centralized monitoring tool in the Kubernetes cluster, which needs all application logs to be printed in “APP-NAME – HOSTNAME – DATE – SEVERITY” format. But the cluster could have many applications written in variety of languages printing logs in variety of formats. In that case it would not be wise for all applications to change their logging format as if the tool changes in future the format may has to change again. To solve this issue, we can spawn a second container which reads logs of the main application container, processes it into the format desired by the monitoring tool. Problem solved.

Ambassador Pattern

An ambassador is an envoy who represents his country in the outside world.  How he can help us in Kubernetes Pod?

Take an example. You have a legacy application where the DB URL is hard coded inside the application as localhost. It is difficult to change legacy applications as it will bring in changes at lot of places. If you have to make it deployable in Kubernetes cluster, you need to change code. You can do so without code change by using an Ambassador pattern. An ambassador container co-locates an application container in same Pod. It works as a proxy. It connects to the correct Database depending upon the Dev, QA or Stage environment. The main application can connect to such external URLs as localhost through the ambassador container. The ambassador pattern finds the correct URL and supplies to the application container at localhost. The main application container doesn’t need to worry about the correct URL. That is assigned on to the ambassador container.

Sidecar Pattern

A sidecar is attached with a motor bike.  It adds a seat or two to the motorbike without any changes to it. It is not an integral part of the bike, but it enhances the capability of the bike. A sidecar container also behaves in the same way. It enhances the capability of the main container deployed with it, without making any changes to the main container. For example, if you have an application which generates log files in certain folder. If your application monitoring tool in the Kubernetes cluster needs the logs to be stored in some external storage for all the applications deployed to the cluster, it simply can’t be done at the application level. Rather we could employ a sidecar container which will store the log files in the required storage easily without making any code change at the main application level.

\"\"
Figure 2: Multi Container Pods

                             

Conclusion

All these patterns are very useful for doing cross-cutting jobs without making the main application to change. They provide support for the main container and must be deployed as secondary containers. These workloads must be written in such a way that they could be reusable in different Pods. To summarize Adapter pattern is used where we have to convert or process the output of main container to some standard format. Ambassador pattern is used to provide network proxy. Sidecar pattern is used to provide helper/utility services to the main container.

Try using these patterns to get best out of your Kubernetes cluster.

0 0 votes
Article Rating
Subscribe
Notify of
guest
213 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Sujeet
Sujeet
4 years ago

“We will deploy all the ‘for’ tiers as four containers in a single Pod”

Did you mean – “four tiers” instead?

Your code of destiny
8 months ago

I am extremely inspired along with your writing skills as well as with the layout to your weblog. Is this a paid subject or did you customize it your self? Either way stay up the nice high quality writing, it is rare to look a great blog like this one today!

Instagram Auto comment
8 months ago

I’m extremely impressed along with your writing talents
and also with the structure to your blog. Is that this a paid subject matter or did you modify it your self?
Either way keep up the excellent quality writing, it’s rare
to look a nice blog like this one nowadays. Beacons AI!

https://walmtv.com
3 months ago

long term anabolic steroid use

References:

people on steroids before and after (https://walmtv.com)

Git.Yinas.Cn
3 months ago

illegal testosterone booster

References:

Is Bodybuilding.Com Legit, Git.Yinas.Cn,

Valley.Md
3 months ago

closest thing to steroids on the market

References:

Valley.Md

https://gitnto.innovationcampus.ru/Laynedugger40

bodybuilding supplements for cutting

References:

can you drink Alcohol while on Steroids [https://gitnto.innovationcampus.ru/Laynedugger40]

git.penwing.org
3 months ago

anabolic muscle growth

References:

anavar anabolic steroid (git.penwing.org)

https://www.physiobabatsikos.gr/2019/05/08/άκανθα-πτέρνας

what do steroids do to your muscles

References:

where to buy legal steroids in the us (https://www.physiobabatsikos.gr/2019/05/08/άκανθα-πτέρνας)

구글아이디판매
3 months ago

Its such as you read my mind! You appear to grasp a lot about this,
like you wrote the e book in it or something. I think that you just could do with a
few % to pressure the message house a little bit, however instead of that, this is excellent blog.
An excellent read. I’ll definitely be back.

nh3limpiezas.com
3 months ago

A fascinating discussion is definitely worth comment.
I believe that you ought to publish more about
this subject matter, it might not be a taboo matter but typically people
do not speak about such issues. To the next! All the best!!

tomatotomato1.com
3 months ago

Greetings! I know this is somewhat off topic but I was wondering if you knew where I
could find a captcha plugin for my comment form?

I’m using the same blog platform as yours and I’m having problems finding
one? Thanks a lot!

gabiaba.com
3 months ago

Right away I am going away to do my breakfast, later than having my breakfast coming
yet again to read additional news.

skewers-restaurant.com
3 months ago

Now I am going away to do my breakfast, after having my breakfast coming over again to read
other news.

bodybuilding steroids use

steroids for weight gain

References:

bodybuilding steroids use

Https://Git.Werkraum-Karlsruhe.Org

steroid injection for muscle growth

References:

Anabolic Steroids Effects On Females (https://Git.Werkraum-Karlsruhe.Org)

le-canal.com
3 months ago

I really like your blog.. very nice colors & theme.
Did you design this website yourself or did you hire someone to do it for you?
Plz respond as I’m looking to create my own blog and would like to find out where u got this from.
appreciate it

Https://Volts.Howto.Co.Ug/@Brittneyeldred

can u drink on steroids

References:

Girls On Steroids Before And After (https://Volts.Howto.Co.Ug/@Brittneyeldred)

git.cnml.de
3 months ago

jay cutler before steroids

References:

Steroid formula (git.cnml.de)

Https://Molchanovonews.Ru/

countries where steroids are legal

References:

Best Product To Get Cut (https://Molchanovonews.Ru/)

tvgogo.co.kr
3 months ago

What’s up to all, it’s really a good for me to go to see this web site, it
contains helpful Information.

Https://historydb.date/

steroids effects on the body

References:

how long have steroids Been around (https://historydb.date/)

Repositorio de contenido multilingüe

Mʏ brother sսggested I miցht like this
web site. He was totally right. This post ɑctually maԀe my day.
You can not imagine just how much time I had spent for this infоrmation! Thanks!

Also visit my web page – Repositorio de contenido multilingüe

git.outsidecontext.solutions

natural muscles

References:

which of the Following statements about anabolic steroids is false?

(git.outsidecontext.solutions)

وی اینر آرمور

وی اینر آرمور،
از پروتئین گاوهای علف‌خوار نیوزلندی تهیه
شده و سرشار از لوسین، یکی از آمینو اسیدهای
شاخه‌ای (BCAA)، است.

netzschindia.com
3 months ago

What’s up everyone, it’s my first visit at this website,
and piece of writing is truly fruitful designed for me, keep up
posting these types of articles or reviews.

Https://peatix.Com/
3 months ago

prednisone substitutes

References:

steroid Stacks (https://peatix.Com/)

Https://golz.tv
3 months ago

what effects does steroids have on your body

References:

risks of anabolic steroids; https://golz.tv,

creelpetcare.com
3 months ago

Wonderful blog! I found it while surfing around on Yahoo News.
Do you have any suggestions on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!

Thank you

git.konsulterna.nu
3 months ago

steroids negative effects

References:

where to get dianabol (git.konsulterna.nu)

bluemoonmask.com
3 months ago

Remarkable! Its actually remarkable article, I have
got much clear idea regarding from this post.

story-story1.com
3 months ago

Awesome article.

Hafrikplay.Com
3 months ago

what are anabolics

References:

Gnc Cutting Supplements (Hafrikplay.Com)

وی ایزوله
3 months ago

پروتئین وی ایزوله، دارای پروتئین بالا و چربی و کربوهیدرات پایین‌تری نسبت به سایر انواع پروتئین است.

وی هیدرولیز
3 months ago

پروتئین وی هیدرولیز، باعث می‌شود تا با سرعت بیشتری به هدف مورد‌نظرکه اندامی خوش فرم است برسید.

وی پروتئین
3 months ago

پروتئین وی، باعث می‌شود تا با سرعت بیشتری به هدف مورد‌نظرکه اندامی خوش فرم است برسید.

emotioncruisehalong.com

I have to thank you for the efforts you have put in penning this site.
I’m hoping to see the same high-grade content by you later on as well.

In truth, your creative writing abilities has encouraged me to get my own, personal website now 😉

وی اتمیک
3 months ago

وی اتمیک، یک مکمل پودری است که به‌ راحتی در مایعات حل می‌شود و به شما کمک می‌کند تا پروتئین باکیفیت به رژیم غذاییتان اضافه کنید.

وی انابولیک کوین

وی انابولیک کوین، یک فرمول پیشرفته پروتئینی است که از ۵ منبع مختلف شامل وی کنسانتره، وی ایزوله، وی هیدرولیزه، کازئین و آلبومین تخم‌مرغ تشکیل شده است.

next-Work.org
3 months ago

steroids street names

References:

different ways to take steroids – next-Work.org,

وی ماسل رولز پرو

وی ماسل رولز پرو، با فرمولاسیونی خاص، مکملی ایده‌آل برای تمام افرادی است که به دنبال تأمین پروتئین روزانه خود هستند.

مکمل فیتنس
3 months ago

فیتنس مکمل، منبع بهترین مکمل های اروجینال برای افرادی است که به سلامت و زیبای اندام خود، و کیفیت و اصالت مکمل ورزشی اهمیت میدهند.

پروتئین کازئین

پروتئین کازئین، یکی از دو پروتئین اصلی موجود در شیر است (پروتئین دیگر، آب پنیر یا وی است).

کراتین
3 months ago

مکمل کراتین، مکملی محبوب در دنیای بدنسازی و ورزش، ترکیبی طبیعی است که از سه اسیدآمینه آرژنین، گلایسین و متیونین در بدن تولید می‌شود.

کراتین مونوهیدرات

مکمل کراتین مونوهیدرات، یک ترکیب طبیعیه که از سه اسید آمینه گلیسین، آرژنین و متیونین ساخته می‌شه و به طور عمده در عضلات اسکلتی ذخیره می‌شه.

เว็บm98
3 months ago

I’ll right away take hold of your rss as I
can not in finding your e-mail subscription link or e-newsletter service.
Do you have any? Please permit me recognize so that I may subscribe.
Thanks.

وی پرو انتیوم

وی پرو آنتیوم رونی کلمن، حاوی ۱۳.۵ گرم EAA، ۳.۵ گرم BCAA، ۵ گرم کراتین و ۲.۵ گرم بتائین در هر وعده است که به افزایش قدرت، استقامت و حجم عضلات کمک می‌کند.

کراتین ترکیبی

مکمل کراتین ترکیبی، مثل یه تیم فوتبال حرفه‌ای می‌مونه که هر بازیکنش یه کار خاص رو به نحو احسن انجام میده.

ویتامین
3 months ago

مکمل‌ ویتامین، مواد حیاتی‌ ای است که بدن ما برای عملکرد صحیح به آن‌ها نیاز دارد.

مولتی ویتامین یونیورسال 30

مولتی ویتامین انیمال یونیورسال پک 30 تایی، یک بسته کامل و جامع حاوی بیش از ۶۰ تا ۸۵ ماده مغذی کلیدی در هر ساشه (بسته) روزانه است!

Back To Top
3
0
Would love your thoughts, please comment.x
()
x