K8sConntrack
What is K8sConntrack
K8sConntrack keeps track of networking metrics of communication between pods in Kubernetes cluster.
Right now it helps to answer the following questions:
- It exposes the number of transactions for applications at the service level. So it helps users to understand how the applications are used and determine whether to scale out/in applications automatically based on QoS.
- It exposes end-to-end traffic information among pods in Kubernetes cluster. So that users can understand the communication pattern between the pods and make initial placement or replacement based on networking topology.
Architecture
![K8sConntrack Architecture](https://cloud.githubusercontent.com/assets/7660489/18649719/03feeb8a-7e8f-11e6-9995-9de6ec9e05b3.png)
Run K8sConntrack inside Kubernetes
As K8sConntrack gathers networking metrics from netfilter, it requires to deploy K8sConntrack application on every node in the Kubernetes cluster. The best way to deploy K8sConntrack in a Kubernetes cluster is to deploy it as DaemonSet.
You can find deploy guide for different scenarios here
How to get metrics from K8sConntrack
Metrics are exposed on port 2222 of each host.
Transaction Metrics
Transaction metrics expose serviceID and the number of transactions of each endpoint.
To get transaction metrics, go to <HOST_IP>:2222/transactions, an output example is like the following:
[{
"serviceID":"default/redis-slave",
"endpointCounter":{
"172.17.0.4":3,
"172.17.0.5":2
}
}]
Flow Metrics
Flow metrics expose the amount of traffic between two endpoints in bytes.
To get flow metrics, go to <HOST_IP>:2222/flows
[{
"uid":"172.17.0.3:6379->172.17.0.5:38318#1471007430",
"source":"172.17.0.3",
"destination":"172.17.0.5",
"value":52,
"timestamp":1471010475
}]