Kubernetes

Install Metric Agent at Kubernetes Cluster

You can install vMonitor Platform Metric Agent into your Kubernetes Cluster to collect and push metrics to the vMonitor Platform site, then use the features at vMonitor Platform to centrally manage resources and monitor unusual activity of your Kubernetes Cluster. .


Install Metric Agent using Helm

Preparation steps before installation

1. Check that you have the Metric Quota and that your quota has not reached the limit. If you do not have it, you need to buy the Metric Quota here .

2. Create a Service Account and attach policy: vMonitorMetricPush to have enough rights to push Metric to vMonitor Platform. To create a service account, go here , then perform the following steps:

  • Select " Create a Service Account ", enter a name for the Service Account and click Next Step to assign permissions to the Service Account

  • Find and select Policy: vMonitorMetricPush, then click " Create a Service Account " to create a Service Account, Policy: vMonitorMetricPush created by VNG Cloud only contains the correct permission to push metrics to the system.

  • After successful creation, you need to save the Client_ID and Secret_Key to perform the next step.

Install helm on Debian/Ubuntu server

1. You need to install Helm on a server with kubeconfig containing enough permissions to interact with the Kubernetes Cluster.

  • Check permissions with kubectl command :

# Lệnh dùng để kiểm tra quyền tương tác tất cả resource tại namespace default
kubectl auth can-i '*' '*'
# Lệnh dùng để kiểm tra quyền tương tác tất cả resource tại namespace chỉ định, sử dụng lệnh này khi bạn muốn cài đặt agent metric tại namespace khác
kubectl auth can-i -n <namespace_chỉ_định> '*' '*'
# Lệnh dùng để kiểm tra quyền tạo clusterrole và clusterrolebinding
kubectl auth can-i create clusterrole
kubectl auth can-i create clusterrolebinding
  • If the result of the above commands is YES , then you have enough rights.

2. Proceed to install Helm

  • Execute the following commands:

  • Check that Helm has been installed successfully

To install Helm on other operating systems, please refer to the installation instructions here: Install Helm Through Package Managers .

3. Some additional notes about Helm: (see details at: helm docs )

  • Helm will use kubeconfig to interact with the cluster, by default helm will use config in the path: "~/.kube/config"

  • If we need to change the path to kubeconfig we can use 2 ways:

    • To each helm command you can add the --kubeconfig option: for example helm install --kubeconfig <path_to_kubeconfig>

    • Declare environment variable: KUBECONFIG


Install Metric Agent

By default, when installing vMonitor Platform Metric Agent, there will be 2 components:

  • Deployment Agent kube-state-metrics : collect metrics for each resource of k8s cluster (pod, daemonset, deployment, replicaset, ....)

  • Daemonset Agent : collect metrics for each k8s cluster node (CPU, Memory usage, ...)

1. Add Helm vMonitor Platform Repo as command

2. Install charts

  • Install at default namespace (add flag -n <namespace_specified> to install agent at another namespace)

  • In there:

    • <YOUR_CLIENT_ID_XXXXXXXXXXXXXXXXXXX>, <YOUR_CLIENT_SECRET_XXXXXXXXXXXXXXX>: Service account information created in the preparation step

    • <CLUSTER_NAME>: This information will be used to filter hosts of k8s cluster in case there are many clusters to monitor

  • Check the successful installation of the agent via command

After installation is complete, kubernetes tracking metrics have been pushed to the vMonitor Platform site, you can proceed to vMonitor Platform to draw dashboards and widgets.


Uninstall Metric Agent

Execute the following command to delete the installed related k8s resources:

Metric Agent installation does not use kube-state-metrics

  • Install at default namespace (add flag -n <namespace_specified> to install agent at another namespace)


Monitor Kubernetes (K8S) at vMonitor Platform

To perform a Kubernetes (K8S) monitor at vMonitor Platform, please follow the instructions below:

Step 1 : Install helm from API for Debian/Ubuntu operating system, you should install Helm on the machine with kubeconfig and have enough rights to access the Kubernetes Cluster you need to monitor

  • Execute the following commands

For other operating systems , you can refer to the installation instructions here: Install Helm Through Package Managers

  • Check that helm has been installed successfully with the command

Step 2 : Check permissions to interact with k8s cluster

  • Some notes about helm: (see details at: helm docs )

    • Helm will use kubeconfig to interact with the cluster, by default helm will use config in the path: "~/.kube/config"

    • If we need to change the path to kubeconfig we can use 2 ways:

      • For each helm command, add the --kubeconfig option: for example, helm install --kubeconfig <path_to_kubeconfig>

      • Declare environment variable: KUBECONFIG

  • Check permissions:

    • Use the kubectl command:

If the results of the above commands are YES, then you have enough rights to perform the next steps

Step 3 : Install kube-state-metrics using helm

  • Check that the installation of kube-state-metrics was successful

Attention:

  • Currently vMonitor metric agent only supports kube-state-metrics version <= v2.7.0.

Step 4 : Install vmonitor metric agent using helm

By default, vMonitor metric agent will have 2 components: deployment used to collect kube-state-metrics and daemonset component to collect metrics for each k8s node

  • Add vMonitor helm repository

  • Install vmonitor-metric-agent from the helm repository, by default it will be installed in namespace:default, if you want to install in another namespace, add the –n option in the command below, you can change the name vng-vmonitor- metric-agent to whatever name you want and change k8s-cluster-name to your Kubernetes Cluster name

  • Check that the agent installation was successful

Step 5: After installing all kubernetes tracking metrics have been pushed, you can proceed to vMonitor to draw dashboards and widgets.

  • If you no longer need to use vmonitor metric agent, you can uninstall it with the command below

Attention:

  • When monitoring Kubernetes with vMonitor Platform, you are currently only charged for the number of Hosts into the Quota, the number of Hosts will be calculated by the number of kubelet worker nodes you have plus 1. The number of Containers per Host will not be counted. this moment.

Last updated