<p>I've read some pages about monitoring k8s, and I found <strong><em>kubernetes_sd_config</em></strong> (within prometheus), <strong><em>metrics-server</em></strong> (took the place of <em>heapster</em>) and <strong><em>kube-state-metrics</em></strong>. All of them could provides metrics, but what's the difference? </p>

<ol>
<li>Does kubernetes_sd_config (within prometheus) provide all the data those I can get using metrics-server and kube-state-metrics? </li>
<li>Is kubernetes_sd_config just enough for monitoring? </li>
<li>Is metrics-server just for providing data (less than kubernetes_sd_config) to the internal components(such as hpa controller)?</li>
<li>Is kube-state-metrics just for the objects (pod, deployment...) in k8s?</li>
<li>what is their own target respectively?</li>
</ol>

woshilaiceshide
<p><strong>1</strong> <a href="https://github.com/kubernetes-incubator/metrics-server" rel="nofollow noreferrer">Metrics-server</a> is a cluster level component which periodically scrapes container CPU and memory usage  metrics from all Kubernetes nodes served by Kubelet through Summary API.</p>
<p>The Kubelet exports a &quot;summary&quot; API that aggregates stats from all pods.</p>
<pre><code>$ kubectl proxy &amp;
Starting to serve on 127.0.0.1:8001
$ NODE=$(kubectl get nodes -o=jsonpath=&quot;{.items[0].metadata.name}&quot;)
$ curl localhost:8001/api/v1/proxy/nodes/${NODE}:10255/stats/summary
</code></pre>
<p><strong>Use-Cases:</strong></p>
<ul>
<li>Horizontal Pod Autoscaler.</li>
<li><code>kubectl top --help</code>:  command.</li>
</ul>
<p><strong>2</strong> <a href="https://github.com/kubernetes/kube-state-metrics" rel="nofollow noreferrer">kube-state-metrics</a></p>
<blockquote>
<p>is focused on generating completely new metrics from Kubernetes' object state (e.g. metrics based on deployments, replica sets, etc.). It holds an entire snapshot of Kubernetes state in memory and continuously generates new metrics based off of it</p>
</blockquote>
<p><strong>Use-Cases</strong></p>
<ul>
<li>count the number of k8s Objects.</li>
<li>How many namespaces are there ?</li>
</ul>
<p><a href="https://sysdig.com/blog/introducing-kube-state-metrics/" rel="nofollow noreferrer">sysdig-k8s-state-metrics</a> provide the further Information.</p>
<p><strong>3</strong> <strong><a href="https://github.com/prometheus/node_exporter" rel="nofollow noreferrer">Prometheus Node_Exporter</a></strong> − Gets the host level matrices and exposes them to Prometheus.</p>
<p><strong>Use-Cases</strong></p>
<ul>
<li>User and Kernel Space level information.</li>
</ul>
<p>Lastly, <a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config" rel="nofollow noreferrer">kubernetes_sd_config</a> is the configuration file defines everything related to scraping targets.</p>
<p>You can decide in the config file what kind of information you want to gather and from whom.</p>
