@xdev-asia/xdev-knowledge-mcp 1.0.43 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/content/pages/xoa-du-lieu-nguoi-dung.md +68 -0
  2. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/01-bai-1-data-repositories-ingestion.md +5 -0
  3. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/02-bai-2-data-transformation.md +5 -0
  4. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/01-phan-1-data-engineering/lessons/03-bai-3-data-analysis.md +159 -0
  5. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/02-phan-2-modeling/lessons/04-bai-4-sagemaker-built-in-algorithms.md +186 -0
  6. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/02-phan-2-modeling/lessons/05-bai-5-training-hyperparameter-tuning.md +159 -0
  7. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/02-phan-2-modeling/lessons/06-bai-6-model-evaluation.md +169 -0
  8. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/03-phan-3-implementation-operations/lessons/07-bai-7-model-deployment.md +193 -0
  9. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/03-phan-3-implementation-operations/lessons/08-bai-8-model-monitoring-mlops.md +184 -0
  10. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/03-phan-3-implementation-operations/lessons/09-bai-9-security-cost.md +166 -0
  11. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/04-phan-4-on-tap/lessons/10-bai-10-bai-toan-thuong-gap.md +181 -0
  12. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/04-phan-4-on-tap/lessons/11-bai-11-cheat-sheet.md +110 -0
  13. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/chapters/04-phan-4-on-tap/lessons/12-bai-12-chien-luoc-thi.md +113 -0
  14. package/content/series/luyen-thi/luyen-thi-aws-ml-specialty/index.md +1 -1
  15. package/content/series/luyen-thi/luyen-thi-cka/chapters/01-cluster-architecture/lessons/01-kien-truc-cka-kubeadm.md +133 -0
  16. package/content/series/luyen-thi/luyen-thi-cka/chapters/01-cluster-architecture/lessons/02-cluster-upgrade-kubeadm.md +147 -0
  17. package/content/series/luyen-thi/luyen-thi-cka/chapters/01-cluster-architecture/lessons/03-rbac-cka.md +152 -0
  18. package/content/series/luyen-thi/luyen-thi-cka/chapters/02-workloads-scheduling/lessons/04-deployments-daemonsets-statefulsets.md +186 -0
  19. package/content/series/luyen-thi/luyen-thi-cka/chapters/02-workloads-scheduling/lessons/05-scheduling-taints-affinity.md +163 -0
  20. package/content/series/luyen-thi/luyen-thi-cka/chapters/03-services-networking/lessons/06-services-endpoints-coredns.md +145 -0
  21. package/content/series/luyen-thi/luyen-thi-cka/chapters/03-services-networking/lessons/07-ingress-networkpolicies-cni.md +172 -0
  22. package/content/series/luyen-thi/luyen-thi-cka/chapters/04-storage/lessons/08-persistent-volumes-storageclass.md +159 -0
  23. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/09-etcd-backup-restore.md +149 -0
  24. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/10-troubleshooting-nodes.md +153 -0
  25. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/11-troubleshooting-workloads.md +146 -0
  26. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/12-troubleshooting-networking-exam.md +170 -0
  27. package/content/series/luyen-thi/luyen-thi-cka/index.md +217 -0
  28. package/content/series/luyen-thi/luyen-thi-ckad/chapters/01-app-design-build/lessons/01-multi-container-pods.md +146 -0
  29. package/content/series/luyen-thi/luyen-thi-ckad/chapters/01-app-design-build/lessons/02-jobs-cronjobs-resources.md +174 -0
  30. package/content/series/luyen-thi/luyen-thi-ckad/chapters/02-app-deployment/lessons/03-rolling-updates-rollbacks.md +148 -0
  31. package/content/series/luyen-thi/luyen-thi-ckad/chapters/02-app-deployment/lessons/04-helm-kustomize.md +181 -0
  32. package/content/series/luyen-thi/luyen-thi-ckad/chapters/03-app-observability/lessons/05-probes-logging-debugging.md +183 -0
  33. package/content/series/luyen-thi/luyen-thi-ckad/chapters/04-app-environment-config/lessons/06-configmaps-secrets.md +182 -0
  34. package/content/series/luyen-thi/luyen-thi-ckad/chapters/04-app-environment-config/lessons/07-securitycontext-pod-security.md +168 -0
  35. package/content/series/luyen-thi/luyen-thi-ckad/chapters/04-app-environment-config/lessons/08-resources-qos.md +168 -0
  36. package/content/series/luyen-thi/luyen-thi-ckad/chapters/05-services-networking/lessons/09-services-ingress.md +182 -0
  37. package/content/series/luyen-thi/luyen-thi-ckad/chapters/05-services-networking/lessons/10-networkpolicies-exam-strategy.md +236 -0
  38. package/content/series/luyen-thi/luyen-thi-ckad/index.md +199 -0
  39. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/01-phan-1-problem-framing/lessons/01-bai-1-framing-ml-problems.md +136 -0
  40. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/01-phan-1-problem-framing/lessons/02-bai-2-gcp-ai-ml-ecosystem.md +160 -0
  41. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/02-phan-2-data-engineering/lessons/03-bai-3-data-pipeline.md +174 -0
  42. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/02-phan-2-data-engineering/lessons/04-bai-4-feature-engineering.md +156 -0
  43. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/03-phan-3-model-development/lessons/05-bai-5-vertex-ai-training.md +155 -0
  44. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/03-phan-3-model-development/lessons/06-bai-6-bigquery-ml-tensorflow.md +141 -0
  45. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/04-phan-4-deployment-mlops/lessons/07-bai-7-model-deployment.md +134 -0
  46. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/04-phan-4-deployment-mlops/lessons/08-bai-8-vertex-ai-pipelines-mlops.md +149 -0
  47. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/05-phan-5-responsible-ai/lessons/09-bai-9-responsible-ai.md +128 -0
  48. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/chapters/05-phan-5-responsible-ai/lessons/10-bai-10-cheat-sheet-chien-luoc-thi.md +108 -0
  49. package/content/series/luyen-thi/luyen-thi-gcp-ml-engineer/index.md +1 -1
  50. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/01-kien-truc-kubernetes.md +137 -0
  51. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/02-pods-workloads-controllers.md +142 -0
  52. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/03-services-networking-storage.md +155 -0
  53. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/04-rbac-security.md +137 -0
  54. package/content/series/luyen-thi/luyen-thi-kcna/chapters/02-container-orchestration/lessons/05-container-runtimes-oci.md +137 -0
  55. package/content/series/luyen-thi/luyen-thi-kcna/chapters/02-container-orchestration/lessons/06-orchestration-patterns.md +147 -0
  56. package/content/series/luyen-thi/luyen-thi-kcna/chapters/03-cloud-native-architecture/lessons/07-cloud-native-architecture.md +143 -0
  57. package/content/series/luyen-thi/luyen-thi-kcna/chapters/04-observability-delivery/lessons/08-observability.md +143 -0
  58. package/content/series/luyen-thi/luyen-thi-kcna/chapters/04-observability-delivery/lessons/09-helm-gitops-cicd.md +162 -0
  59. package/content/series/luyen-thi/luyen-thi-kcna/index.md +168 -0
  60. package/data/quizzes.json +1059 -0
  61. package/package.json +1 -1
