Skip to content

Commit e828035

Browse files
authored
Write billing and usage guide docs (#77)
Signed-off-by: Imtiaz Uddin <imtiaz@appscode.com>
1 parent 79d78b7 commit e828035

16 files changed

Lines changed: 289 additions & 2 deletions

src/_home-billing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
menu:
3+
home_menu:
4+
identifier: home-billing
5+
name: Billing and Usage Guide
6+
description: Billing and Usage Guide for AppsCode's products
7+
link: /en/guides/billing-and-usage-guide/overview.html
8+
icon: https://img.icons8.com/external-anggara-basic-outline-anggara-putra/96/external-stats-ui-anggara-basic-outline-anggara-putra.png
9+
weight: 20
10+
---
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
layout: 'guide'
3+
menu:
4+
docs_menu:
5+
identifier: billing-and-usage-guide
6+
name: Billing and Usage Guide
7+
description: Billing and Usage Guide for AppsCode's products
8+
icon: https://img.icons8.com/external-anggara-basic-outline-anggara-putra/96/external-stats-ui-anggara-basic-outline-anggara-putra.png
9+
popular: true
10+
weight: 50
11+
menu_name: docs_menu
12+
section_menu: guides
13+
---
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
layout: 'guide'
3+
menu:
4+
docs_menu:
5+
identifier: billing-and-usage-guide-cost-management
6+
name: Cost Management
7+
parent: billing-and-usage-guide
8+
weight: 40
9+
home_menu:
10+
identifier: billing-and-usage-guide-cost-management
11+
name: Cost Management
12+
parent: home-billing
13+
weight: 40
14+
menu_name: docs_menu
15+
section_menu: guides
16+
---
17+
18+
## **Cluster and Namespace Configuration for Cost Management**
19+
20+
For effective cost management, users can configure their clusters and namespaces. This section covers how to set a cluster's mode to **PROD** or **NON-PROD** for different billing rates, and how to enable a one-month free trial for KubeDB resources in a specific namespace.
21+
22+
### **Configuring Cluster Mode (PROD vs. NON-PROD)**
23+
24+
We offer different billing rates for production (**PROD**) and non-production (**NON-PROD**) environments. To distinguish between these, the user must set an annotation on the kube-system namespace of the cluster. The system considers a cluster as **PROD** only if the mode is explicitly set to `prod`. All other modes (`qa`, `staging`, `dev`) are treated as **NON-PROD**.
25+
26+
**To set the cluster mode:**
27+
28+
1. Identify the kube-system namespace in the cluster.
29+
2. Apply the following annotation: `cluster.appscode.com/mode`.
30+
31+
Here are the possible values for the annotation:
32+
33+
| Value | Cluster Mode Interpretation |
34+
| :---- | :---- |
35+
| prod | **PROD** (Production) |
36+
| qa | **NON-PROD** (Quality Assurance) |
37+
| staging | **NON-PROD** (Staging) |
38+
| dev | **NON-PROD** (Development) |
39+
40+
**Example using kubectl:**
41+
42+
To set a cluster to **PROD** mode, run the following command:
43+
44+
```shell
45+
kubectl annotate namespace kube-system cluster.appscode.com/mode=prod --overwrite
46+
```
47+
48+
To set it to a **NON-PROD** mode like staging, run:
49+
50+
```shell
51+
kubectl annotate namespace kube-system cluster.appscode.com/mode=staging --overwrite
52+
```
53+
54+
### **Enabling the One-Month Free Resource Trial**
55+
56+
Users can get a one-month free trial for every KubeDB database running within a specific namespace. This allows for evaluation of the service without incurring costs during the trial period.
57+
58+
To enable the free trial, the user needs to add a specific annotation to the desired namespace.
59+
60+
- **Who applies this:** In a DBaaS setup, downstream users typically do not have direct access to the cluster. The annotation must be applied by the cluster/infra administrator who manages the cluster.
61+
- **Where it can be used:** The trial can be enabled in namespaces on both **PROD** and **NON-PROD** clusters. While the trial is active, eligible database usage is counted as **free usage** (not billed and reported as Free usage in the Billable section), regardless of cluster mode. After the trial ends for a database, subsequent usage follows the cluster's pricing mode (**PROD** or **NON-PROD**) and your contract status (paid contract vs. the 30‑day free contract when no paid contract exists).
62+
63+
**To enable the trial:**
64+
65+
1. Select the namespace that contains your KubeDB databases. Any existing databases in this namespace that have not previously received a trial will receive a one-month free trial starting from when the annotation is applied. Any databases created later in this namespace will also automatically receive a one-month free trial. Databases that have already used a trial are not eligible again.
66+
2. Apply the annotation `ace.appscode.com/enable-resource-trial` with the value `true`.
67+
68+
**Example using kubectl:**
69+
70+
To enable the free trial for a namespace named `my-app-ns`, run the following command:
71+
72+
```shell
73+
kubectl annotate namespace my-app-ns ace.appscode.com/enable-resource-trial=true --overwrite
74+
```
75+
76+
Once this annotation is applied, all KubeDB resources deployed within the my-app-ns namespace will automatically receive a one-month free trial.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
layout: 'guide'
3+
menu:
4+
docs_menu:
5+
identifier: billing-and-usage-guide-dbaas-client-billing
6+
name: DBaaS Client Billing
7+
parent: billing-and-usage-guide
8+
weight: 30
9+
home_menu:
10+
identifier: billing-and-usage-guide-dbaas-client-billing
11+
name: DBaaS Client Billing
12+
parent: home-billing
13+
weight: 30
14+
menu_name: docs_menu
15+
section_menu: guides
16+
---
17+
18+
### **DBaaS Provider Billing APIs**
19+
20+
This section is intended for DBaaS providers (self-hosted administrators) who manage the platform for end-users. To help providers monitor the resource consumption of their clients, we expose a set of APIs that deliver detailed usage reports for specific namespaces. This is particularly useful for billing, resource planning, and gaining insights into how end-users are utilizing the KubeDB resources within their assigned namespaces.
21+
22+
#### **Prerequisites: Enabling Client Billing**
23+
24+
Before these APIs can be used, the **Client Billing** feature must be enabled in your contract with us. This is a digital agreement that activates the necessary backend services to collect and expose usage data for your clients' namespaces from our central system.
25+
26+
For more information on how to view or modify your contract, please refer to the [official contract management documentation](https://appscode.com/docs/en/guides/license-management/contract.html) or contact [AppsCode administrators](https://appscode.com/contact/). Once **Client Billing** is enabled in your contract, you can proceed to use the API endpoints detailed below.
27+
28+
### **Authentication**
29+
30+
To use these APIs, you must authenticate your requests. Usage information is collected and stored in our central system, and accessing it requires a secure token.
31+
32+
1. **Generate an Access Token:** Create a user-scoped API token from your account.
33+
- Go to User Settings and open the `Tokens` tab, then click on `Generate Token`.
34+
![Navigate to API Tokens](./images/create-token-ui-navigation.png)
35+
- Provide a token name and (optionally) an expiry, then click on `Generate`.
36+
![Create token options](./images/create-token-options.png)
37+
- Copy the token and store it securely. It’s shown only once.
38+
![Copy the generated token](./images/created-token-result.png)
39+
2. **Use as a Bearer Token:** This token must be included in the Authorization header of your API requests as a Bearer token.
40+
41+
**Example Header:** Authorization: Bearer <YOUR_ACCESS_TOKEN>
42+
43+
**Note:** Treat this access token as a confidential credential. Do not expose it in client-side code or public repositories.
44+
45+
### **Information Available for Client-Side Billing**
46+
47+
The billing reports expose the following information for use in customer invoicing and internal chargeback. This section describes what you can expect to see; the next section explains how to query it via APIs.
48+
49+
1) Namespace Level
50+
- **Database Information:** Identifies the type of database deployed in each namespace (for example, MongoDB, PostgreSQL, MySQL), along with the database name as visible to the platform.
51+
52+
2) Database Level
53+
- **Pod Details:**
54+
- **Flavor:** CPU and Memory allocation for each pod.
55+
- **Age of Pod:** Duration since pod creation.
56+
- **Number of Pods:** Total pod count, including autoscaling pods.
57+
- Volume Details:
58+
- **Volume Name:** Name of the persistent volume.
59+
- **Initial Size:** Initial size of the volume at creation.
60+
- **Expanded Sizes:** Any volume size increases, including the size and timestamp of each expansion.
61+
- **Volume Created At:** Timestamp when the volume was created.
62+
- **Volume Age:** Duration since the volume was created.
63+
- **Volume Expansion History:** Record of any expansion events, with size and timestamp.
64+
- **Volume Deleted At:** Timestamp when the volume was deleted (if applicable).
65+
66+
**Notes:** Timestamps are reported in UNIX time. Sizes are returned as strings with Gi units (for example, '10Gi').
67+
68+
### **API Endpoints**
69+
70+
The following APIs are available to retrieve billing and usage reports.
71+
72+
#### **1. Get Usage Reports for All Namespaces**
73+
74+
This endpoint retrieves a consolidated usage report for all namespaces that are bound to your client organizations. It is ideal for generating auditing reports and getting a high-level overview of resource consumption.
75+
76+
* **Endpoint:**
77+
> GET https://appscode.com/api/v1/dbaas/billing/reports/namespaces
78+
* **Description:** Returns a list of usage reports, with each report corresponding to a namespace managed under your DBaaS platform. This endpoint is particularly useful for auditing, billing reconciliation, and high‑level usage analysis.
79+
* **Query Parameters:**
80+
* **org** (string, optional): The organization name in the central **appscode.com** platform that owns your billing contract and receives usage from your self-hosted installation. The authenticated user must be a member of this organization. Use this to restrict results to namespaces reported under that org.
81+
* **Limitations:**
82+
* The current implementation does not support pagination. As a result, the endpoint returns all available namespaces, which may lead to large response sizes over time.
83+
* Resources (including namespaces, pods, and volumes) that were deleted more than six months ago are automatically excluded from the response.
84+
* **Example Response:** The response will contain a list of namespace reports. Each report includes cluster information, namespace details, and a breakdown of the databases running within that namespace. Please see the [Additional Resources](#additional-resources) section below for detailed response schema and example.
85+
86+
#### **2. Get Usage Report for a Specific Namespace**
87+
88+
This endpoint allows you to drill down and retrieve a detailed usage report for a single, specific namespace within a given cluster. This is useful for generating invoices or analyzing the consumption of a particular client.
89+
90+
* **Endpoint:**
91+
> GET https://appscode.com/api/v1/dbaas/billing/reports/clusters/{clusterID}/namespaces/{namespace}
92+
* **Description:** Returns a detailed usage report for the specified namespace, including information about the cluster, the namespace itself, and all KubeDB resources deployed within it.
93+
* **Path Parameters:**
94+
* **clusterID** (string, required): The unique identifier of the spoke cluster where the namespace is located.
95+
* **namespace** (string, required): The name of the namespace for which the report is being requested.
96+
* **Query Parameters:**
97+
* **org** (string, optional): The organization name in the central **appscode.com** platform that owns your billing contract and to which your self-hosted app reports usage. The authenticated user must be a member of this organization. Provide the org created for your DBaaS customer to target the correct data.
98+
* **Cautions:**
99+
* The namespace name provided in the path should be unique within the specified cluster, or unique across all clusters if you need to ensure you are targeting the correct one.
100+
* In the self-hosted platform, each **client organization** (client-org) name must be unique because the DBaaS namespace is created with exactly the same name as that client-org. This one-to-one mapping means duplicate client-org names will cause namespace conflicts.
101+
* You can optionally add an annotation to the namespace to tag the downstream end-user (for example, a customer ID or external reference) so you can map reports back to your own user records.
102+
* **Response Breakdown:** The JSON response for a single namespace provides granular details:
103+
* **clusterInfo**: Contains metadata about the cluster, such as its name, Kubernetes version, provider, and resource capacity.
104+
* **namespaceInfo**: Includes the namespace's labels, annotations, and creation timestamp.
105+
* **databases**: An array of objects, where each object represents a KubeDB instance and contains:
106+
* **databaseInfo**: Basic details like the database kind, product, and resource name.
107+
* **podDetails**: Information about the pods, including CPU and memory resources allocated.
108+
* **volumeDetails**: Details about the persistent volumes, including their initial size and any expansion history.
109+
110+
For full field-by-field schemas, sample payloads, and screenshots, see the [Additional Resources](#additional-resources) section below.
111+
112+
### **General API Cautions**
113+
114+
- **Time Format:** All time-related values in the API responses (e.g., createdAt, lastReceivedAt) are represented in the **UNIX time format**.
115+
- **Data Retention:** The API response does not include resources (namespaces, pods, volumes, etc.) that were deleted more than **six months ago**.
116+
117+
### **Additional Resources**
118+
- **Document Files:** For related document files, please access the following shared drive: [DBaaS Billing API Documents](https://drive.google.com/drive/u/1/folders/14ccceVuJQCKLvi9iSswnz86LqvB3Dfeq)
159 KB
Loading
377 KB
Loading
264 KB
Loading
260 KB
Loading
103 KB
Loading
74.8 KB
Loading

0 commit comments

Comments
 (0)