Overview of K8s Workloads
- In Kubernetes we have objects which maintain Pods as part of their desired state
- Job
- CronJob
- DaemonSet
- ReplicaSet
- ReplicationController
- Deployment
- StatefulSet
Why ReplicaSet over ReplicationController?
- ReplicaSet is successor of Replication Controller and introducted some improvements
- More Expressive Selectors: In ReplicaSet both Set and Equalty Based Selectors can be used
- Rolling Updates and Rollbacks: ReplicaSets offer better support
- Scaling Behavior: RS offer more control over scaling behavior
- Detailed Status Conditions
Job
- This is a resource that manages execution of specific task or batch job. It ensure that the job completes successfully before considering it done.
- Job might create one or more pods to perform task
- Refer Here
CronJob
- This is to run a particular task on schedule
Deployment
- This resource manages the deployment and scaling of set of identical pods
- key features
- Replica Management
- Rolling Updates
- Roll backs
- History and Rollout status
- Deployment internally create replica set which inturn creates pods
- Sample
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
StatefulSets
- This resources is designed to manage deployment and scaling of stateful applications such as databases, distrbuted data stores.
- Unlike deployment which is designed for staleless applications, stateful set which is designed for Stateful applications has following features
- Stable Network Identity
- Ordered Deployment and Scaling
- Persistent Storage
- Headless Services
DaemonSet
- This resource ensures that copy of a specific pod runs on each or selected nodes with in cluster
- key features
- one pod per node
- node specific tasks
- Use cases:
- Deploying agents
- monitoring
- logging
- network proxies
- Deploying agents
Exercise
- Install kubernetes using kube-spray Refer Here
- Try installing a highly available k8s cluster using kubeadm Refer Here
