Youssef
Samir
Projects
About me
Cheatsheets
Get in touch
Kubernetes
A reference guide for Kubernetes commands and concepts to efficiently manage and scale containerized applications.
Context
: A group of access parameters to a Kubernetes cluster
Cluster
Nodes
: Physical or virtual machines
Master node/control plane
Worker nodes
Contains:
Container runtime
Kubelet: Manages the pod lifecycle
Kube-proxy: Manages network rules
Pods
User
Namespace
: Group resources (e.g., Dev, Test, Prod)
Pods
: Smallest deployable units
Encapsulate containers
Can run multiple containers
States:
Pending
Running
Succeeded
Failed
Unknown
CrashLoopBackOff
Labels
: Key-value pairs for identifying resources
Selectors
: Filter or select objects using labels
Services
: Provide stable IP addresses
Containers
: Share IP and storage within a pod
Workloads
: Application running on Kubernetes
Pod
ReplicaSet
: Manages pod replicas
Deployment
: Manages pod templates
StatefulSet
: For stateful applications
DaemonSet
: Ensures pods on all nodes
Job
: Short-lived tasks
CronJob
: Scheduled tasks
Deployments
Replicas
: Number of pod instances
Strategy
RollingUpdate
Recreate
StatefulSet
: For stateful applications (e.g., databases)
Services
ClusterIP
: Internal visibility
NodePort
: External visibility
LoadBalancer
: External load balancing
Ingress
: Advanced routing
Volumes
Persistent Volume
Persistent Volume Claim
Reclaim Policies
: Delete, Retain
Access Modes
ReadOnlyMany
ReadWriteMany
ReadWriteOnce
Persistent Volume States
Available
Bound
Released
Failed
ConfigMaps
: Externalize configuration
Horizontal Pod Autoscaling
Requires metrics server
Scale based on metrics
kubectl
Commands
config
current-context
: Get current context
get-contexts
: List all contexts
use-context
context name
: Set current context
set-context --current --namespace=
namespace name
delete-context
context name
rename-context
old-name
new-name
create
deployment
name
--image=
image name
: Imperative way
-f
yaml file
: Declarative way
ns
namespace name
delete
all --all
: Delete all pods
deployment
name
ns
namespace name
pod
podname
-f
pod-definition.yaml
rs
rs name
ds
ds name
sts
sts name
job
job name
cj
job name
svc
service name
pv
pv name
pvc
pvc name
hpa
hpa name
get
namespaces or ns
: List namespaces
pods -o wide
nodes
ep
service name
: Service endpoint IP
rs
: List ReplicaSets
ds
: List DaemonSets
sts
: List StatefulSets
pvc
: Persistent volume claims
job
node
node name
pod
pod name
rs
rs name
ds
ds name
cj
svc -o wide
nodes -o wide
: Node IP addresses
pv
pvc
cm
: ConfigMap
hpa
hpa name
exec
-it
podname
-- sh
: Interactive shell
run
podname
--image=
image name
logs
podname
rollout
status
: Update progress
history deployment
name
: Deployment history
undo
name
: Rollback deployment
describe
svc
service name
pv
pv name
pvc
pvc name
scale
resource-type
/
resource-name
--replicas=
number