Home

CKA Quick Review Notes

https://kubernetes.io/docs/concepts/services-networking/service/

Deployment with Startup Delay

When a Pod must wait before the main application starts, use an initContainer.

spec:
  initContainers:
  - name: init-deploy
    image: busybox
    command:
    - sleep
    - "30"

  containers:
  - name: nginx
    image: nginx
Pod starts → Init Container runs → sleep 30 → Init Container exits → nginx starts.

Persistent Volume (HostPath)

CKA Mental Model:

PersistentVolume
├─ capacity
├─ accessModes
└─ hostPath

Example:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: lab154
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /lab154
Remember:
Don't confuse PV syntax with Pod syntax.
Incorrect:
spec:
  volumes:
Correct:
spec:
  hostPath:
    path: /lab154

NodePort Service

Task Example:

Create a deployment running nginx that can be accessed externally on port 32567 on every cluster node.

Creation workflow:

kubectl create deployment lab155deploy --image=nginx
kubectl scale deployment lab155deploy --replicas=3

Create Service:

kubectl expose deployment lab155deploy \
  --type=NodePort \
  --port=80

Edit service YAML and specify:

spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    nodePort: 32567
Think:

External User ↓
NodePort (32567) ↓
Service Port (80) ↓
Container Port (80)

Useful Exam Commands

kubectl explain pv.spec

kubectl explain deployment.spec.template.spec

kubectl explain deployment.spec.template.spec.initContainers

kubectl get pv

kubectl get svc

kubectl describe pv lab154

kubectl describe svc lab155deploy

Exam Strategy

A valid resource accepted by Kubernetes is worth more than a perfectly memorized YAML.