Pods
- Pods contain containers in it
- Pods have 3 types of containers
- containers: These contain application containers and they execute in parallel. This is mandatory
- init containers: These containers will start first and once they finish executing the containers will start. Containers here will start in sequence.
- We will have containers which act as pre-condition
- optional contianer
- ephemeral containers: for debugging purposes (optional)
Example 1: I want a httpd container inside a pod
- Refer Here for api reference
- metadata: In metadata as of now we will add two details
- name
- labels: labels in k8s are key value apirs, which can be used to query
- Manifest
---
apiVersion: v1
kind: Pod
metadata:
name: example-1
labels:
app: httpd
purpose: learning
env: dev
spec:
containers:
- name: httpd
image: httpd:latest
ports:
- name: httpd
protocol: TCP
containerPort: 80
Pods contd
- Each Pod gets a unique ip address
- Each Pod has a lifecycle

Example 2: Pod with container with stops
---
apiVersion: v1
kind: Pod
metadata:
name: example-2
labels:
app: hello-world
env: dev
topic: "exiting-containers"
spec:
containers:
- name: suicidal
image: hello-world:latest

Example 3: Pod with two containers
- Lets create a pod with two containers
- first container will be nginx
- second container will be tomcat
---
apiVersion: v1
kind: Pod
metadata:
name: example-3
labels:
app: web
purpose: multi-container
spec:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
- name: tomcat
image: tomcat:latest
ports:
- containerPort: 8080
Example 4: lets use init containers with sleep 3s and 4s and nginx
---
apiVersion: v1
kind: Pod
metadata:
name: example-4
labels:
purpose: init-container-demo
app: nginx
spec:
initContainers:
- name: init-0
image: alpine
command:
- sleep
- "3s"
- name: init-1
image: alpine
command:
- sleep
- "4s"
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80

Prompts
- Understanding manifest w.r.t apiServer/cluster
You are kubernetes api-server. I will give you k8s manifest
tell me what you will be doing and give me in plain english what the manifest is all about.
- Understanding manifest and knowing best practices
you are kubernetes expert, I will give you manifest files, explain what it does and also suggest me best practices around this manifest
Like this:
Like Loading...