> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudthinker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Giám sát Sức khỏe Kubernetes

> Dùng Kai để giám sát sức khỏe cụm EKS, phát hiện lãng phí tài nguyên, và nhận khuyến nghị HPA trước khi sự cố xảy ra trên môi trường production.

Kai liên tục giám sát cụm Amazon EKS của bạn, phát hiện pod được cấp phát thừa, node chưa được tận dụng, và thiếu chính sách autoscaling trước khi chúng gây ra sự cố nghiêm trọng.

## Tình huống

Một nhóm platform đang vận hành cụm EKS production trải dài nhiều namespace. Cảnh báo CPU xuất hiện ngắt quãng nhưng điều tra chậm chạp — kỹ sư phải chạy thủ công các lệnh `kubectl` qua hàng trăm pod để tương quan log, metrics, và event.

<Frame>
  <img src="https://mintcdn.com/cloudthinker/0IKJjKZJEIROke98/images/use-cases/kubernetes-health-monitoring/01-manual-troubleshooting-challenges.jpg?fit=max&auto=format&n=0IKJjKZJEIROke98&q=85&s=b0ee7de46d34538911ac646b3c1356e2" alt="Thách thức khi xử lý sự cố Kubernetes thủ công qua các namespace và tài nguyên" width="1152" height="1136" data-path="images/use-cases/kubernetes-health-monitoring/01-manual-troubleshooting-challenges.jpg" />
</Frame>

<p style={{textAlign: 'center', fontSize: '0.9em', color: '#666', marginTop: '8px'}}>Thách thức khi xử lý sự cố Kubernetes thủ công</p>

Nhóm yêu cầu Kai đánh giá toàn diện cụm, xác định lãng phí tài nguyên, và khuyến nghị chính sách autoscaling cho những nơi còn thiếu.

## Hướng dẫn từng bước

<Steps>
  ### Kết nối Kai với cụm của bạn

  Làm theo [hướng dẫn kết nối Kubernetes](/vi/guide/connections/kubernetes) để cấp cho Kai quyền truy cập cụm EKS của bạn. Khi kết nối hiển thị trạng thái **Connected**, Kai có thể truy vấn cụm trực tiếp.

  ### Phân tích mức sử dụng tài nguyên pod

  ```text theme={null}
  @kai #report analyze pod resource utilization in production namespace
  ```

  <Frame>
    <img src="https://mintcdn.com/cloudthinker/0IKJjKZJEIROke98/images/use-cases/kubernetes-health-monitoring/02-pod-resource-utilization.jpg?fit=max&auto=format&n=0IKJjKZJEIROke98&q=85&s=e222d8a917b6ed474e862b78092b45bb" alt="Phân tích mức sử dụng tài nguyên pod thể hiện mẫu sử dụng CPU và bộ nhớ" width="2236" height="1546" data-path="images/use-cases/kubernetes-health-monitoring/02-pod-resource-utilization.jpg" />
  </Frame>

  <p style={{textAlign: 'center', fontSize: '0.9em', color: '#666', marginTop: '8px'}}>Phân tích mức sử dụng tài nguyên pod</p>

  <Frame>
    <img src="https://mintcdn.com/cloudthinker/0IKJjKZJEIROke98/images/use-cases/kubernetes-health-monitoring/03-pod-analysis-visualization.jpg?fit=max&auto=format&n=0IKJjKZJEIROke98&q=85&s=3ab99f44bf3d440f29c803b422a48010" alt="Trực quan hóa phân tích pod kèm khuyến nghị hiệu năng" width="2240" height="1544" data-path="images/use-cases/kubernetes-health-monitoring/03-pod-analysis-visualization.jpg" />
  </Frame>

  <p style={{textAlign: 'center', fontSize: '0.9em', color: '#666', marginTop: '8px'}}>Trực quan hóa phân tích pod kèm khuyến nghị hiệu năng</p>

  Kai phát hiện ba vấn đề: auth-service và notification-worker được cấp phát thừa (CPU 18–21%), api-gateway và cache-redis có kích thước phù hợp, và payment-processor đang thiếu tài nguyên nguy hiểm ở mức CPU 80–86% và bộ nhớ 88–94% — có nguy cơ cao bị OOM kill và gián đoạn dịch vụ.

  ### Xác định node chưa được tận dụng

  ```text theme={null}
  @kai #chart identify nodes with <30% CPU utilization
  ```

  <Frame>
    <img src="https://mintcdn.com/cloudthinker/0IKJjKZJEIROke98/images/use-cases/kubernetes-health-monitoring/04-node-cpu-utilization.jpg?fit=max&auto=format&n=0IKJjKZJEIROke98&q=85&s=6faab9bb595868b7077bc4e287558a51" alt="Phân tích mức sử dụng CPU node cho thấy instance chưa được tận dụng và lãng phí chi phí" width="2236" height="1544" data-path="images/use-cases/kubernetes-health-monitoring/04-node-cpu-utilization.jpg" />
  </Frame>

  <p style={{textAlign: 'center', fontSize: '0.9em', color: '#666', marginTop: '8px'}}>Phân tích mức sử dụng CPU node cho thấy instance chưa được tận dụng</p>

  Kai tìm thấy năm node có mức CPU trung bình dưới 30% (một số chỉ 12–15%), lãng phí khoảng \$573 mỗi tháng. Các instance t3.xlarge quá lớn chạy workload nhẹ — kết hợp với lịch trình pod kém — khiến một số node chỉ có 2–3 pod trong khi các node khác mang 8–9 pod.

  ### Nhận khuyến nghị HPA

  ```text theme={null}
  @kai #recommend HPA policies for web deployments
  ```

  <Frame>
    <img src="https://mintcdn.com/cloudthinker/0IKJjKZJEIROke98/images/use-cases/kubernetes-health-monitoring/05-hpa-policy-recommendations.jpg?fit=max&auto=format&n=0IKJjKZJEIROke98&q=85&s=c017e66acc6cba7ad980435e31c99a83" alt="Khuyến nghị chính sách HPA cho cấu hình auto-scaling web deployment" width="2238" height="1552" data-path="images/use-cases/kubernetes-health-monitoring/05-hpa-policy-recommendations.jpg" />
  </Frame>

  <p style={{textAlign: 'center', fontSize: '0.9em', color: '#666', marginTop: '8px'}}>Khuyến nghị chính sách HPA cho auto-scaling</p>

  Kai đánh dấu payment-processor là có rủi ro nghiêm trọng — chỉ có 2 replica ở mức CPU 80–86%, không có autoscaling. Kai khuyến nghị thêm HPA cho api-gateway để xử lý spike lưu lượng, và loại bỏ capacity dư thừa khỏi user-service và auth-service.
