Kubernetes Knowledge Transfer Pack
1. Namespaces
Definition: Logical partitions in a cluster, used to separate environments or teams.
Commands:
kubectl get namespaces
kubectl create namespace dev-team
kubectl delete namespace dev-team
2. Pods
Definition: Smallest deployable unit in Kubernetes, wraps one or more containers.
Commands:
kubectl get pods
kubectl get pods --all-namespaces
kubectl describe pod <pod-name>
kubectl delete pod <pod-name>
3. Containers
Definition: Actual running processes inside pods (Docker/containerd images).
Commands:
kubectl logs <pod-name> -c <container-name>
kubectl exec -it <pod-name> -c <container-name> -- /bin/sh
4. Deployments
Definition: Controller that manages pods, scaling, and rolling updates.
Commands:
kubectl create deployment nginx-deploy --image=nginx
kubectl scale deployment nginx-deploy --replicas=5
kubectl get deployments
kubectl delete deployment nginx-deploy
5. Services
Definition: Provides stable networking to pods.
Types: ClusterIP, NodePort, LoadBalancer.
Commands:
kubectl expose deployment nginx-deploy --port=80 --target-port=80 --type=ClusterIP
kubectl get svc
kubectl delete svc nginx-deploy
6. ConfigMaps
Definition: Store non‑confidential configuration data.
Commands:
kubectl create configmap app-config --from-literal=ENV=prod
kubectl get configmaps
kubectl describe configmap app-config
7. Secrets
Definition: Store sensitive data (passwords, tokens).
Commands:
kubectl create secret generic db-secret --from-literal=DB_PASSWORD=banking123
kubectl get secrets
kubectl describe secret db-secret
8. Volumes & Storage
Definition: Persistent storage for pods.
Commands:
kubectl get pv
kubectl get pvc --all-namespaces
9. StatefulSets
Definition: Manage stateful apps (databases, Kafka).
Commands:
kubectl apply -f redis-statefulset.yaml
kubectl get statefulsets
10. DaemonSets
Definition: Ensures one pod runs on every node (logging, monitoring).
Commands:
kubectl get daemonsets -n kube-system
11. Jobs & CronJobs
Job: Runs pods until completion.
CronJob: Runs jobs on a schedule.
Commands:
kubectl create job pi --image=perl -- perl -Mbignum=bpi -wle 'print bpi(2000)'
kubectl get jobs
kubectl create cronjob hello --image=busybox --schedule="*/1 * * * *" -- echo "Hello World"
kubectl get cronjobs
12. Ingress
Definition: Manages external HTTP/HTTPS access to services.
Commands:
kubectl apply -f ingress.yaml
kubectl get ingress
🏗 Kubernetes Architecture
Control Plane Components
API Server → Entry point for all requests.
etcd → Cluster state database.
Controller Manager → Ensures desired state.
Scheduler → Assigns pods to nodes.
Node Components
Kubelet → Agent ensuring containers run.
Kube-proxy → Networking rules.
Container Runtime → Runs containers (Docker, containerd).
Add‑ons
CoreDNS → DNS service discovery.
CNI Plugin (Flannel/Calico) → Pod networking.
Metrics Server → Resource monitoring.
📊 Monitoring & Health Commands
kubectl get nodes -o wide
kubectl get pods --all-namespaces -w
kubectl get events --all-namespaces --sort-by=.metadata.creationTimestamp
kubectl top nodes
kubectl top pods
systemctl status kubelet
systemctl status containerd