# Create a Cluster via API

### Introduction

The VKS API allows users to automate the creation of **Clusters** and **Node Groups** instead of manual operations on the portal.\
Detailed documentation: [https://docs.api.vngcloud.vn/service-docs/vks-api.html](https://docs.api.vngcloud.vn/service-docs/vks-api.html?utm_source=chatgpt.com)

***

### Prerequisites

| Component                    | Description                     |
| ---------------------------- | ------------------------------- |
| **Token**                    | Valid Bearer token              |
| **VPC / Subnet**             | Already created                 |
| **Image / Flavor**           | Check valid list                |
| **SSH Key / Security Group** | Used for access & node security |

***

### Create Cluster + Node Group via API

**Endpoint:**

```
POST /v1/clusters
```

**Example Body:**

```json
{
  "name": "cluster-demo-01",
  "version": "v1.29.13-vks.1740045600",
  "description": "Cluster demo created via API",
  "isBuyMorePoc": false,
  "isPoc": false,
  "isEnableAutoRenew": false
  "enablePrivateCluster": false,
  "networkType": "CILIUM_OVERLAY",
  "ipipEncapsulationMode": "ALWAYS",
  "cidr": "192.168.0.0/16",
  "vpcId": "net-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "subnetId": "sub-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "whitelistIp": "0.0.0.0/0",
  "nodeGroups": [
    {
      "name": "nodegroup-demo",
      "numNodes": 3,
      "enableAutoHealing": true,
      "autoScaleConfig": null,
      "upgradeConfig": {
        "maxSurge": 1,
        "maxUnavailable": 0,
        "strategy": "SURGE"
      },
      "enablePrivateNodes": false,
      "imageId": "img-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "flavorId": "flav-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "diskSize": 100,
      "diskType": "vtype-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "securityGroups": ["secg-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"],
      "sshKeyId": "ssh-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "labels": {},
      "taints": [],
      "subnetId": "sub-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "enabledEncryptionVolume": false
    }
  ],
  "enabledBlockStoreCsiPlugin": true,
  "enabledLoadBalancerPlugin": true,
  "enabledServiceEndpoint": false,
  "autoUpgradeConfig": null,
  "releaseChannel": "STABLE",
  "fleetConfig": null
}
```

***

### Create a standalone Node Group via API

**Endpoint:**

```
POST /v1/clusters/{clusterId}/node-groups
```

The body is similar to the `nodeGroups` section above.

***

### Other APIs

| Purpose        | API                                |
| -------------- | ---------------------------------- |
| List Clusters  | `GET /v1/clusters`                 |
| Delete Cluster | `DELETE /v1/clusters/{id}`         |
| Get kubeconfig | `GET /v1/clusters/{id}/kubeconfig` |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vngcloud.vn/vng-cloud-document/vks/getting-started/create-a-cluster-via-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
