Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Multi-Container Pod

From https://blog.devops.dev/advanced-kubernetes-pod-concepts-that-you-should-know-as-a-beginner-50c9ca1327fc

Why Multi-Container Pods?

Benefits: allows for the specific patterns that improve the efficiency, modularity, and functionality of applications.

Common Multi-Container Pod Patterns

Init Containers

Init Containers are special containers that run before the main application containers in a pod. They help set up required conditions, such as downloading files, initializing databases, or ensuring the environment is ready before the main application starts.

Use Cases of Init Containers:

Example configuration with an Init Container that runs a command to ensure that a specific database is ready:

apiVersion: v1
kind: Pod
metadata:
  name: init-container-pod
spec:
  initContainers:
  - name: init-db
    image: busybox
    command: ['sh', '-c', 'until nslookup database; do echo waiting for database; sleep 2; done']
  containers:
  - name: main-app
    image: nginx

The Init Container (init-db) checks if a service named database is accessible. Only once this check is complete does the main application container (nginx) start.