@xdev-asia/xdev-knowledge-mcp 1.0.44 → 1.0.46

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 (36) hide show
  1. package/content/series/luyen-thi/luyen-thi-cka/chapters/01-cluster-architecture/lessons/01-kien-truc-cka-kubeadm.md +133 -0
  2. package/content/series/luyen-thi/luyen-thi-cka/chapters/01-cluster-architecture/lessons/02-cluster-upgrade-kubeadm.md +147 -0
  3. package/content/series/luyen-thi/luyen-thi-cka/chapters/01-cluster-architecture/lessons/03-rbac-cka.md +152 -0
  4. package/content/series/luyen-thi/luyen-thi-cka/chapters/02-workloads-scheduling/lessons/04-deployments-daemonsets-statefulsets.md +186 -0
  5. package/content/series/luyen-thi/luyen-thi-cka/chapters/02-workloads-scheduling/lessons/05-scheduling-taints-affinity.md +163 -0
  6. package/content/series/luyen-thi/luyen-thi-cka/chapters/03-services-networking/lessons/06-services-endpoints-coredns.md +145 -0
  7. package/content/series/luyen-thi/luyen-thi-cka/chapters/03-services-networking/lessons/07-ingress-networkpolicies-cni.md +172 -0
  8. package/content/series/luyen-thi/luyen-thi-cka/chapters/04-storage/lessons/08-persistent-volumes-storageclass.md +159 -0
  9. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/09-etcd-backup-restore.md +149 -0
  10. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/10-troubleshooting-nodes.md +153 -0
  11. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/11-troubleshooting-workloads.md +146 -0
  12. package/content/series/luyen-thi/luyen-thi-cka/chapters/05-troubleshooting/lessons/12-troubleshooting-networking-exam.md +170 -0
  13. package/content/series/luyen-thi/luyen-thi-cka/index.md +7 -7
  14. package/content/series/luyen-thi/luyen-thi-ckad/chapters/01-app-design-build/lessons/01-multi-container-pods.md +146 -0
  15. package/content/series/luyen-thi/luyen-thi-ckad/chapters/01-app-design-build/lessons/02-jobs-cronjobs-resources.md +174 -0
  16. package/content/series/luyen-thi/luyen-thi-ckad/chapters/02-app-deployment/lessons/03-rolling-updates-rollbacks.md +148 -0
  17. package/content/series/luyen-thi/luyen-thi-ckad/chapters/02-app-deployment/lessons/04-helm-kustomize.md +181 -0
  18. package/content/series/luyen-thi/luyen-thi-ckad/chapters/03-app-observability/lessons/05-probes-logging-debugging.md +183 -0
  19. package/content/series/luyen-thi/luyen-thi-ckad/chapters/04-app-environment-config/lessons/06-configmaps-secrets.md +182 -0
  20. package/content/series/luyen-thi/luyen-thi-ckad/chapters/04-app-environment-config/lessons/07-securitycontext-pod-security.md +168 -0
  21. package/content/series/luyen-thi/luyen-thi-ckad/chapters/04-app-environment-config/lessons/08-resources-qos.md +168 -0
  22. package/content/series/luyen-thi/luyen-thi-ckad/chapters/05-services-networking/lessons/09-services-ingress.md +182 -0
  23. package/content/series/luyen-thi/luyen-thi-ckad/chapters/05-services-networking/lessons/10-networkpolicies-exam-strategy.md +236 -0
  24. package/content/series/luyen-thi/luyen-thi-ckad/index.md +7 -7
  25. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/01-kien-truc-kubernetes.md +137 -0
  26. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/02-pods-workloads-controllers.md +142 -0
  27. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/03-services-networking-storage.md +155 -0
  28. package/content/series/luyen-thi/luyen-thi-kcna/chapters/01-kubernetes-fundamentals/lessons/04-rbac-security.md +137 -0
  29. package/content/series/luyen-thi/luyen-thi-kcna/chapters/02-container-orchestration/lessons/05-container-runtimes-oci.md +137 -0
  30. package/content/series/luyen-thi/luyen-thi-kcna/chapters/02-container-orchestration/lessons/06-orchestration-patterns.md +147 -0
  31. package/content/series/luyen-thi/luyen-thi-kcna/chapters/03-cloud-native-architecture/lessons/07-cloud-native-architecture.md +143 -0
  32. package/content/series/luyen-thi/luyen-thi-kcna/chapters/04-observability-delivery/lessons/08-observability.md +143 -0
  33. package/content/series/luyen-thi/luyen-thi-kcna/chapters/04-observability-delivery/lessons/09-helm-gitops-cicd.md +162 -0
  34. package/content/series/luyen-thi/luyen-thi-kcna/index.md +1 -1
  35. package/data/quizzes.json +1059 -0
  36. package/package.json +1 -1