@@ -0,0 +1,148 @@
1
+ ---
2
+ id: ckad-d2-l03
3
+ title: 'Bài 3: Rolling Updates, Rollbacks & Deployment Strategies'
4
+ slug: 03-rolling-updates-rollbacks
5
+ description: >-
6
+ Deployment strategies: RollingUpdate vs Recreate. Kubectl rollout commands,
7
+ maxUnavailable/maxSurge. Revision history và rollback kỹ thuật cho CKAD.
8
+ duration_minutes: 55
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 3
12
+ section_title: "Domain 2: Application Deployment (20%)"
13
+ course:
14
+ id: lt-ckad-series-001
15
+ title: 'Luyện thi CKAD — Certified Kubernetes Application Developer'
16
+ slug: luyen-thi-ckad
17
+ ---
18
+
19
+ <img src="/storage/uploads/2026/04/k8s-cert-ckad-bai3-rolling-update.png" alt="Rolling Update và Rollback — maxUnavailable, maxSurge, ReplicaSet history" style="max-width: 800px; width: 100%; border-radius: 12px;" />
20
+
21
+ <h2 id="strategies">1. Deployment Strategies</h2>
22
+
23
+ <table>
24
+ <thead><tr><th>Strategy</th><th>Cách hoạt động</th><th>Downtime?</th><th>Khi dùng</th></tr></thead>
25
+ <tbody>
26
+ <tr><td><strong>RollingUpdate</strong></td><td>Replace pods dần dần, maintain availability</td><td>Không</td><td>Default, production</td></tr>
27
+ <tr><td><strong>Recreate</strong></td><td>Kill tất cả pods cũ, tạo mới</td><td>Có</td><td>Dev/test, breaking changes</td></tr>
28
+ </tbody>
29
+ </table>
30
+
31
+ <pre><code class="language-text">spec:
32
+ strategy:
33
+ type: RollingUpdate
34
+ rollingUpdate:
35
+ maxUnavailable: 1 # OR "25%" — Max pods unavailable during update
36
+ maxSurge: 1 # OR "25%" — Max extra pods above desired count
37
+
38
+ ┌─────────────────────────────────────────────────┐
39
+ │ Desired: 4 pods │
40
+ │ │
41
+ │ maxUnavailable: 1 → min 3 pods must be running │
42
+ │ maxSurge: 1 → max 5 pods total at once │
43
+ │ │
44
+ │ Step 1: Create 1 new pod (5 total = desired+surge)│
45
+ │ Step 2: Terminate 1 old pod (4 total) │
46
+ │ Step 3: Repeat until all replaced │
47
+ └─────────────────────────────────────────────────┘</code></pre>
48
+
49
+ <blockquote><p><strong>Exam tip:</strong> <code>maxUnavailable</code> và <code>maxSurge</code> KHÔNG thể cùng lúc là 0. Nếu cần zero-downtime update: set <code>maxUnavailable: 0</code> và <code>maxSurge: 1</code> (hoặc cao hơn).</p></blockquote>
50
+
51
+ <h2 id="rollout">2. kubectl rollout Commands</h2>
52
+
53
+ <pre><code class="language-text"># Xem trạng thái rollout
54
+ kubectl rollout status deployment/myapp
55
+
56
+ # Xem revision history
57
+ kubectl rollout history deployment/myapp
58
+ kubectl rollout history deployment/myapp --revision=2
59
+
60
+ # Rollback về version trước
61
+ kubectl rollout undo deployment/myapp
62
+
63
+ # Rollback về revision cụ thể
64
+ kubectl rollout undo deployment/myapp --to-revision=2
65
+
66
+ # Tạm dừng rollout
67
+ kubectl rollout pause deployment/myapp
68
+
69
+ # Resume rollout
70
+ kubectl rollout resume deployment/myapp</code></pre>
71
+
72
+ <table>
73
+ <thead><tr><th>Command</th><th>Tác dụng</th></tr></thead>
74
+ <tbody>
75
+ <tr><td><code>rollout status</code></td><td>Wait/show current rollout progress</td></tr>
76
+ <tr><td><code>rollout history</code></td><td>List revision history</td></tr>
77
+ <tr><td><code>rollout undo</code></td><td>Rollback to previous (or specific) revision</td></tr>
78
+ <tr><td><code>rollout pause/resume</code></td><td>Pause để canary test, rồi resume</td></tr>
79
+ <tr><td><code>rollout restart</code></td><td>Force restart tất cả pods (rolling)</td></tr>
80
+ </tbody>
81
+ </table>
82
+
83
+ <blockquote><p><strong>Exam tip:</strong> Để lưu <code>CHANGE-CAUSE</code> trong revision history, thêm annotation: <code>kubectl annotate deployment/myapp kubernetes.io/change-cause="Updated image to v2"</code> TRƯỚC khi update. Hoặc dùng <code>--record</code> flag (deprecated nhưng vẫn hoạt động trong exam).</p></blockquote>
84
+
85
+ <h2 id="trigger">3. Trigger & Monitor Update</h2>
86
+
87
+ <pre><code class="language-text"># Update image (trigger rolling update)
88
+ kubectl set image deployment/myapp container-name=nginx:1.25
89
+
90
+ # Xem ReplicaSet history (mỗi update tạo mới 1 RS)
91
+ kubectl get rs
92
+ # NAME DESIRED CURRENT READY
93
+ # myapp-7d9b8c 4 4 4 ← current
94
+ # myapp-6f5a2b 0 0 0 ← old (kept for rollback)
95
+
96
+ # Scale deployment
97
+ kubectl scale deployment/myapp --replicas=6
98
+
99
+ # Edit deployment trực tiếp
100
+ kubectl edit deployment/myapp</code></pre>
101
+
102
+ <h2 id="revisionhistory">4. Revision History Limit</h2>
103
+
104
+ <pre><code class="language-text">spec:
105
+ revisionHistoryLimit: 10 # Default: 10 old RS kept for rollback
106
+ # Set to 0 to disable rollback capability</code></pre>
107
+
108
+ <h2 id="cheatsheet">5. Cheat Sheet</h2>
109
+
110
+ <table>
111
+ <thead><tr><th>Tình huống exam</th><th>Command</th></tr></thead>
112
+ <tbody>
113
+ <tr><td>Update image</td><td><code>kubectl set image deploy/app c=image:v2</code></td></tr>
114
+ <tr><td>Check rollout</td><td><code>kubectl rollout status deploy/app</code></td></tr>
115
+ <tr><td>Rollback nhanh</td><td><code>kubectl rollout undo deploy/app</code></td></tr>
116
+ <tr><td>Rollback về rev 3</td><td><code>kubectl rollout undo deploy/app --to-revision=3</code></td></tr>
117
+ <tr><td>Zero-downtime config</td><td><code>maxUnavailable: 0, maxSurge: 1</code></td></tr>
118
+ </tbody>
119
+ </table>
120
+
121
+ <h2 id="practice">6. Practice Questions</h2>
122
+
123
+ <p><strong>Q1:</strong> A Deployment with 10 replicas is configured with maxUnavailable: 2 and maxSurge: 3. During a rolling update, what is the maximum number of pods that can exist at any given time?</p>
124
+ <ul>
125
+ <li>A) 10</li>
126
+ <li>B) 12</li>
127
+ <li>C) 13 ✓</li>
128
+ <li>D) 15</li>
129
+ </ul>
130
+ <p><em>Explanation: maxSurge=3 means up to 3 extra pods above the desired count (10) can exist simultaneously. So maximum = 10 + 3 = 13 pods. Meanwhile, maxUnavailable=2 means at least 8 pods must be available.</em></p>
131
+
132
+ <p><strong>Q2:</strong> You updated a Deployment and then realized the new version has a bug. Which command quickly reverts to the previous working version?</p>
133
+ <ul>
134
+ <li>A) <code>kubectl delete deployment myapp && kubectl apply -f old.yaml</code></li>
135
+ <li>B) <code>kubectl rollout undo deployment/myapp</code> ✓</li>
136
+ <li>C) <code>kubectl rollout history deployment/myapp</code></li>
137
+ <li>D) <code>kubectl set image deployment/myapp container=old-image</code></li>
138
+ </ul>
139
+ <p><em>Explanation: rollout undo is the fastest way to revert to the previous revision. It creates a new rolling update back to the previous ReplicaSet. Option D also works but requires knowing the exact old image name.</em></p>
140
+
141
+ <p><strong>Q3:</strong> A Deployment uses Recreate strategy. What is the expected behavior during an update?</p>
142
+ <ul>
143
+ <li>A) Pods are replaced one at a time with no downtime</li>
144
+ <li>B) All existing pods are terminated before new pods are created, causing downtime ✓</li>
145
+ <li>C) Half the pods are updated at once while the other half serve traffic</li>
146
+ <li>D) New pods are created first, then old pods are terminated</li>
147
+ </ul>
148
+ <p><em>Explanation: Recreate strategy terminates ALL existing pods at once (scale to 0), then creates the new pods. This causes downtime but ensures no two versions run simultaneously — suitable when old and new versions cannot coexist.</em></p>
@@ -0,0 +1,181 @@
1
+ ---
2
+ id: ckad-d2-l04
3
+ title: 'Bài 4: Helm & Kustomize'
4
+ slug: 04-helm-kustomize
5
+ description: >-
6
+ Helm charts, releases, values.yaml và upgrade/rollback workflow. Kustomize
7
+ overlays và bases. Phân biệt khi nào dùng Helm vs Kustomize cho CKAD.
8
+ duration_minutes: 50
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 4
12
+ section_title: "Domain 2: Application Deployment (20%)"
13
+ course:
14
+ id: lt-ckad-series-001
15
+ title: 'Luyện thi CKAD — Certified Kubernetes Application Developer'
16
+ slug: luyen-thi-ckad
17
+ ---
18
+
19
+ <img src="/storage/uploads/2026/04/k8s-cert-ckad-bai4-helm-kustomize.png" alt="Helm vs Kustomize — Chart structure, template engine, overlays" style="max-width: 800px; width: 100%; border-radius: 12px;" />
20
+
21
+ <h2 id="helm-concepts">1. Helm Core Concepts</h2>
22
+
23
+ <p><strong>Helm</strong> là Kubernetes package manager. Nó đóng gói các Kubernetes manifests vào <strong>Charts</strong> và quản lý deployments dưới dạng <strong>Releases</strong>.</p>
24
+
25
+ <pre><code class="language-text">Helm Architecture:
26
+
27
+ values.yaml Chart templates
28
+ │ │
29
+ ▼ ▼
30
+ ┌──────────────────────────────┐
31
+ │ Helm Template Engine │
32
+ │ Renders YAML manifests │
33
+ └──────────────┬───────────────┘
34
+
35
+ ▼ kubectl apply
36
+ Kubernetes Cluster
37
+ (stored as Release)</code></pre>
38
+
39
+ <table>
40
+ <thead><tr><th>Term</th><th>Định nghĩa</th></tr></thead>
41
+ <tbody>
42
+ <tr><td><strong>Chart</strong></td><td>Package của Helm — bao gồm templates + default values</td></tr>
43
+ <tr><td><strong>Release</strong></td><td>Instance của Chart đã được deploy lên cluster</td></tr>
44
+ <tr><td><strong>Repository</strong></td><td>Nơi lưu trữ Charts (như artifact hub, bitnami)</td></tr>
45
+ <tr><td><strong>Values</strong></td><td>Configuration parameters để customize Chart</td></tr>
46
+ <tr><td><strong>Revision</strong></td><td>Mỗi install/upgrade tạo ra một revision mới</td></tr>
47
+ </tbody>
48
+ </table>
49
+
50
+ <h2 id="helm-commands">2. Helm Commands</h2>
51
+
52
+ <pre><code class="language-text"># Add repository
53
+ helm repo add bitnami https://charts.bitnami.com/bitnami
54
+ helm repo update
55
+
56
+ # Search charts
57
+ helm search repo bitnami/nginx
58
+ helm search hub wordpress
59
+
60
+ # Install chart
61
+ helm install my-release bitnami/nginx
62
+ helm install my-release bitnami/nginx --values custom-values.yaml
63
+ helm install my-release bitnami/nginx --set image.tag=1.25
64
+
65
+ # List releases
66
+ helm list
67
+ helm list -n production
68
+
69
+ # Upgrade release
70
+ helm upgrade my-release bitnami/nginx --set replicaCount=3
71
+
72
+ # Rollback to previous revision
73
+ helm rollback my-release 1 # rollback to revision 1
74
+ helm rollback my-release # rollback to previous revision
75
+
76
+ # Uninstall
77
+ helm uninstall my-release
78
+
79
+ # View rendered templates (dry-run)
80
+ helm template my-release bitnami/nginx
81
+ helm install my-release bitnami/nginx --dry-run</code></pre>
82
+
83
+ <blockquote><p><strong>Exam tip:</strong> CKAD thường test <code>helm install</code> với flag <code>--set</code> (override values trực tiếp) và <code>--values file.yaml</code> (override từ file). Cũng test <code>helm upgrade</code> và <code>helm rollback</code>. Nhớ rằng <code>--set</code> override trumps <code>--values</code> file.</p></blockquote>
84
+
85
+ <h2 id="kustomize">3. Kustomize</h2>
86
+
87
+ <p><strong>Kustomize</strong> là tool built vào kubectl cho phép customize Kubernetes manifests mà không cần templates hoặc parameters. Dùng overlay pattern.</p>
88
+
89
+ <pre><code class="language-text">Kustomize Structure:
90
+ base/
91
+ ├── kustomization.yaml # Base kustomization
92
+ ├── deployment.yaml
93
+ └── service.yaml
94
+
95
+ overlays/
96
+ ├── development/
97
+ │ ├── kustomization.yaml # Patches for dev
98
+ │ └── replica-patch.yaml
99
+ └── production/
100
+ ├── kustomization.yaml # Patches for prod
101
+ └── replica-patch.yaml</code></pre>
102
+
103
+ <pre><code class="language-text"># base/kustomization.yaml
104
+ apiVersion: kustomize.config.k8s.io/v1beta1
105
+ kind: Kustomization
106
+ resources:
107
+ - deployment.yaml
108
+ - service.yaml
109
+
110
+ # overlays/production/kustomization.yaml
111
+ apiVersion: kustomize.config.k8s.io/v1beta1
112
+ kind: Kustomization
113
+ bases:
114
+ - ../../base
115
+ patches:
116
+ - path: replica-patch.yaml
117
+ images:
118
+ - name: myapp
119
+ newTag: "2.0"</code></pre>
120
+
121
+ <pre><code class="language-text"># Apply với kustomize
122
+ kubectl apply -k overlays/production/
123
+
124
+ # Preview rendered output
125
+ kubectl kustomize overlays/production/</code></pre>
126
+
127
+ <h2 id="comparison">4. Helm vs Kustomize</h2>
128
+
129
+ <table>
130
+ <thead><tr><th>Tiêu chí</th><th>Helm</th><th>Kustomize</th></tr></thead>
131
+ <tbody>
132
+ <tr><td>Approach</td><td>Template-based (Go templates)</td><td>Overlay/patching (plain YAML)</td></tr>
133
+ <tr><td>Learning curve</td><td>Cao hơn (template syntax)</td><td>Thấp hơn (YAML patches)</td></tr>
134
+ <tr><td>Package mgmt</td><td>Có (charts, repos, versioning)</td><td>Không</td></tr>
135
+ <tr><td>Release history</td><td>Có (upgrade/rollback)</td><td>Không built-in</td></tr>
136
+ <tr><td>Built into kubectl</td><td>Không (separate binary)</td><td>Có (<code>kubectl apply -k</code>)</td></tr>
137
+ <tr><td>Best for</td><td>Phân phối (distribute) apps</td><td>Env-specific customization</td></tr>
138
+ </tbody>
139
+ </table>
140
+
141
+ <h2 id="cheatsheet">5. Cheat Sheet</h2>
142
+
143
+ <table>
144
+ <thead><tr><th>Task</th><th>Command</th></tr></thead>
145
+ <tbody>
146
+ <tr><td>Install chart với custom values</td><td><code>helm install rel chart --values f.yaml</code></td></tr>
147
+ <tr><td>Override một value</td><td><code>helm install rel chart --set key=val</code></td></tr>
148
+ <tr><td>Rollback Helm release</td><td><code>helm rollback release-name 2</code></td></tr>
149
+ <tr><td>Apply kustomize overlay</td><td><code>kubectl apply -k overlays/prod/</code></td></tr>
150
+ <tr><td>Preview kustomize output</td><td><code>kubectl kustomize overlays/prod/</code></td></tr>
151
+ </tbody>
152
+ </table>
153
+
154
+ <h2 id="practice">6. Practice Questions</h2>
155
+
156
+ <p><strong>Q1:</strong> You need to deploy a Helm chart from the "stable" repo with a custom replica count of 5. Which command accomplishes this?</p>
157
+ <ul>
158
+ <li>A) <code>helm deploy myapp stable/nginx --replicas=5</code></li>
159
+ <li>B) <code>helm install myapp stable/nginx --set replicaCount=5</code> ✓</li>
160
+ <li>C) <code>helm install myapp stable/nginx -e replicaCount=5</code></li>
161
+ <li>D) <code>helm apply myapp stable/nginx --values replicaCount=5</code></li>
162
+ </ul>
163
+ <p><em>Explanation: helm install uses --set flag to override values. The syntax is --set key=value. The exact key name (replicaCount) depends on the chart's values.yaml, but --set is the correct flag for inline value overrides.</em></p>
164
+
165
+ <p><strong>Q2:</strong> A team uses Kustomize with a base configuration and production/staging overlays. Which command applies the production overlay?</p>
166
+ <ul>
167
+ <li>A) <code>kubectl apply -f overlays/production/</code></li>
168
+ <li>B) <code>kubectl kustomize overlays/production/ | kubectl apply -f -</code></li>
169
+ <li>C) <code>kubectl apply -k overlays/production/</code> ✓</li>
170
+ <li>D) <code>kustomize apply overlays/production/</code></li>
171
+ </ul>
172
+ <p><em>Explanation: kubectl apply -k (note -k not -f) is the built-in way to apply a kustomization directory. Option B also works but is more verbose. The -k flag tells kubectl to process the directory as a Kustomize configuration.</em></p>
173
+
174
+ <p><strong>Q3:</strong> After a Helm upgrade introduces a bug, you need to revert to the previous working state. What is the correct approach?</p>
175
+ <ul>
176
+ <li>A) kubectl rollout undo deployment/myapp</li>
177
+ <li>B) helm install --replace myapp stable/nginx</li>
178
+ <li>C) helm rollback myapp ✓</li>
179
+ <li>D) helm upgrade myapp --version=previous</li>
180
+ </ul>
181
+ <p><em>Explanation: helm rollback reverts a release to a previous revision. Without specifying a revision number, it rolls back to the previous one. This undoes all the changes made by the failed upgrade, including ConfigMaps, Secrets, and other resources managed by the chart.</em></p>
@@ -0,0 +1,183 @@
1
+ ---
2
+ id: ckad-d3-l05
3
+ title: 'Bài 5: Probes, Logging & Debugging'
4
+ slug: 05-probes-logging-debugging
5
+ description: >-
6
+ Liveness, Readiness và Startup Probes với các probe types (httpGet, tcpSocket,
7
+ exec). Kubectl logs, exec, debug và port-forward cho CKAD troubleshooting.
8
+ duration_minutes: 55
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 5
12
+ section_title: "Domain 3: Application Observability and Maintenance (15%)"
13
+ course:
14
+ id: lt-ckad-series-001
15
+ title: 'Luyện thi CKAD — Certified Kubernetes Application Developer'
16
+ slug: luyen-thi-ckad
17
+ ---
18
+
19
+ <img src="/storage/uploads/2026/04/k8s-cert-ckad-bai5-probes.png" alt="Liveness, Readiness và Startup Probes — timeline và probe methods" style="max-width: 800px; width: 100%; border-radius: 12px;" />
20
+
21
+ <h2 id="probe-types">1. Ba loại Probe</h2>
22
+
23
+ <table>
24
+ <thead><tr><th>Probe</th><th>Mục đích</th><th>Khi fail?</th></tr></thead>
25
+ <tbody>
26
+ <tr><td><strong>Liveness</strong></td><td>Container có còn "sống" không?</td><td>Container bị restart</td></tr>
27
+ <tr><td><strong>Readiness</strong></td><td>Container có sẵn sàng nhận traffic?</td><td>Removed from Service endpoints (không restart)</td></tr>
28
+ <tr><td><strong>Startup</strong></td><td>App đã khởi động xong chưa?</td><td>Container bị restart (dùng trước liveness check)</td></tr>
29
+ </tbody>
30
+ </table>
31
+
32
+ <pre><code class="language-text">Probe execution timeline:
33
+
34
+ Container starts
35
+
36
+
37
+ startupProbe checks (periodically)
38
+ │ success
39
+
40
+ Both livenessProbe & readinessProbe run in parallel
41
+ │ │
42
+ ▼ fail ▼ fail
43
+ Container restart Removed from Service
44
+ (pod still running)</code></pre>
45
+
46
+ <h2 id="probe-methods">2. Probe Methods (httpGet, tcpSocket, exec)</h2>
47
+
48
+ <pre><code class="language-text">livenessProbe:
49
+ httpGet: # HTTP GET — success if status 200-399
50
+ path: /healthz
51
+ port: 8080
52
+ httpHeaders:
53
+ - name: Custom-Header
54
+ value: Awesome
55
+ initialDelaySeconds: 15 # Wait before first probe
56
+ periodSeconds: 20 # How often to probe
57
+ timeoutSeconds: 5 # Timeout per probe
58
+ failureThreshold: 3 # Fail count before action
59
+ successThreshold: 1 # Success count to pass
60
+
61
+ readinessProbe:
62
+ tcpSocket: # TCP connection — success if port open
63
+ port: 3306
64
+ initialDelaySeconds: 5
65
+ periodSeconds: 10
66
+
67
+ startupProbe:
68
+ exec: # Run command in container — success if exit 0
69
+ command:
70
+ - cat
71
+ - /tmp/healthy
72
+ failureThreshold: 30 # Allows 30*10s = 5 min to start
73
+ periodSeconds: 10</code></pre>
74
+
75
+ <table>
76
+ <thead><tr><th>Field</th><th>Default</th><th>Ý nghĩa</th></tr></thead>
77
+ <tbody>
78
+ <tr><td><code>initialDelaySeconds</code></td><td>0</td><td>Chờ trước khi probe đầu tiên</td></tr>
79
+ <tr><td><code>periodSeconds</code></td><td>10</td><td>Interval giữa các probes</td></tr>
80
+ <tr><td><code>timeoutSeconds</code></td><td>1</td><td>Timeout của mỗi probe</td></tr>
81
+ <tr><td><code>failureThreshold</code></td><td>3</td><td>Fail bao nhiêu lần thì action</td></tr>
82
+ <tr><td><code>successThreshold</code></td><td>1</td><td>Pass bao nhiêu lần để "healthy"</td></tr>
83
+ </tbody>
84
+ </table>
85
+
86
+ <blockquote><p><strong>Exam tip:</strong> <strong>Startup probe</strong> dùng khi app khởi động lâu (ví dụ: legacy app cần 2 phút load). Set <code>failureThreshold * periodSeconds</code> &gt;= thời gian startup tối đa. Liveness probe không chạy cho đến khi startup probe pass.</p></blockquote>
87
+
88
+ <h2 id="logging">3. Logging & kubectl logs</h2>
89
+
90
+ <pre><code class="language-text"># Xem logs của pod
91
+ kubectl logs podname
92
+
93
+ # Follow logs (tail -f)
94
+ kubectl logs -f podname
95
+
96
+ # Previous container (nếu bị crash)
97
+ kubectl logs podname --previous
98
+
99
+ # Logs của specific container trong multi-container pod
100
+ kubectl logs podname -c container-name
101
+
102
+ # Logs với timestamp
103
+ kubectl logs podname --timestamps
104
+
105
+ # Tail N lines
106
+ kubectl logs podname --tail=100</code></pre>
107
+
108
+ <h2 id="debugging">4. Debugging Commands</h2>
109
+
110
+ <pre><code class="language-text"># Exec vào container
111
+ kubectl exec -it podname -- /bin/bash
112
+ kubectl exec -it podname -c container-name -- sh
113
+
114
+ # Port forward để test service locally
115
+ kubectl port-forward pod/podname 8080:80
116
+ kubectl port-forward service/myservice 8080:80
117
+
118
+ # Ephemeral debug container (khi container không có shell)
119
+ kubectl debug -it podname --image=busybox --target=container-name
120
+
121
+ # Debug a node
122
+ kubectl debug node/worker-1 -it --image=ubuntu
123
+
124
+ # Copy files
125
+ kubectl cp podname:/app/logs/error.log ./error.log
126
+ kubectl cp ./config.yaml podname:/app/config.yaml</code></pre>
127
+
128
+ <blockquote><p><strong>Exam tip:</strong> Khi pod không có shell (distroless image), dùng <code>kubectl debug</code> với ephemeral container. Trong CKAD exam, <code>kubectl exec</code> + <code>kubectl logs</code> là 2 commands debugging quan trọng nhất. Luôn check logs trước khi exec.</p></blockquote>
129
+
130
+ <h2 id="pod-states">5. Common Pod States & Debug</h2>
131
+
132
+ <table>
133
+ <thead><tr><th>Pod State</th><th>Nguyên nhân thường gặp</th><th>Debug command</th></tr></thead>
134
+ <tbody>
135
+ <tr><td><code>CrashLoopBackOff</code></td><td>App crash, bad command, missing config</td><td><code>kubectl logs --previous</code></td></tr>
136
+ <tr><td><code>ImagePullBackOff</code></td><td>Wrong image name, registry auth failure</td><td><code>kubectl describe pod</code></td></tr>
137
+ <tr><td><code>Pending</code></td><td>Insufficient resources, unschedulable</td><td><code>kubectl describe pod</code> → Events</td></tr>
138
+ <tr><td><code>OOMKilled</code></td><td>Memory limit exceeded</td><td><code>kubectl describe pod</code> → Last State</td></tr>
139
+ <tr><td><code>Error</code></td><td>Init container failed, bad entrypoint</td><td><code>kubectl logs -c init-c</code></td></tr>
140
+ </tbody>
141
+ </table>
142
+
143
+ <h2 id="cheatsheet">6. Cheat Sheet</h2>
144
+
145
+ <table>
146
+ <thead><tr><th>Task</th><th>Command</th></tr></thead>
147
+ <tbody>
148
+ <tr><td>Check pod sức khỏe</td><td><code>kubectl describe pod &lt;name&gt;</code></td></tr>
149
+ <tr><td>Xem logs crash</td><td><code>kubectl logs &lt;pod&gt; --previous</code></td></tr>
150
+ <tr><td>Shell vào container</td><td><code>kubectl exec -it &lt;pod&gt; -- sh</code></td></tr>
151
+ <tr><td>Test service connectivity</td><td><code>kubectl port-forward svc/&lt;name&gt; 8080:80</code></td></tr>
152
+ <tr><td>Debug distroless container</td><td><code>kubectl debug -it &lt;pod&gt; --image=busybox</code></td></tr>
153
+ </tbody>
154
+ </table>
155
+
156
+ <h2 id="practice">7. Practice Questions</h2>
157
+
158
+ <p><strong>Q1:</strong> A Pod's readinessProbe fails, but the livenessProbe passes. What happens to the Pod?</p>
159
+ <ul>
160
+ <li>A) The Pod is restarted</li>
161
+ <li>B) The Pod is deleted</li>
162
+ <li>C) The Pod remains running but is removed from the Service's endpoint list ✓</li>
163
+ <li>D) The Pod is marked as Failed</li>
164
+ </ul>
165
+ <p><em>Explanation: Readiness probe failure does NOT restart the container. It only removes the Pod from the Service endpoints so no new traffic is routed to it. The Pod keeps running. When the readiness probe passes again, the Pod is re-added to the endpoints.</em></p>
166
+
167
+ <p><strong>Q2:</strong> An application takes 3 minutes to start. Without a startupProbe, the livenessProbe with failureThreshold: 3 and periodSeconds: 10 would kill the container before it finishes starting. How should you configure a startupProbe to allow up to 5 minutes for startup?</p>
168
+ <ul>
169
+ <li>A) startupProbe with failureThreshold: 5 and periodSeconds: 60</li>
170
+ <li>B) startupProbe with failureThreshold: 30 and periodSeconds: 10 ✓</li>
171
+ <li>C) startupProbe with failureThreshold: 300 and periodSeconds: 1</li>
172
+ <li>D) startupProbe with initialDelaySeconds: 300</li>
173
+ </ul>
174
+ <p><em>Explanation: failureThreshold × periodSeconds = maximum startup time. 30 × 10s = 300s = 5 minutes. During this window, the liveness probe is disabled. Once the startup probe succeeds, both liveness and readiness probes activate.</em></p>
175
+
176
+ <p><strong>Q3:</strong> You need to debug a running Pod that uses a distroless container image (no shell available). How do you get a shell for debugging?</p>
177
+ <ul>
178
+ <li>A) kubectl exec -it podname -- /bin/sh</li>
179
+ <li>B) kubectl attach podname -it</li>
180
+ <li>C) kubectl debug -it podname --image=busybox --target=app ✓</li>
181
+ <li>D) kubectl run debug --image=busybox --attach</li>
182
+ </ul>
183
+ <p><em>Explanation: kubectl debug with an ephemeral container injects a debug container (busybox) into the running Pod with access to the same process namespace. The --target flag shares the process namespace with the specified container. This works even when the main container has no shell.</em></p>