</Steps>

## Điều gì tạo nên hiệu quả

* **[Kai](/vi/guide/agents/kai)** truy vấn trực tiếp cluster API, thay thế các phiên `kubectl` thủ công và chuyển đổi công cụ.
* **Tương quan đa lớp** liên kết mức sử dụng pod, dung lượng node, và mẫu lịch trình trong một lượt phân tích duy nhất.
* **[`#report`](/vi/guide/language) và [`#chart`](/vi/guide/language)** tạo đầu ra có cấu trúc để Kai suy luận trước khi trình bày phát hiện.
* **[`#recommend`](/vi/guide/language)** tạo ra các thay đổi chính sách HPA có thể thực thi thay vì chỉ dump metrics thô.
* **[CloudKeepers](/vi/guide/infrastructure/cloudkeepers)** có thể chạy phân tích này theo lịch để phát hiện vấn đề trước khi kỹ sư trực bị gọi.

## Tự mình thử

<CardGroup cols={2}>
  <Card title="Tài liệu tham khảo agent Kai" icon="robot" href="/vi/guide/agents/kai">
    Toàn bộ khả năng của Kai, agent Kỹ sư Kubernetes
  </Card>

  <Card title="Kết nối Kubernetes" icon="https://mintcdn.com/cloudthinker/aLd-ttc-SCW-aFky/images/icons/kubernetes.svg?fit=max&auto=format&n=aLd-ttc-SCW-aFky&q=85&s=7c03292954ff635a1994623a5c39971b" href="/vi/guide/connections/kubernetes" width="24" height="24" data-path="images/icons/kubernetes.svg">
    Hướng dẫn từng bước kết nối CloudThinker với cụm EKS của bạn
  </Card>

  <Card title="Topology Explorer" icon="diagram-project" href="/vi/guide/infrastructure/topology">
    Vẽ sơ đồ phụ thuộc dịch vụ Kubernetes để phân tích nguyên nhân gốc rễ nhanh hơn
  </Card>

  <Card title="CloudKeepers" icon="radar" href="/vi/guide/infrastructure/cloudkeepers">
    Chạy kiểm tra sức khỏe liên tục trên workload Kubernetes của bạn một cách tự động
  </Card>
</CardGroup>
