Member-only story

Mastering Kubernetes: The Art of Pod Composition

Beyond Single Containers: The Power of Pod Patterns in Kubernetes

Eugen Hoble
3 min readMar 12, 2024

--

Reasons to have multiple containers running inside a pod: It may not make sense to recreate an entire image to add functionality like a shell or logging agent. Instead, you could add another container to the Pod, which would provide the necessary tools.

Each container in the Pod should be transient and decoupled. If adding another container limits the scalability or transient nature of the original application, then a new build may be warranted.

Every container in a Pod shares a single IP address and namespace. Each container has equal potential access to storage given to the Pod. Kubernetes does not provide any locking, so your configuration or application should be such that containers do not have conflicting writes.

One container could be read only while the other writes. You could configure the containers to write to different directories in the volume, or the application could have built in locking. Without these protections, there would be no way to order containers writing to the storage.

Design patterns in the context of containerized applications are best practices and solutions to common problems that developers encounter when designing and deploying applications using containers.

1. Sidecar Pattern

  • Deploys a helper container alongside a primary application container, providing supporting features like logging, monitoring, or configuration management without changing the application.
  • Example: A logging sidecar container can be deployed alongside an application container to handle log collection and forwarding.

2. Ambassador Pattern

  • Uses an ambassador container as a proxy to external services, providing an abstraction layer that handles connection management, monitoring, and circuit breaking.

--

--

No responses yet

Write a response