where can I check the documentation of prometheus metric - kubernetes

In the Kubernetes environment, I'm using Prometheus.
And there, I can view lots of metrics such as kube_node_status_allocatable, kube_resourcequota,...
I want to know what this metric means. But I can't find any documentation about it.
In the repo of Kubernetes, I found this page. https://github.com/kubernetes/kube-state-metrics/blob/main/docs/resourcequota-metrics.md
But the explanation is too short.
I want to know where can I check the official documentation about it.
I want to figure out what the type means in kube_resourcequota metric.
I already checked prometheus homepages. But It can't be found.
Do I have to dig the source codes?

do you mean what is resource quota?
https://kubernetes.io/docs/concepts/policy/resource-quotas/
You'll find kube_resourcequota is same as kubectl get resourcequotas -A.

Related

Where do I find the function for "kubectl describe <CRD>"?

I am studying "kubectl describe" sourcecodes at https://github.com/kubernetes/kubectl/blob/master/pkg/describe/describe.go
However, I still could not figure out how "kubectl decsribe [CRD]" works (as in which function/functions are called).
I am a Go newbie, so would like to get some pointers please. Thanks.
I have read describePod function and understand how it works more or less, but still could not figure out how "kubectl describe [CRD]" works.
The "kubectl describe " function can be found in the command-line interface (CLI) of Kubernetes, specifically in the "kubectl" tool. "kubectl" is used to manage and interact with a Kubernetes cluster and its resources.
enter image description here
Kubectl describe command helps to view the entire information about the kubernetes resources like Pods,deployments,services,nodes,jobs etc.
By using CRD(Custom Resource Definition) you can do CRUD operations like create, update, get and delete commands to access the resources. To use CRD we need to use the API groups.
Example:
Suppose you specify an API group as example.crd.com, which means you can issue the get, list, create, update, and delete commands to access the custom resources under the API group example.crd.com.
You can use kubectl describe crd <crd_name> to get a description of the CRD.
For more information refer this official doc
Try this similar SO’s SO1 and SO2 for more information

Show more logs in kubernetes dashboard

I am using the official kubernetes dashboard in Version kubernetesui/dashboard:v2.4.0 to manage my cluster and I've noticed that, when I select a pod and look into the logs, the length of the displayed logs is quite short. It's like 50 lines or something?
If an exception occurs, the logs are pretty much useless because the original cause is hidden by lots of other lines. I would have to download the logs or shell to the kubernetes server and use kubectl logs in order to see whats going on.
Is there any way to configure the dashboard in a way so that more lines of logs get displayed?
AFAIK, it is not possible with kubernetesui/dashboard:v2.4.0. On the list of dashboard arguments that allow for customization, there is no option to change the amount of logs displayed.
As a workaround you can use Prometheus + Grafana combination or ELK kibana as separate dashboards with logs/metrics, however depending on the size and scope of your k8s cluster it might be overkill. There are also alternative k8s opensource dashboards such as skooner (formerly known as k8dash), however I am not sure if it offers more workload logs visibility.
If anyone is interested: As the feature that i was looking for does not exist yet, i have submitted a feature request in GitHub. You can see it here: https://github.com/kubernetes/dashboard/issues/6700

Where is the Kubernetes YAML/JSON configuration files documentation?

Hei,
I'm looking for the documentation for Kubernetes's configuration files. The ones used by kubectl (e.g. kubectl create -f whatever.yaml).
Basically, the Kubernetes equivalent of this Docker Compose document.
I did search a lot but I didn't find much, or 404 links from old stackoverflow questions.
You could use the official API docs but a much more user-friendly way on the command line is the explain command, for example, I never remember what exactly goes into the spec of a pod, so I do:
$ kubectl explain Deployment.spec.template.spec

how to write a kubernetes manifest file cause there is no details to explan the parameters?

I deployed kubernetes 1.5 cluster on the aws, when I want to deploy a LNMP stack on the k8s cluster, but I find that it's difficult to wirte the manifest file, I can't find any examples on k8s official docs. so ,is there any detailed list of manifest parameters and also explan what the parameters meanings?
sorry for my poor english, hope somebody can help me ,thx
There is a full reference on their website:
k8s.io -> Documentation -> Reference -> Select your "Kubernetes API Versions"
For 1.10: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/
Unfortunately this is hard to read for a beginner. Also, there are many examples on the GitHub repo:
For 1.9: https://github.com/kubernetes/kubernetes/tree/release-1.9/examples
Since 1.10: https://github.com/kubernetes/examples

Kubernetes prometheus metrics for running pods and nodes?

I've set up prometheus to monitor kubernetes metrics by following the prometheus documentation.
A lot of useful metrics now show up in prometheus.
However, I can't see any metrics referencing the status of my pods or nodes.
Ideally - I'd like to be able to graph the pod status (Running, Pending, CrashLoopBackOff, Error) and nodes (NodeReady, Ready).
Is this metric anywhere? If not, can I add it somewhere? And how?
The regular kubernetes setup does not expose these metrics - further discussion here.
However, another service can be used to collect these cluster level metrics: https://github.com/kubernetes/kube-state-metrics.
This currently provides node_status_ready and pod_container_restarts which sound like what I want.
I don't think such metrics exist.
You have to modify the source code to add them. Take a look at this file on how to register a metric: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/metrics/metrics.go,
and take a look at this line on how to record a metric: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/pleg/generic.go#L180
I've found that I can monitor these metrics using heapster & snap, which is a plausible workaround for my case. Let me know if that's something you're also using and I'll give you the proper metrics to get this data.