Skip to content

Multi-Container Pods

Multi-Containers Pod

Container images solve many real-world problems with existing packaging and deployment tools, but in addition to these significant benefits, containers offer us an opportunity to fundamentally re-think the way we build distributed applications. Just as service oriented architectures (SOA) encouraged the decomposition of applications into modular, focused services, containers should encourage the further decomposition of these services into closely cooperating modular containers. By virtue of establishing a boundary, containers enable users to build their services using modular, reusable components, and this in turn leads to services that are more reliable, more scalable and faster to build than applications built from monolithic containers.

Resources

OpenShift

IKS - Sidecar Logging - Shared Volume Communication - Toolkit Patterns - Brendan Burns Paper

References

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  volumes:
  - name: shared-data
    emptyDir: {}
  containers:
  - name: app
    image: bitnami/nginx
    volumeMounts:
      - name: shared-data
        mountPath: /app
    ports:
    - containerPort: 8080
  - name: sidecard
    image: busybox
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ['sh', '-c', 'echo Hello from the side container > /pod-data/index.html && sleep 3600']
apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  shareProcessNamespace: true
  containers:
  - name: app
    image: bitnami/nginx
    ports:
    - containerPort: 8080
  - name: sidecard
    image: busybox
    securityContext:
      capabilities:
        add:
        - SYS_PTRACE
    stdin: true
    tty: true

Attach Pods Together

oc attach -it my-pod -c sidecard
ps ax
kill -HUP 7
ps ax

Attach Pods Together

kubectl attach -it my-pod -c sidecard
ps ax
kill -HUP 7
ps ax

Activities

Task Description Link
Try It Yourself
Multiple Containers Build a container using legacy container image. Multiple Containers