# 7. Autoscale

### 7.1. **Enable autoscale trong khi tạo cluster**

**Bước 1:** Thực hiện thoa tác tạo 1 k8s cluster. Sau khi nhập đầy đủ thông tin cho 1 cluster cần tạo > Click vào **Autoscale** ở mục **Worker Configuration** để enable tính năng autoscale.

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2F01qBEDFAVNLRMCheEvyP%2Fauto1.png?alt=media\&token=5d5fac0f-f02e-489b-974c-31f80a04e9ae)

**Bước 2:** Lựa chọn thông số **Scale Min** (số lượng node còn lại khi scale down xuống) và Scale max (số lượng node tối đa có thể scale up lên) > Click **Create cluster**.

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2FRuQgulIfqNWBSRbmcGDE%2Fauto2.png?alt=media\&token=78f7ae28-9ace-4e20-b41f-81c00b2a537f)

<mark style="color:red;">Lưu ý: Khi nhập số lượng cho scale max/min thì phải check xem còn đủ quota không, nếu nhập vượt quá quota cho phép, thì sẽ hiển thị thông báo quota không đủ như phía dưới:</mark>

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2FFBptYNwbh2LWeVFfFFDq%2Fauto3.png?alt=media\&token=bed42b62-0cee-4533-b8a4-e5ff1ee53af7)

<mark style="color:red;">Để khắc phục khác phục thì giảm lượng scale max/min xuống mức quota cho phép.</mark>

### 7.2. **Enable autoscale sau khi đã tạo xong 1 cluster**

**Bước 1:** Từ menu chọn **Kubernetes** > Chọn cluster muốn enable Autoscale.

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2FDU8y28tOIzqBfdPwFxiA%2Fauto4.png?alt=media\&token=42fad1ac-8054-4f3d-b6e3-39d135294dfb)

**Bước 2:** Từ mục **Worker Config** chọn vào mục **Autoscale** > Nhập thông số **Scale min** (số lượng tối thiểu khi scale down worker) và **Scale max** (số lượng tối đa khi Scale up worker) cho tính năng autoscale > Click **Autoscale** để enable tính năng.

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2F398dRAz72ATudZWKQkip%2Fauto5.png?alt=media\&token=c0d64e64-73c2-4092-98a4-3a4eb7fa9b0b)

Sau khi click Autoscale thì status của cluster là Enable scaling. Quá trình Autoscale sẽ diễn ra tự động phù hợp với nhu cầu của bên người sử dụng.

### 7.3. Disable Autoscale

**Bước 1:** Từ Menu chọn **Kubernetes** > Chọn cluster muốn Disable Autoscale.

**Bước 2:** Trong mục **Worker Config** chọn **Autoscale**.

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2F1ZqcM5vjR3Aqm4flacu4%2Fauto6.png?alt=media\&token=8072baf1-6dbc-4e11-a356-f9461a3be607)

**Bước 3:** Chọn Action **Disable Autoscale** > Click button **Disable** để ngừng tính năng Autoscale hoặc **Cancel** để hủy bỏ thao tác.

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2FfeESjW7sRx70YkgBmpWu%2Fauto7.png?alt=media\&token=ca9eb3a5-47c7-485a-bf60-246b228c6f85)

Sau khi disable thì status của cluster là Disable Scaling và quá trình Autoscale sẽ ngừng hoạt động.

### 7.4. Update Autoscale

**Bước 1:** Từ Menu chọn **Kubernetes** > Chọn cluster muốn Update Autoscale.

**Bước 2:** Trong mục **Worker Config** chọn **Autoscale** > Chọn Action **Update Autoscale** > Nhập thông số **Scale max** và **Scale min** worker nodes muốn điều chỉnh cho tính năng Autoscale > Chọn **Update** để thực hiện hoặc **Cancel** để hủy bỏ thao tác.

![](https://2837260264-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F18Kpdo0VNH9pUQatMCfo%2Fuploads%2Fg0p0UTfHPRbbvgQLIXIF%2Fauto8.png?alt=media\&token=cd198ad9-98df-49e6-a9e4-d78c1cfbf7e5)

Sau khi update status của cluster là Update Scaling. Người dùng check lại số lượng Scale max và min worker nodes sau khi update lại.
