Abdullah Şamil Güser

Workloads

A workload is an application running on Kubernetes

ReplicaSets

Self-healing : : If a pod fails, the ReplicaSet will create a new pod to replace it

ReplicaSet vs Deployment : While you can create ReplicaSets, the recommended way is to create Deployments because they provide extra functionalities on top of ReplicaSets. So why bother and learn about ReplicaSets? Well, in the Deployment lecture, you’ll see that when you create a Deployment, that will also create a ReplicaSet in the background. That’s why it’s important to learn about the ReplicaSet’s functionalities.

kubectl - ReplicaSets Cheat Sheet

# Create a ReplicaSet
kubectl apply -f 013_workloads/replicaset-definition.yaml

# List ReplicaSets
kubectl get rs

# Get info
kubectl describe rs myapp-replicaset

# Delete a ReplicaSet
kubectl delete -f 013_workloads/replicaset-definition.yaml

# Same but using the ReplicaSet name
kubectl delete rs myapp-replicaset

Deployments

# Pods vs Deployments

- Pods don't
  - Self-heal
  - Scale
  - Updates
  - Rollback
- Deployments can!

Deployment

Definition

kubectl - Deployments Cheat Sheet

# The imperative way
kubectl create deployment [deployment-name] --image=[image-name] --replicas=[number-of-replicas] --port=[port-number]

# Create a Deployment
kubectl apply -f [definition.yaml]

# List Deployments
kubectl get deploy

# Get info
kubectl describe deploy [deployment-name]

# List ReplicaSets
kubectl get rs

# Delete a Deployment
kubectl delete -f [definition.yaml]

# Same but using the deployment name
kubectl delete deploy [deployment-name]

DaemonSet

kubectl - DaemonSet Cheat Sheet

kubectl apply -f [definition.yaml] - Create a DaemonSet kubectl get ds - List DaemonSets kubectl describe ds [rsName] - Get info kubectl delete -f [definition.yaml] - Delete a DaemonSet kubectl delete ds [rsName] - Same but using the DaemonSet name

# Create a DaemonSet
kubectl apply -f [definition.yaml]

# List DaemonSets
kubectl get ds

# Get info
kubectl describe ds [rsName]

# Delete a DaemonSet
kubectl delete -f [definition.yaml]

# Same but using the DaemonSet name
kubectl delete ds [rsName]

StatefulSet

Notes

kubectl - StatefulSet Cheat Sheet

# Create a StatefulSet
kubectl apply -f [definition.yaml]

# List StatefulSets
kubectl get sts

# Get info
kubectl describe sts [rsName]

# Delete a StatefulSet
kubectl delete -f [definition.yaml]

# Same but using the StatefulSet name
kubectl delete sts [rsName]

Job

kubectl - Job Cheat Sheet

# The imperative way
kubectl create job [jobName] --image=busybox

# Create a Job
kubectl apply -f [definition.yaml]

# List jobs
kubectl get job

# Get info
kubectl describe job [jobName]

# Delete a job
kubectl delete -f [definition.yaml]

# Same but using the Job name
kubectl delete job [jobName]

CronJob

kubectl - CronJob Cheat Sheet

kubectl create cronjob [jobName] –image=busybox –schedule=”*/1 * * * *” - The imperative way kubectl apply -f [definition.yaml] - Create a CronJob kubectl get cj - List CronJobs kubectl describe cj [jobName] - Get info kubectl delete -f [definition.yaml] - Delete a CronJob kubectl delete cj [jobName] - Same but using the CronJob name

# The imperative way
kubectl create cronjob [jobName] --image=busybox --schedule="*/1 * * * *"

# Create a CronJob
kubectl apply -f [definition.yaml]

# List CronJobs
kubectl get cj

# Get info
kubectl describe cj [jobName]

# Delete a CronJob
kubectl delete -f [definition.yaml]

# Same but using the CronJob name
kubectl delete cj [jobName]