@@ -0,0 +1,137 @@
1
+ ---
2
+ id: kcna-d1-l01
3
+ title: 'Bài 1: Kubernetes Architecture & Core Components'
4
+ slug: 01-kien-truc-kubernetes
5
+ description: >-
6
+ Control plane vs Worker node. kube-apiserver, etcd, kube-scheduler,
7
+ controller-manager, kubelet, kube-proxy. Kubernetes objects overview.
8
+ duration_minutes: 55
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 1
12
+ section_title: "Domain 1: Kubernetes Fundamentals (46%)"
13
+ course:
14
+ id: lt-kcna-series-001
15
+ title: 'Luyện thi KCNA — Kubernetes and Cloud Native Associate'
16
+ slug: luyen-thi-kcna
17
+ ---
18
+
19
+ <img src="/storage/uploads/2026/04/k8s-cert-kcna-bai1-architecture.png" alt="Kubernetes Architecture — Control Plane và Worker Node components" style="max-width: 800px; width: 100%; border-radius: 12px;" />
20
+
21
+ <h2 id="overview">1. Tổng quan Kubernetes</h2>
22
+
23
+ <p><strong>Kubernetes</strong> (K8s) là nền tảng orchestration container mã nguồn mở do Google phát triển, tặng cho CNCF năm 2014. Kubernetes tự động hóa việc triển khai, scaling và quản lý containerized applications.</p>
24
+
25
+ <blockquote><p><strong>Exam tip:</strong> KCNA Domain 1 chiếm <strong>46%</strong> đề thi. Câu hỏi thường hỏi "Which component is responsible for..." — học thuộc vai trò từng component.</p></blockquote>
26
+
27
+ <h2 id="architecture">2. Kiến trúc Kubernetes</h2>
28
+
29
+ <p>Cluster Kubernetes gồm hai loại node: <strong>Control Plane</strong> và <strong>Worker Node</strong>.</p>
30
+
31
+ <pre><code class="language-text">┌─────────────────────────────────────────────────────────┐
32
+ │ CONTROL PLANE │
33
+ │ ┌──────────────┐ ┌─────────┐ ┌────────────────────┐ │
34
+ │ │ kube-apiserver│ │ etcd │ │kube-controller-mgr │ │
35
+ │ │ (REST API) │ │(DB key- │ │ - Node Controller │ │
36
+ │ │ front door │ │ value) │ │ - ReplicaSet Ctrl │ │
37
+ │ └──────────────┘ └─────────┘ │ - Endpoints Ctrl │ │
38
+ │ ┌──────────────┐ └────────────────────┘ │
39
+ │ │kube-scheduler│ │
40
+ │ │ (assign node)│ │
41
+ │ └──────────────┘ │
42
+ └─────────────────────────────────────────────────────────┘
43
+ │ │ │
44
+ ┌────────▼──────┐ ┌─────▼──────┐ ┌───▼────────────┐
45
+ │ WORKER NODE 1│ │WORKER NODE 2│ │ WORKER NODE 3 │
46
+ │ ┌──────────┐ │ │ ┌────────┐ │ │ ┌──────────┐ │
47
+ │ │ kubelet │ │ │ │kubelet │ │ │ │ kubelet │ │
48
+ │ │kube-proxy│ │ │ │k-proxy │ │ │ │kube-proxy│ │
49
+ │ │ Pod Pod │ │ │ │Pod Pod │ │ │ │ Pod Pod │ │
50
+ │ └──────────┘ │ │ └────────┘ │ │ └──────────┘ │
51
+ └───────────────┘ └────────────┘ └────────────────┘</code></pre>
52
+
53
+ <h2 id="control-plane">3. Control Plane Components</h2>
54
+
55
+ <table>
56
+ <thead><tr><th>Component</th><th>Vai trò</th><th>Từ khóa exam</th></tr></thead>
57
+ <tbody>
58
+ <tr><td><strong>kube-apiserver</strong></td><td>Cổng vào duy nhất của cluster, xử lý REST API. Mọi communication đều qua đây.</td><td>"single point of truth", "REST API", "authentication &amp; authorization"</td></tr>
59
+ <tr><td><strong>etcd</strong></td><td>Key-value store lưu trữ toàn bộ cluster state. Là database của Kubernetes.</td><td>"cluster state", "consistent", "distributed key-value"</td></tr>
60
+ <tr><td><strong>kube-scheduler</strong></td><td>Xem xét Pod chưa có node và chọn node phù hợp dựa trên resources, constraints.</td><td>"schedule", "assign node", "resource fit"</td></tr>
61
+ <tr><td><strong>kube-controller-manager</strong></td><td>Chạy nhiều controller loops: Node, ReplicaSet, Endpoints, ServiceAccount, v.v.</td><td>"reconciliation loop", "desired state", "controller"</td></tr>
62
+ <tr><td><strong>cloud-controller-manager</strong></td><td>Tích hợp với cloud provider API (AWS, GCP, Azure) — tùy chọn.</td><td>"cloud integration", "LoadBalancer provisioning"</td></tr>
63
+ </tbody>
64
+ </table>
65
+
66
+ <h2 id="worker-node">4. Worker Node Components</h2>
67
+
68
+ <table>
69
+ <thead><tr><th>Component</th><th>Vai trò</th><th>Từ khóa exam</th></tr></thead>
70
+ <tbody>
71
+ <tr><td><strong>kubelet</strong></td><td>Agent chạy trên mỗi node, nhận PodSpec từ apiserver và đảm bảo containers chạy đúng.</td><td>"node agent", "PodSpec", "container health"</td></tr>
72
+ <tr><td><strong>kube-proxy</strong></td><td>Quản lý network rules (iptables/IPVS) cho Services. Cho phép network communication đến Pods.</td><td>"networking", "iptables", "Service load balancing"</td></tr>
73
+ <tr><td><strong>Container Runtime</strong></td><td>Software chạy containers: containerd, CRI-O. Docker đã bị deprecated.</td><td>"CRI", "containerd", "run containers"</td></tr>
74
+ </tbody>
75
+ </table>
76
+
77
+ <blockquote><p><strong>Exam tip:</strong> <strong>kubelet</strong> là component duy nhất không chạy trong container — nó là systemd service trực tiếp trên node. Nếu kubelet crash, node sẽ NotReady.</p></blockquote>
78
+
79
+ <h2 id="objects">5. Kubernetes Objects Cơ Bản</h2>
80
+
81
+ <p>Mọi thứ trong Kubernetes là <strong>object</strong> — declarative resources được lưu trong etcd.</p>
82
+
83
+ <table>
84
+ <thead><tr><th>Object</th><th>Mô tả</th><th>Scope</th></tr></thead>
85
+ <tbody>
86
+ <tr><td><strong>Pod</strong></td><td>Unit nhỏ nhất, chứa 1+ containers chia sẻ network và storage</td><td>Namespaced</td></tr>
87
+ <tr><td><strong>Namespace</strong></td><td>Virtual cluster, isolate resources</td><td>Cluster-wide</td></tr>
88
+ <tr><td><strong>Node</strong></td><td>Worker machine (VM hoặc physical)</td><td>Cluster-wide</td></tr>
89
+ <tr><td><strong>Deployment</strong></td><td>Manage stateless app replicas với rolling update</td><td>Namespaced</td></tr>
90
+ <tr><td><strong>Service</strong></td><td>Stable network endpoint cho Pods</td><td>Namespaced</td></tr>
91
+ <tr><td><strong>ConfigMap / Secret</strong></td><td>Configuration data</td><td>Namespaced</td></tr>
92
+ <tr><td><strong>PersistentVolume</strong></td><td>Storage resource</td><td>Cluster-wide</td></tr>
93
+ </tbody>
94
+ </table>
95
+
96
+ <h2 id="cheatsheet">6. Cheat Sheet — Component → Nhiệm vụ</h2>
97
+
98
+ <table>
99
+ <thead><tr><th>Câu hỏi</th><th>Trả lời</th></tr></thead>
100
+ <tbody>
101
+ <tr><td>Lưu cluster state ở đâu?</td><td><strong>etcd</strong></td></tr>
102
+ <tr><td>Component nào chọn node cho Pod?</td><td><strong>kube-scheduler</strong></td></tr>
103
+ <tr><td>Component nào chạy trên mỗi worker, quản lý Pods?</td><td><strong>kubelet</strong></td></tr>
104
+ <tr><td>Component nào xử lý tất cả API calls?</td><td><strong>kube-apiserver</strong></td></tr>
105
+ <tr><td>Component nào manage network rules cho Services?</td><td><strong>kube-proxy</strong></td></tr>
106
+ <tr><td>Component nào watch và reconcile desired state?</td><td><strong>kube-controller-manager</strong></td></tr>
107
+ </tbody>
108
+ </table>
109
+
110
+ <h2 id="practice">7. Practice Questions</h2>
111
+
112
+ <p><strong>Q1:</strong> Which Kubernetes control plane component is responsible for watching newly created Pods that have no node assigned, and selecting a node for them?</p>
113
+ <ul>
114
+ <li>A) kube-apiserver</li>
115
+ <li>B) kube-scheduler ✓</li>
116
+ <li>C) kube-controller-manager</li>
117
+ <li>D) kubelet</li>
118
+ </ul>
119
+ <p><em>Explanation: kube-scheduler watches for unscheduled Pods and assigns them to suitable nodes based on resource requirements, affinity rules, and constraints.</em></p>
120
+
121
+ <p><strong>Q2:</strong> Where does Kubernetes store all cluster configuration and state?</p>
122
+ <ul>
123
+ <li>A) kube-apiserver memory</li>
124
+ <li>B) /etc/kubernetes/ on each node</li>
125
+ <li>C) etcd ✓</li>
126
+ <li>D) kubelet database</li>
127
+ </ul>
128
+ <p><em>Explanation: etcd is the consistent, highly-available key-value store that serves as the backing store for all Kubernetes cluster data. Backing up etcd = backing up the entire cluster.</em></p>
129
+
130
+ <p><strong>Q3:</strong> Which component on a Worker Node is responsible for ensuring containers described in PodSpecs are running and healthy?</p>
131
+ <ul>
132
+ <li>A) kube-proxy</li>
133
+ <li>B) Container runtime</li>
134
+ <li>C) kubelet ✓</li>
135
+ <li>D) kube-controller-manager</li>
136
+ </ul>
137
+ <p><em>Explanation: kubelet is the node agent that receives PodSpecs from kube-apiserver and ensures the described containers are running. It reports node/Pod status back to the control plane.</em></p>
@@ -0,0 +1,142 @@
1
+ ---
2
+ id: kcna-d1-l02
3
+ title: 'Bài 2: Pods, Workloads & Controllers'
4
+ slug: 02-pods-workloads-controllers
5
+ description: >-
6
+ Pod lifecycle. Deployments, ReplicaSets, StatefulSets, DaemonSets,
7
+ Jobs, CronJobs. Labels, selectors, annotations.
8
+ duration_minutes: 55
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 2
12
+ section_title: "Domain 1: Kubernetes Fundamentals (46%)"
13
+ course:
14
+ id: lt-kcna-series-001
15
+ title: 'Luyện thi KCNA — Kubernetes and Cloud Native Associate'
16
+ slug: luyen-thi-kcna
17
+ ---
18
+
19
+ <img src="/storage/uploads/2026/04/k8s-cert-kcna-bai2-pods-workloads.png" alt="Kubernetes Workload Controllers — Deployment, StatefulSet, DaemonSet, Job" style="max-width: 800px; width: 100%; border-radius: 12px;" />
20
+
21
+ <h2 id="pod">1. Pod — Đơn vị nhỏ nhất</h2>
22
+
23
+ <p>Một <strong>Pod</strong> là nhóm 1 hoặc nhiều containers chia sẻ cùng network namespace (cùng IP, port space) và storage volumes. Pod là đơn vị scheduling trong Kubernetes.</p>
24
+
25
+ <pre><code class="language-text">┌─────────────────────────────────────┐
26
+ │ POD │
27
+ │ IP: 10.244.1.5 │
28
+ │ ┌────────────┐ ┌───────────────┐ │
29
+ │ │ Container │ │ Sidecar │ │
30
+ │ │ (app) │ │ (log-agent) │ │
31
+ │ └────────────┘ └───────────────┘ │
32
+ │ Shared Volume: /var/log │
33
+ └─────────────────────────────────────┘</code></pre>
34
+
35
+ <h3 id="pod-lifecycle">Pod Lifecycle</h3>
36
+
37
+ <table>
38
+ <thead><tr><th>Phase</th><th>Ý nghĩa</th><th>Debug hint</th></tr></thead>
39
+ <tbody>
40
+ <tr><td><strong>Pending</strong></td><td>Chưa được schedule hoặc đang pull image</td><td>Check events: kubectl describe pod</td></tr>
41
+ <tr><td><strong>Running</strong></td><td>Đang chạy, ít nhất 1 container đang active</td><td>Normal state</td></tr>
42
+ <tr><td><strong>Succeeded</strong></td><td>Tất cả containers thoát với code 0</td><td>Job completed</td></tr>
43
+ <tr><td><strong>Failed</strong></td><td>Ít nhất 1 container thoát với lỗi</td><td>kubectl logs --previous</td></tr>
44
+ <tr><td><strong>Unknown</strong></td><td>Không liên lạc được với node</td><td>Node network issue</td></tr>
45
+ <tr><td><strong>CrashLoopBackOff</strong></td><td>Container liên tục crash và restart</td><td>kubectl logs -p</td></tr>
46
+ </tbody>
47
+ </table>
48
+
49
+ <blockquote><p><strong>Exam tip:</strong> <strong>CrashLoopBackOff</strong> không phải Pod phase chính thức — nó là Container state trong Waiting. Câu hỏi hay hỏi "pod phase" vs "container state".</p></blockquote>
50
+
51
+ <h2 id="workloads">2. Workload Controllers</h2>
52
+
53
+ <table>
54
+ <thead><tr><th>Controller</th><th>Dùng khi</th><th>Đặc điểm nổi bật</th></tr></thead>
55
+ <tbody>
56
+ <tr><td><strong>Deployment</strong></td><td>Stateless apps (web server, API)</td><td>Rolling update, rollback, ReplicaSet management</td></tr>
57
+ <tr><td><strong>ReplicaSet</strong></td><td>Đảm bảo N replicas (thường dùng qua Deployment)</td><td>Label selector, ít dùng trực tiếp</td></tr>
58
+ <tr><td><strong>StatefulSet</strong></td><td>Stateful apps (database, Kafka, Elasticsearch)</td><td>Stable pod names (web-0, web-1), stable storage, ordered deployment</td></tr>
59
+ <tr><td><strong>DaemonSet</strong></td><td>Agent chạy trên mọi node (logging, monitoring, network)</td><td>1 Pod/node, auto-deploy khi node mới join</td></tr>
60
+ <tr><td><strong>Job</strong></td><td>Batch task chạy đến khi hoàn thành</td><td>completions, parallelism, backoffLimit</td></tr>
61
+ <tr><td><strong>CronJob</strong></td><td>Periodic batch tasks</td><td>cron syntax, concurrencyPolicy, schedule</td></tr>
62
+ </tbody>
63
+ </table>
64
+
65
+ <h3 id="deployment-vs-statefulset">Deployment vs StatefulSet</h3>
66
+
67
+ <pre><code class="language-text">DEPLOYMENT (Stateless) STATEFULSET (Stateful)
68
+ ───────────────────── ────────────────────────
69
+ Pod names: web-a1b2c3 Pod names: web-0, web-1, web-2
70
+ Any order scale up/down Ordered: web-0 first, then web-1...
71
+ Shared or no storage Each Pod gets its own PVC
72
+ Pod replaced = new identity Pod replaced = same identity
73
+ Examples: nginx, api-server Examples: MySQL, MongoDB, Kafka</code></pre>
74
+
75
+ <h2 id="labels">3. Labels, Selectors & Annotations</h2>
76
+
77
+ <table>
78
+ <thead><tr><th>Concept</th><th>Dùng để</th><th>Ví dụ</th></tr></thead>
79
+ <tbody>
80
+ <tr><td><strong>Labels</strong></td><td>Tag resources để select và group</td><td><code>app: frontend, env: prod</code></td></tr>
81
+ <tr><td><strong>Selectors</strong></td><td>Query resources theo labels</td><td><code>selector: {app: frontend}</code></td></tr>
82
+ <tr><td><strong>Annotations</strong></td><td>Metadata không dùng để select (build info, contact)</td><td><code>maintainer: team@company.com</code></td></tr>
83
+ </tbody>
84
+ </table>
85
+
86
+ <blockquote><p><strong>Exam tip:</strong> Service tìm Pods qua <strong>selector</strong> matching Pod <strong>labels</strong>. Nếu selector không match, Service sẽ có empty Endpoints → traffic không đến được Pod.</p></blockquote>
87
+
88
+ <h2 id="daemonset-usecase">4. DaemonSet Use Cases</h2>
89
+
90
+ <pre><code class="language-text">NODE 1 NODE 2 NODE 3
91
+ ┌──────┐ ┌──────┐ ┌──────┐
92
+ │fluentd│ │fluentd│ │fluentd│ ← Log collector DaemonSet
93
+ │ Pod │ │ Pod │ │ Pod │
94
+ ├──────┤ ├──────┤ ├──────┤
95
+ │calico│ │calico│ │calico│ ← CNI network plugin DaemonSet
96
+ │ Pod │ │ Pod │ │ Pod │
97
+ └──────┘ └──────┘ └──────┘</code></pre>
98
+
99
+ <p>DaemonSets thường dùng cho: <strong>Fluentd/Filebeat</strong> (log collection), <strong>Prometheus Node Exporter</strong> (metrics), <strong>kube-proxy</strong> (networking), <strong>CNI plugins</strong> (Calico, Cilium).</p>
100
+
101
+ <h2 id="cheatsheet">5. Cheat Sheet</h2>
102
+
103
+ <table>
104
+ <thead><tr><th>Câu hỏi exam</th><th>Đáp án</th></tr></thead>
105
+ <tbody>
106
+ <tr><td>Stateful app, cần stable identity?</td><td><strong>StatefulSet</strong></td></tr>
107
+ <tr><td>1 Pod per node (monitoring agent)?</td><td><strong>DaemonSet</strong></td></tr>
108
+ <tr><td>Stateless app với rolling update?</td><td><strong>Deployment</strong></td></tr>
109
+ <tr><td>One-time batch processing?</td><td><strong>Job</strong></td></tr>
110
+ <tr><td>Scheduled batch (nightly backup)?</td><td><strong>CronJob</strong></td></tr>
111
+ <tr><td>Pod naming pattern cho StatefulSet?</td><td><code>name-0, name-1, name-2</code></td></tr>
112
+ </tbody>
113
+ </table>
114
+
115
+ <h2 id="practice">6. Practice Questions</h2>
116
+
117
+ <p><strong>Q1:</strong> A company needs to deploy a MySQL database on Kubernetes with stable network identity and dedicated storage per replica. Which workload type should they use?</p>
118
+ <ul>
119
+ <li>A) Deployment with PersistentVolumeClaim</li>
120
+ <li>B) StatefulSet ✓</li>
121
+ <li>C) DaemonSet</li>
122
+ <li>D) ReplicaSet</li>
123
+ </ul>
124
+ <p><em>Explanation: StatefulSet provides stable Pod names (mysql-0, mysql-1), ordered deployment/scaling, and each Pod gets its own PVC via volumeClaimTemplates. These properties are essential for databases.</em></p>
125
+
126
+ <p><strong>Q2:</strong> Which workload ensures exactly one Pod runs on every node in the cluster, including future nodes that join?</p>
127
+ <ul>
128
+ <li>A) Deployment with replicas matching node count</li>
129
+ <li>B) ReplicaSet with nodeSelector</li>
130
+ <li>C) DaemonSet ✓</li>
131
+ <li>D) StatefulSet</li>
132
+ </ul>
133
+ <p><em>Explanation: DaemonSet automatically deploys one Pod per node and watches cluster membership — when a new node joins, the DaemonSet controller immediately creates a Pod on it.</em></p>
134
+
135
+ <p><strong>Q3:</strong> A Pod is in 'Pending' state. What is the MOST likely cause?</p>
136
+ <ul>
137
+ <li>A) The container application crashed</li>
138
+ <li>B) No node satisfies the scheduling requirements ✓</li>
139
+ <li>C) The liveness probe failed</li>
140
+ <li>D) The container image is corrupted</li>
141
+ </ul>
142
+ <p><em>Explanation: Pending means the Pod has been accepted but hasn't started. Most common reasons: insufficient CPU/memory on nodes, unsatisfied node affinity/taints, or PVC not bound. Check kubectl describe pod events.</em></p>
@@ -0,0 +1,155 @@
1
+ ---
2
+ id: kcna-d1-l03
3
+ title: 'Bài 3: Services, Networking & Storage'
4
+ slug: 03-services-networking-storage
5
+ description: >-
6
+ Service types (ClusterIP, NodePort, LoadBalancer, ExternalName). CoreDNS
7
+ và service discovery. PersistentVolume, PVC, ConfigMap, Secret.
8
+ duration_minutes: 60
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 3
12
+ section_title: "Domain 1: Kubernetes Fundamentals (46%)"
13
+ course:
14
+ id: lt-kcna-series-001
15
+ title: 'Luyện thi KCNA — Kubernetes and Cloud Native Associate'
16
+ slug: luyen-thi-kcna
17
+ ---
18
+
19
+ <img src="/storage/uploads/2026/04/k8s-cert-kcna-bai3-services-networking.png" alt="Kubernetes Services và Networking — ClusterIP, NodePort, LoadBalancer" style="max-width: 800px; width: 100%; border-radius: 12px;" />
20
+
21
+ <h2 id="services">1. Service Types</h2>
22
+
23
+ <p>Pods có IP tạm thời, bị xóa khi restart. <strong>Service</strong> cung cấp stable Virtual IP (ClusterIP) và load-balancing đến một nhóm Pods qua label selector.</p>
24
+
25
+ <table>
26
+ <thead><tr><th>Type</th><th>Reachable From</th><th>Use Case</th><th>Real-world Example</th></tr></thead>
27
+ <tbody>
28
+ <tr><td><strong>ClusterIP</strong></td><td>Cluster internal only</td><td>Backend microservices</td><td>Payment service → DB</td></tr>
29
+ <tr><td><strong>NodePort</strong></td><td>External via NodeIP:Port (30000-32767)</td><td>Dev/test access</td><td>Demo app on bare metal</td></tr>
30
+ <tr><td><strong>LoadBalancer</strong></td><td>External via cloud LB</td><td>Production apps on cloud</td><td>AWS/GCP internet traffic</td></tr>
31
+ <tr><td><strong>ExternalName</strong></td><td>CNAME alias for external service</td><td>Integrate external DNS</td><td>legacy-db.company.com</td></tr>
32
+ </tbody>
33
+ </table>
34
+
35
+ <pre><code class="language-text">External Traffic
36
+
37
+
38
+ [LoadBalancer] ← cloud provider LB (AWS ELB, GCP)
39
+
40
+ [NodePort :30080] ← all nodes expose port 30080
41
+
42
+ [ClusterIP 10.96.5.3] ← virtual IP, iptables/IPVS routing
43
+
44
+ ┌────┴────┐
45
+ [Pod A] [Pod B] ← matched by label selector</code></pre>
46
+
47
+ <blockquote><p><strong>Exam tip:</strong> <strong>NodePort</strong> tự động tạo thêm <strong>ClusterIP</strong>. <strong>LoadBalancer</strong> tự động tạo thêm <strong>NodePort + ClusterIP</strong>. Mỗi type kế thừa type nhỏ hơn.</p></blockquote>
48
+
49
+ <h2 id="coredns">2. CoreDNS & Service Discovery</h2>
50
+
51
+ <p><strong>CoreDNS</strong> là DNS server mặc định trong Kubernetes cluster. Mỗi Service được đăng ký DNS record tự động.</p>
52
+
53
+ <pre><code class="language-text">DNS format: {service}.{namespace}.svc.cluster.local
54
+
55
+ Ví dụ:
56
+ Service "api" trong namespace "production":
57
+ → api.production.svc.cluster.local
58
+ → api.production.svc
59
+ → api.production
60
+ → api (chỉ trong cùng namespace)</code></pre>
61
+
62
+ <table>
63
+ <thead><tr><th>DNS Query</th><th>Resolves To</th><th>Works From</th></tr></thead>
64
+ <tbody>
65
+ <tr><td><code>api</code></td><td>Service ClusterIP</td><td>Same namespace only</td></tr>
66
+ <tr><td><code>api.production</code></td><td>Service ClusterIP</td><td>Any namespace</td></tr>
67
+ <tr><td><code>api.production.svc.cluster.local</code></td><td>Service ClusterIP</td><td>Any namespace (FQDN)</td></tr>
68
+ </tbody>
69
+ </table>
70
+
71
+ <h2 id="storage">3. Storage: PV, PVC, StorageClass</h2>
72
+
73
+ <pre><code class="language-text">Storage lifecycle:
74
+ STATIC DYNAMIC
75
+ ───── ───────
76
+ Admin creates → PersistentVolume StorageClass (provision template)
77
+ App requests → PersistentVolumeClaim → SC auto-provisions PV
78
+ Pod mounts → PVC as volume</code></pre>
79
+
80
+ <table>
81
+ <thead><tr><th>Concept</th><th>Vai trò</th><th>Ai tạo</th></tr></thead>
82
+ <tbody>
83
+ <tr><td><strong>PersistentVolume (PV)</strong></td><td>Tài nguyên storage thực tế (NFS, EBS, GCE Disk)</td><td>Admin hoặc dynamic provisioner</td></tr>
84
+ <tr><td><strong>PersistentVolumeClaim (PVC)</strong></td><td>Request storage với size + access mode</td><td>Developer / App</td></tr>
85
+ <tr><td><strong>StorageClass</strong></td><td>Template tự động tạo PV khi có PVC</td><td>Admin</td></tr>
86
+ </tbody>
87
+ </table>
88
+
89
+ <h3 id="access-modes">Access Modes</h3>
90
+
91
+ <table>
92
+ <thead><tr><th>Mode</th><th>Abbrev</th><th>Ý nghĩa</th><th>Ví dụ</th></tr></thead>
93
+ <tbody>
94
+ <tr><td>ReadWriteOnce</td><td><strong>RWO</strong></td><td>1 node đọc+ghi</td><td>EBS volume, local disk</td></tr>
95
+ <tr><td>ReadOnlyMany</td><td><strong>ROX</strong></td><td>Nhiều nodes đọc</td><td>Static files on NFS</td></tr>
96
+ <tr><td>ReadWriteMany</td><td><strong>RWX</strong></td><td>Nhiều nodes đọc+ghi</td><td>NFS, EFS, GlusterFS</td></tr>
97
+ <tr><td>ReadWriteOncePod</td><td><strong>RWOP</strong></td><td>Chỉ 1 Pod (v1.22+)</td><td>Exclusive access needed</td></tr>
98
+ </tbody>
99
+ </table>
100
+
101
+ <blockquote><p><strong>Exam tip:</strong> AWS EBS chỉ hỗ trợ <strong>RWO</strong>. Nếu câu hỏi yêu cầu nhiều Pods ghi đồng thời, cần dùng NFS (RWX). StatefulSet thường dùng RWO với mỗi Pod có PVC riêng.</p></blockquote>
102
+
103
+ <h2 id="configmap-secret">4. ConfigMap & Secret</h2>
104
+
105
+ <table>
106
+ <thead><tr><th>Resource</th><th>Dùng cho</th><th>Encoding</th><th>Inject vào Pod</th></tr></thead>
107
+ <tbody>
108
+ <tr><td><strong>ConfigMap</strong></td><td>Config không nhạy cảm (URLs, flags, env files)</td><td>Plain text</td><td>Env var, volume file, CLI args</td></tr>
109
+ <tr><td><strong>Secret</strong></td><td>Data nhạy cảm (passwords, API keys, TLS certs)</td><td>Base64 (NOT encrypted by default)</td><td>Env var (không khuyến khích), volume mount</td></tr>
110
+ </tbody>
111
+ </table>
112
+
113
+ <blockquote><p><strong>Exam tip:</strong> Secret chỉ là base64 encoded, <strong>KHÔNG phải encrypted</strong>. Để encrypt Secret at rest, cần bật <strong>Encryption Configuration</strong> ở API Server. Câu hỏi hay dùng "encrypted" như distractor sai.</p></blockquote>
114
+
115
+ <h2 id="cheatsheet">5. Cheat Sheet</h2>
116
+
117
+ <table>
118
+ <thead><tr><th>Câu hỏi exam</th><th>Đáp án</th></tr></thead>
119
+ <tbody>
120
+ <tr><td>Expose app ra ngoài cluster trên cloud?</td><td><strong>LoadBalancer</strong> (hoặc Ingress)</td></tr>
121
+ <tr><td>DNS name cho Service "db" trong ns "backend"?</td><td><code>db.backend.svc.cluster.local</code></td></tr>
122
+ <tr><td>Cần storage shared giữa nhiều Pods?</td><td>PV với access mode <strong>RWX</strong></td></tr>
123
+ <tr><td>Tự động provision storage khi deploy?</td><td><strong>StorageClass</strong> + PVC</td></tr>
124
+ <tr><td>Secret có bị encrypt by default?</td><td><strong>Không</strong>, chỉ base64</td></tr>
125
+ </tbody>
126
+ </table>
127
+
128
+ <h2 id="practice">6. Practice Questions</h2>
129
+
130
+ <p><strong>Q1:</strong> A developer wants to access a backend database Service named "orders-db" from a different namespace called "frontend". Which DNS name should they use?</p>
131
+ <ul>
132
+ <li>A) orders-db</li>
133
+ <li>B) orders-db.default.svc.cluster.local</li>
134
+ <li>C) orders-db.backend.svc.cluster.local ✓</li>
135
+ <li>D) backend.orders-db.cluster.local</li>
136
+ </ul>
137
+ <p><em>Explanation: Cross-namespace DNS requires the full format: {service}.{namespace}.svc.cluster.local. Short name "orders-db" only works within the same namespace.</em></p>
138
+
139
+ <p><strong>Q2:</strong> Which Service type automatically creates a ClusterIP AND a NodePort?</p>
140
+ <ul>
141
+ <li>A) ClusterIP</li>
142
+ <li>B) NodePort</li>
143
+ <li>C) LoadBalancer ✓</li>
144
+ <li>D) ExternalName</li>
145
+ </ul>
146
+ <p><em>Explanation: LoadBalancer is a superset — it creates ClusterIP + NodePort + cloud load balancer. NodePort includes ClusterIP, but ClusterIP is standalone with no external access.</em></p>
147
+
148
+ <p><strong>Q3:</strong> A Secret contains a database password. A developer claims the password is "encrypted". Is this claim accurate?</p>
149
+ <ul>
150
+ <li>A) Yes, Kubernetes Secrets are encrypted with AES</li>
151
+ <li>B) No, Secrets are only base64 encoded unless Encryption Configuration is enabled ✓</li>
152
+ <li>C) Yes, Secrets are encrypted using etcd's built-in encryption</li>
153
+ <li>D) No, Secrets are stored in plain text</li>
154
+ </ul>
155
+ <p><em>Explanation: By default, Secrets are stored as base64-encoded strings in etcd — which is NOT encryption. Administrators must configure EncryptionConfiguration on the API server to enable encryption at rest.</em></p>
@@ -0,0 +1,137 @@
1
+ ---
2
+ id: kcna-d1-l04
3
+ title: 'Bài 4: RBAC & Kubernetes Security'
4
+ slug: 04-rbac-security
5
+ description: >-
6
+ Role-Based Access Control (RBAC), ServiceAccounts, Network Policies,
7
+ Pod Security Standards và Security Context. Bảo mật Kubernetes cluster.
8
+ duration_minutes: 55
9
+ is_free: true
10
+ video_url: null
11
+ sort_order: 4
12
+ section_title: "Domain 1: Kubernetes Fundamentals (46%)"
13
+ course:
14
+ id: lt-kcna-series-001
15
+ title: 'Luyện thi KCNA — Kubernetes and Cloud Native Associate'
16
+ slug: luyen-thi-kcna
17
+ ---
18
+
19
+ <img src="/storage/uploads/2026/04/k8s-cert-kcna-bai4-rbac.png" alt="RBAC Authorization Model — Subject, RoleBinding, Role, Rules" style="max-width: 800px; width: 100%; border-radius: 12px;" />
20
+
21
+ <h2 id="rbac">1. RBAC — Role-Based Access Control</h2>
22
+
23
+ <p><strong>RBAC</strong> kiểm soát ai (User, Group, ServiceAccount) được làm gì (verbs) với tài nguyên nào (resources) trong namespace hoặc cluster.</p>
24
+
25
+ <pre><code class="language-text">RBAC Flow:
26
+ Subject (Who?) → Role/ClusterRole (What?) → RoleBinding (Links)
27
+
28
+ User "alice" Role "pod-reader" RoleBinding
29
+ ServiceAccount - get pods alice → pod-reader
30
+ Group "devs" - list pods (in namespace "dev")
31
+ - watch pods</code></pre>
32
+
33
+ <table>
34
+ <thead><tr><th>Object</th><th>Scope</th><th>Dùng khi</th></tr></thead>
35
+ <tbody>
36
+ <tr><td><strong>Role</strong></td><td>Namespace</td><td>Quyền trong 1 namespace</td></tr>
37
+ <tr><td><strong>ClusterRole</strong></td><td>Cluster-wide</td><td>Quyền trên toàn cluster hoặc non-namespaced resources (nodes)</td></tr>
38
+ <tr><td><strong>RoleBinding</strong></td><td>Namespace</td><td>Gán Role or ClusterRole cho Subject trong 1 namespace</td></tr>
39
+ <tr><td><strong>ClusterRoleBinding</strong></td><td>Cluster-wide</td><td>Gán ClusterRole cho Subject trên toàn cluster</td></tr>
40
+ </tbody>
41
+ </table>
42
+
43
+ <blockquote><p><strong>Exam tip:</strong> Có thể dùng <strong>RoleBinding</strong> để gán <strong>ClusterRole</strong> vào 1 namespace cụ thể — đây là cách tái sử dụng permission template mà không cấp quyền toàn cluster. Rất hay xuất hiện trong exam!</p></blockquote>
44
+
45
+ <h2 id="serviceaccounts">2. ServiceAccounts</h2>
46
+
47
+ <p>Mỗi Pod có thể gắn một <strong>ServiceAccount</strong>. Token của ServiceAccount được mount tự động vào <code>/var/run/secrets/kubernetes.io/serviceaccount/</code>. Pods dùng token này để gọi Kubernetes API.</p>
48
+
49
+ <pre><code class="language-text">Default ServiceAccount flow:
50
+ Pod → ServiceAccount → RBAC Role → API Server
51
+
52
+ Ví dụ: Prometheus cần đọc Pod metrics:
53
+ ServiceAccount: prometheus-sa
54
+ ClusterRole: pod-metrics-reader (verbs: get, list, watch)
55
+ ClusterRoleBinding: prometheus-sa → pod-metrics-reader</code></pre>
56
+
57
+ <h2 id="network-policies">3. Network Policies</h2>
58
+
59
+ <p>Mặc định, tất cả Pods trong cluster có thể communicate với nhau. <strong>NetworkPolicy</strong> cho phép giới hạn traffic ingress/egress dựa trên Pod selector, namespace selector, hoặc IP block.</p>
60
+
61
+ <pre><code class="language-text">❌ Default (no NetworkPolicy): All pods talk to all pods
62
+ ✅ With NetworkPolicy:
63
+ frontend → backend (allowed)
64
+ frontend → database (BLOCKED)
65
+ backend → database (allowed)</code></pre>
66
+
67
+ <blockquote><p><strong>Exam tip:</strong> NetworkPolicy chỉ có tác dụng khi <strong>CNI plugin hỗ trợ</strong> (Calico, Cilium, Weave). Flannel không hỗ trợ NetworkPolicy. Nếu không có policy nào → allow all. Nếu có ít nhất 1 policy → default deny cho traffic được select.</p></blockquote>
68
+
69
+ <h2 id="pod-security">4. Pod Security Standards</h2>
70
+
71
+ <p>Kubernetes định nghĩa 3 <strong>Pod Security Standards</strong> (thay thế PodSecurityPolicy từ v1.25):</p>
72
+
73
+ <table>
74
+ <thead><tr><th>Profile</th><th>Mức độ hạn chế</th><th>Dùng cho</th></tr></thead>
75
+ <tbody>
76
+ <tr><td><strong>Privileged</strong></td><td>Không hạn chế</td><td>System/infra workloads (kube-system)</td></tr>
77
+ <tr><td><strong>Baseline</strong></td><td>Ngăn escalation rõ ràng</td><td>Workloads thông thường</td></tr>
78
+ <tr><td><strong>Restricted</strong></td><td>Tuân thủ hardening tối đa</td><td>Security-sensitive apps</td></tr>
79
+ </tbody>
80
+ </table>
81
+
82
+ <h2 id="security-context">5. SecurityContext</h2>
83
+
84
+ <p><strong>SecurityContext</strong> cấu hình bảo mật ở cấp Pod hoặc Container:</p>
85
+
86
+ <table>
87
+ <thead><tr><th>Security setting</th><th>Ý nghĩa</th></tr></thead>
88
+ <tbody>
89
+ <tr><td><code>runAsNonRoot: true</code></td><td>Container không được chạy với UID 0</td></tr>
90
+ <tr><td><code>runAsUser: 1000</code></td><td>Chạy container với UID 1000</td></tr>
91
+ <tr><td><code>readOnlyRootFilesystem: true</code></td><td>Filesystem read-only (write phải dùng volume)</td></tr>
92
+ <tr><td><code>allowPrivilegeEscalation: false</code></td><td>Không cho process leo thang đặc quyền</td></tr>
93
+ <tr><td><code>capabilities.drop: ["ALL"]</code></td><td>Bỏ tất cả Linux capabilities</td></tr>
94
+ </tbody>
95
+ </table>
96
+
97
+ <h2 id="cheatsheet">6. Cheat Sheet</h2>
98
+
99
+ <table>
100
+ <thead><tr><th>Câu hỏi exam</th><th>Đáp án</th></tr></thead>
101
+ <tbody>
102
+ <tr><td>Pod cần gọi K8s API, dùng gì?</td><td><strong>ServiceAccount</strong></td></tr>
103
+ <tr><td>Giới hạn quyền user trong 1 namespace?</td><td><strong>Role</strong> + <strong>RoleBinding</strong></td></tr>
104
+ <tr><td>Giới hạn network traffic giữa Pods?</td><td><strong>NetworkPolicy</strong></td></tr>
105
+ <tr><td>NetworkPolicy cần gì để hoạt động?</td><td>CNI plugin hỗ trợ (Calico, Cilium)</td></tr>
106
+ <tr><td>Privileged → Restricted, Pod Security cần?</td><td><strong>Pod Security Admission</strong></td></tr>
107
+ </tbody>
108
+ </table>
109
+
110
+ <h2 id="practice">7. Practice Questions</h2>
111
+
112
+ <p><strong>Q1:</strong> An application Pod needs to access the Kubernetes API to list Pods in its own namespace. What should a cluster administrator create?</p>
113
+ <ul>
114
+ <li>A) ClusterRole with ClusterRoleBinding for all namespaces</li>
115
+ <li>B) ServiceAccount with Role (list pods) and RoleBinding ✓</li>
116
+ <li>C) Service with type LoadBalancer for API Server</li>
117
+ <li>D) ConfigMap with API Server credentials</li>
118
+ </ul>
119
+ <p><em>Explanation: The Pod needs a ServiceAccount, a Role granting "list pods" in its namespace, and a RoleBinding linking them. Using ClusterRole would over-grant access across all namespaces.</em></p>
120
+
121
+ <p><strong>Q2:</strong> A NetworkPolicy is applied to a Pod. What is the default behavior for traffic not explicitly matched by any rule?</p>
122
+ <ul>
123
+ <li>A) All traffic is allowed (default allow)</li>
124
+ <li>B) Traffic is logged but not blocked</li>
125
+ <li>C) Traffic that matches the Pod selector is denied; all other traffic passes ✓</li>
126
+ <li>D) All traffic to/from the Pod is denied</li>
127
+ </ul>
128
+ <p><em>Explanation: Once a NetworkPolicy selects a Pod (via podSelector), all traffic not explicitly allowed is denied for that policy type (ingress/egress). Non-selected Pods remain unaffected and have full connectivity.</em></p>
129
+
130
+ <p><strong>Q3:</strong> Which Pod Security Standard profile should be used for a system-level component that requires privileged access to the host?</p>
131
+ <ul>
132
+ <li>A) Restricted</li>
133
+ <li>B) Baseline</li>
134
+ <li>C) Privileged ✓</li>
135
+ <li>D) SystemAdmin</li>
136
+ </ul>
137
+ <p><em>Explanation: The Privileged profile places no restrictions on Pods, allowing all capabilities. It's intended for system/infrastructure components. Baseline prevents known privilege escalations; Restricted enforces maximum hardening.</em></p>