Pods
-
Pods will have different types of containers
- init containers: for initialization or checks
- main application(main car)
- side car containers
- ephemeral containers
-
Pod life cycle

- Pod will
- first create init containers one by one
- once the init containers finish then the
- main car and side car containers are created in parallel
- A container generally when running will launch CMD or ENTRYPOINT and if this command returns 0 (success) any thing else (FAILURE)
Lets write some examples
- 2 init containers with sleep 5 seconds
- main container with nginx
apiVersion: v1
kind: Pod
metadata:
name: ex-1
spec:
initContainers:
- name: init1
image: alpine
command:
- sleep
- "5"
- name: init2
image: alpine
command:
- sleep
- "5"
containers:
- name: web
image: nginx
- Lets try running one main car and one side car container with two init contaienrs
apiVersion: v1
kind: Pod
metadata:
name: ex-2
spec:
initContainers:
- name: init1
image: alpine
command:
- sleep
- "5"
- name: init2
image: alpine
command:
- sleep
- "5"
containers:
- name: web
image: nginx
- name: logger
image: alpine
command:
- sleep
- "1d"
- init containers failing will not start main container
- what if main container is failing
apiVersion: v1
kind: Pod
metadata:
name: ex-3
spec:
initContainers:
- name: init1
image: alpine
command:
- sleep
- "5"
- name: init2
image: alpine
command:
- sleep
- "5"
containers:
- name: web
image: alpine
command:
- sleep
- "3s"
- name: logger
image: alpine
command:
- sleep
- "1d"
-
This will lead to CrashLoopBackoff
-
To create a sidecar containers in newer versions of k8s add restart: always in init-contianers Refer Here
Health Probes
Create a simple tabular summary of health probes and impact of what happens when they fail or succed refer https://kubernetes.io/docs/concepts/workloads/pods/probes/
Give me an example of writing different types of probes
* command based
* request based
Give me a simple pod with one container based examples for each probe type