How to calculate high watermark pod count
search cancel

How to calculate high watermark pod count

book

Article ID: 298563

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid Integrated Edition

Issue/Introduction

This article describes how an operator can calculate the high watermark pod count value for billing purposes in Pivotal Container Service (PKS) v1.3.

Environment


Resolution

To connect to the billing database, follow the instructions listed below: 

1. In a browser, navigate to Ops Manager.

2. Select the Pivotal Container Service tile.

3. Select the Status tab. Record the IP address that appears in the IPS column. 

4. Select the Credentials tab.

5. Click the credential link next to Cf Mysql Billing Db Password. Record the MySQL billing database password that appears.

6. SSH into the PKS VM using the following command:
$ bosh -e ENVIRONMENT -d pivotal-container-service/DEPLOYMENT-ID ssh pivotal-container-service/VM-ID
7. Log in to the billing database using the following command:
$ mysql -h IP-ADDRESS -u billing -p billing
When prompted by the command line, enter the MySQL billing database password you recorded earlier.


Viewing raw pod consumption data

To view the raw consumption data for all pods, run the following query: 
MariaDB [billing]> select * from pods;

Calculating the high watermark value

To calculate the high watermark value, run the following query:

SET @beginning_of_period = '2018-11-26 00:00:00';
SET @end_of_period = '2018-11-27 00:00:00';
SELECT MAX(number_of_pods) AS high_watermark
FROM (
       SELECT COUNT(DISTINCT main_table.id) AS number_of_pods
       FROM (SELECT first_seen AS sampling_timestamp
             FROM pods
             WHERE first_seen BETWEEN @beginning_of_period AND @end_of_period
             UNION ALL
             SELECT @beginning_of_period AS first_seen) AS sampling_table,
            pods main_table
       WHERE sampling_table.sampling_timestamp BETWEEN main_table.first_seen AND main_table.last_seen
       GROUP BY sampling_table.sampling_timestamp
       ORDER BY sampling_table.sampling_timestamp
     ) AS watermarks

Note: Modify the values for the beginning and end periods as needed.