Skip to main content
This use case provides an overview of how to collect Kubernetes container data into Densify and how to obtain Densify container recommendations. The diagram below shows the major processes in Densify to optimize Kubernetes containers:
  1. Data Collection—Collect Kubernetes data into Densify.
You need to have an existing monitoring and metrics collection service, such as Prometheus, configured for your container clusters. See Container Prerequisites for details. Densify provides a collection and transfer tool called the Data Forwarder, which you can download from Docker Hub, configure, and launch into a container to transfer node information and resource metrics from Prometheus to Densify. Your Densify instance needs to be enabled with Data Forwarder support to accept and ingest incoming data for optimization. Contact Densify support (Support@Densify.com) to enable Data Forwarder support.
You will need a Data Forwarder container for each Prometheus server you want to collect data from.
  1. Analysis—Analyze collected data based on pre-defined policies to make recommendations.
The analysis process is initiated after data is ingested into a Densify data model. Results can be pulled from the Densify API or pushed to a webhook URI once the analysis is complete. The steps below outline a typical workflow to access Kubernetes container recommendations:
  1. From the Densify API: Authenticate using JWT—Retrieve token to authenticate each subsequent API call.
  2. API: List All Kubernetes Container Analyses—Query for the analysis entity of each cluster for which Kubernetes container data was collected.
  3. API: Download Results for Action—Retrieve recommendations for actioning or forward to orchestration engine. Alternatively, you can Add a Webhook to an Existing Kubernetes Container Analysis to push recommendations to an external URI once the next analysis process completes.
  4. Console (optional alternative): Review the Kubernetes Container Optimization report from the Densify Console. See Optimizing Your Containers for details.

Postman Collection

Densify provides a Postman collection of sample API requests for working with your public cloud environments. See the Postman Collection.

Authenticate using JWT

Use the /authorize resource to retrieve an authenticated token to make subsequent API calls. See Authorize for details. By default, the token expires in 5 minutes, therefore you will need to ensure that you have an active token for each Densify API request.
Request:
POST /authorize
{
    "userName": "apiUser",
    "pwd": "apiPassword"
}
Response:
{
  "apiToken": "eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIzNzI2Yzk0NC0wMmE4LTRlYzQtOGE2Ny04ODBmMDM2OTRhZDciLCJpYXQiOjE1NDI2NTI0MDUsInN1YiI6InZhbiIsImlzcyI6IkRlbnNpZnkuY29tIiwiZXhwIjoxNTQyNjUyNzA1fQ.cJd8qFJfRoPnMEU7GzcdYGBT8WwlgmviQ1OQp8P_w9VUcjQA3FJaB9QkqJJ6d7zbrY5yjc4w0rOWjY-PPdbmqw",
  "expires" : 1542652705869,
  "status" : 200
}
Use the apiToken value in your Authorization request header for subsequent Densify API calls.

List All Kubernetes Container Analyses

To see a list of all Kubernetes analyses currently in Densify, use the /analysis/containers/kubernetes resource. See List all analyses for a particular platform and vendor for details of the resource operation.
Request:
GET /analysis/containers/kubernetes
Response:
  {
    "analysisId": "d7298ac3-a143-41bb-b7d7-62f659f2a8c5",
    "analysisName": "WEST222-Bench",
    "analysisCompletedOn": 1548889723847,
    "href": "/analysis/containers/kubernetes/d7298ac3-a143-41bb-b7d7-62f659f2a8c5",
    "analysisResults": "/analysis/containers/kubernetes/d7298ac3-a143-41bb-b7d7-62f659f2a8c5/results",
    "analysisStatus": "/analysis/containers/kubernetes/d7298ac3-a143-41bb-b7d7-62f659f2a8c5/status"
  }

Poll for Analysis Status

Use the "analysisStatus" resource element from the List All Kubernetes Container Analyses response to poll for status of the data collection and analysis. See Check for analysis status for details of the resource operation. The analysis is complete and recommendations are available when "analysisStage": "Completed".
Request:
GET analysis/containers/kubernetes/d7298ac3-a143-41bb-b7d7-62f659f2a8c5/status
Response:
{
  "analysisStage": "Completed",
  "webHookStatus": "",
  "statusMessage": "Analysis WEST222-Bench was last completed on Wed Jan 30 19:03:41 EST 2019."
}

Add a Webhook to an Existing Kubernetes Container Analysis

You can add a webhook definition to an existing Kubernetes container analysis. The analysis will push the optimized results to the specified webhook URI. See Analysis: Webhook for details on managing webhooks.
Request:
POST /webhook/analysis/containers/kubernetes/d7298ac3-a143-41bb-b7d7-62f659f2a8c5
{
  "uri": "https://myInstanceConfigServer:443/api/densify/ContainerResults",
  "authType": "bearer",
  "authValue": "eyJhbGciOiMsIUzUxMiJ9.eyJqdGkiOiJhYWU2MjIxOS1iOWQyLTQ3OGMtYWI3Mi00NGU2OTUzY2RjMDEiLCJpYXQiOjE1NDM2MDgxMTEsInN1YiI6ImFkbWluIiwiaXNzIjoiRGVuc2lmeS5jb20iLCJleHAiOjE1NDM2MDg0MTF9.h3bJrAP-Z2LeqzjN3FYpFDyoaADvYT1MdLw5SuguqkGE7sjB4c7YgQgv3saj15r2IsgTWH8PW7eNnoZwFP9eiQ"
}
Response:
{
  "message": "ok",
  "status": 200
}

Download Results for Action

Use the /analysis/containers/kubernetes/<analysisId>/results resource to retrieve recommendation results and forward to orchestration engine. See Analysis: Kubernetes Container Recommendations for details.
Request:
GET /analysis/containers/kubernetes/d7298ac3-a143-41bb-b7d7-62f659f2a8c5/results
Headers:
Accept: application/terraform-map
Authorization: Bearer <apiToken>