Skip to content

How to Collect Kubernetes Resources


Introduction

TrueWatch supports monitoring the operational status and service capabilities of various resources in Kubernetes, including CONTAINERS, Pods, Services, Deployments, Clusters, Nodes, Replica Sets, Jobs, Cron Jobs, etc. You can install DataKit via DaemonSet in Kubernetes to collect data from Kubernetes resources. Ultimately, you can monitor the operational conditions of various Kubernetes resources in TrueWatch in real time.

Prerequisites

You need to first create a TrueWatch account.

Methods/Steps

There are two ways to install DataKit via DaemonSet in Kubernetes:

  • Helm Installation
  • Yaml Installation

Helm Installation

Prerequisites

  • Kubernetes >= 1.14
  • Helm >= 3.0+

Step1: Add the DataKit Helm Repository

To install DataKit using Helm for collecting Kubernetes resources, you first need to install Helm on your server. After installing Helm, you can add the DataKit Helm repository.

Note: After adding the DataKit Helm repository, you must run the update command helm repo update.

$ helm repo add datakit https://pubrepo.truewatch.com/chartrepo/datakit
$ helm repo update

Step2: Helm Install DataKit

Modify the token data in the datakit.dataway_url when executing the Helm installation command for DataKit.

$ helm install datakit datakit/datakit -n datakit --set datakit.dataway_url="https://openway.truewatch.com?token=<your-token>" --create-namespace

The token can be obtained in the "Manage" - "Basic Settings" section of the TrueWatch workspace.

After replacing the token, execute the Helm installation command for DataKit.

Step3: Check Deployment Status

Once DataKit is installed, you can check the deployment status by running $ helm -n datakit list.

Step4: View and Analyze Collected K8S Data in TrueWatch Workspace

If the DataKit deployment status is normal, you can view and analyze the collected K8S data in the TrueWatch workspace under "Infrastructure" - "Containers".

Yaml Installation

Step1: Download the yaml File

Before starting the collection of Kubernetes resources, use a terminal tool to log into the server and execute the following script command to download the yaml file.

wget https://static.truewatch.com/datakit/datakit.yaml

Step2: Modify the datakit.yaml File

Edit the configuration for the data gateway (dataway) in the datakit.yaml file and replace the token with the workspace token.

    - name: ENV_DATAWAY
        value: https://openway.truewatch.com?token=<your-token> # Enter your workspace token here

The token can be obtained in the "Manage" - "Basic Settings" section of the TrueWatch workspace.

After replacing the token, save the datakit.yaml file.

Step3: Install the yaml File

After modifying the data gateway in the datakit.yaml file, use the command kubectl apply -f datakit.yaml to install the yaml file. The filename should match what you saved it as.

Step4: Check the Running Status of Datakit

After installing the yaml file, a DaemonSet deployment of datakit will be created, and you can check the running status of datakit using the command kubectl get pod -n datakit.

Step5: View and Analyze Collected K8S Data in TrueWatch Workspace

If the datakit is running normally, you can view and analyze the collected K8S data in the TrueWatch workspace under "Infrastructure" - "Containers".