DaemonSet:
- DaemonSet ensure create pod on each node
- Ex: Logs , Networking , node-agent …etc

Create DaemonSet yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: demonset-demo
spec:
selector:
matchLabels:
name: demonset-demo
template:
metadata:
labels:
name: demonset-demo
spec:
containers:
- name: apache2
image: httpd:2.4
ports:
- containerPort: 80
Statefulset:
- Stable and uniq pods names like po-0, po-1, po-2 …etc
- Each pod will have its own storage (pvc)
- while scale up pods like po-0, po-1, po-2 but scale down po-2, po-1, po-0
- sequance order to scale down and scaleup pods
- each pod will have its own dns (Ex: Mysql-o.mysql.namespace.svc.cluster.local )
kubedns for statefulset pod <podname>.<statefulsetName>.<NameSpace>.svc.cluster.local

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: statefulset-demo
spec:
replicas: 3
selector:
matchLabels:
app: statefulset-demo
serviceName: "statefulset-demo"
template:
metadata:
labels:
app: statefulset-demo
spec:
containers:
- name: apache2
image: httpd:2.4
ports:
- containerPort: 80
volumeClaimTemplates:
- metadata:
name: statefulset-demo-storage
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
Job
- job can create one or more pods and enasure to complete or backoflimit (6) try to restart pods
- Usecases:
- db migration
- data ingestions
- automation scrpits

apiVersion: batch/v1
kind: Job
metadata:
name: samplejob
labels:
env: dev
app: data-job
spec:
backoffLimit: 4
template:
spec:
containers:
- name: pi
image: perl:5.34.0
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
- name: demo-sleep
image: bitnami/os-shell
command: ["echo", "hello world"]
restartPolicy: Never
CronJOb:
- cronjob will schedule job based on cron time.
Sample cron expression

apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
Choosing the which workload
- POD ==> test/dev enviromnet
- Deploymnet ==> web app, apis, front-end , backend services
- Deamonset: monitoring, logs application, network plugin, routing …etc
- Statefulset: db, where pod need unique name and pvc
- Job: run the task or activity (automation and data injections)
- CRonjob: used schedule jobs (run job on specific time zone)
- Replicaset: which scale pods ==> Deployment Recommed
- Replicas-controller -old method for replicas set (scale pods).
Task:
- create different multiple templates for each workload
- deployment use NoP
- Statefulset use mysql db
- try access all application by port-farword cmd.