<p>I like to see how my services will work on kubernethes so I can optimize my code and set good values for request/limit on both CPU and memory.</p>
<p>To do that I have tried kubectl top bit ot only gives me the current usage.</p>
<pre><code>kubectl top pod podname
</code></pre>
<p>How do I get the init, min and max usage?</p>
<p>If it is not possible to get all those values, is there any way to get max usage?</p>

Ashkan S
<p>In order to see stats you may want to use one of these <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/" rel="nofollow noreferrer">monitoring tools</a>:</p>
<ol>
<li><a href="https://github.com/google/cadvisor" rel="nofollow noreferrer">cAdvisor</a></li>
</ol>
<blockquote>
<p>Container Advisor is a great monitoring tool that provides
container-level metrics and exposes resource usage and performance
data from running containers. It provides quick insight into CPU
usage, memory usage, and network receive/transmit of running
containers. cAdvisor is embedded into the kubelet, hence you can
scrape the kubelet to get container metrics, store the data in a
persistent time-series store like Prometheus/InfluxDB, and then
visualize it via Grafana.</p>
</blockquote>
<ol start="2">
<li><a href="https://github.com/kubernetes-sigs/metrics-server" rel="nofollow noreferrer">Metrics Server</a></li>
</ol>
<blockquote>
<p>Metrics Server is a cluster-wide aggregator of resource usage data and
collects basic metrics like CPU and memory usage for Kubernetes nodes,
pods, and containers. It’s used by Horizontal Pod Autoscaler and the
Kubernetes dashboard itself, and users can access these metrics
directly by using the kubectl top command. Metrics Server replaces
Heapster as the primary metrics aggregator in the cluster, which has
been marked as deprecated in the newer version of Kubernetes.</p>
</blockquote>
<ol start="3">
<li><a href="https://github.com/prometheus/node_exporter" rel="nofollow noreferrer">Node Exporter</a></li>
</ol>
<blockquote>
<p>Node Exporter is the Prometheus exporter for hardware and operating
system metrics. It allows you to monitor node-level metrics such as
CPU, memory, filesystem space, network traffic, and other monitoring
metrics, which Prometheus scraps from a running node exporter
instance. You can then visualize these metrics in Grafana.</p>
</blockquote>
<ol start="4">
<li><a href="https://github.com/kubernetes/kube-state-metrics" rel="nofollow noreferrer">Kube-State-Metrics</a></li>
</ol>
<blockquote>
<p>Kube-state-metrics is an add-on agent that listens to the Kubernetes
API server. It generates metrics about the state of the Kubernetes
objects inside the cluster like deployments, replica sets, nodes, and
pods.</p>
<p>Metrics generated by kube-state-metrics are different from resource
utilization metrics, which are primarily geared more towards CPU,
memory, and network usage. Kube-state-metrics expose critical metrics
about the condition of your Kubernetes cluster:</p>
<ul>
<li>Resource requests and limits</li>
<li>Number of objects–nodes, pods, namespaces, services, deployments</li>
<li>Number of pods in a running/terminated/failed state</li>
</ul>
</blockquote>
<ol start="5">
<li><a href="https://prometheus.io/docs/prometheus/latest/getting_started/" rel="nofollow noreferrer">Prometheus</a></li>
</ol>
<blockquote>
<p>Prometheus is a free software application used for event monitoring
and alerting. It records real-time metrics in a time series database
built using a HTTP pull model, with flexible queries and real-time
alerting</p>
</blockquote>
<p>You can visualize Prometheus monitoring data with <a href="https://grafana.com/" rel="nofollow noreferrer">Grafana</a>
and its <a href="https://grafana.com/grafana/dashboards?search=pod" rel="nofollow noreferrer">dashboard collection</a>.</p>
<p>You can find detailed <a href="https://medium.com/better-programming/monitor-your-kubernetes-cluster-with-prometheus-and-grafana-1f7d0195e59" rel="nofollow noreferrer">Monitor Your Kubernetes Cluster With Prometheus and Grafana</a> instruction how to use them together</p>
