Skip to content

Commit d134ae3

Browse files
authored
Basic info for API Priority and Fairness (#235)
Signed-off-by: Dean Roehrich <dean.roehrich@hpe.com>
1 parent 47fb75a commit d134ae3

3 files changed

Lines changed: 109 additions & 0 deletions

File tree

docs/guides/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
## Monitoring the Cluster
3232

3333
* [Auditing](monitoring-cluster/auditing.md)
34+
* [API Priority and Fairness](monitoring-cluster/api-priority-and-fairness.md)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Kubernetes API Priority And Fairness
2+
3+
Kubernetes [API Priority and Fairness](https://kubernetes.io/docs/concepts/cluster-administration/flow-control/) (APF) allows requests to the Kubernetes API server to be classified, isolated, and queued in a fine-grained way.
4+
5+
The APF metrics can be monitored to determine how well the API servers are handling the workload. The metrics are intended to be interpreted by tools like [Prometheus](https://prometheus.io/) or [VictoriaMetrics](https://victoriametrics.com/). This document will use them in their raw form.
6+
7+
The metrics covered by this document are **counter** type. Counters are incremented, never decremented. While sampling counters in raw form, they will appear to bounce but on an idle system a given counter should make its current high value known after it appears in 3-5 samples.
8+
9+
## Concepts
10+
11+
Requests coming into the API server are classified by `FlowSchemas` and assigned to priority levels. The FlowSchema assigns the request to a **flow** and gives it a **flow distinguisher**. The flow distinguisher indicates the origin of the request--a user, service account, controller, namespace, or nothing. A priority level may take requests from multiple flows. The priority level attempts to give equal response time to each flow.
12+
13+
To view FlowSchemas and their assigned priority levels:
14+
15+
```console
16+
kubectl get flowschemas
17+
```
18+
19+
Flowschema sample output:
20+
21+
```bash
22+
NAME PRIORITYLEVEL MATCHINGPRECEDENCE DISTINGUISHERMETHOD AGE MISSINGPL
23+
[...]
24+
system-leader-election leader-election 100 ByUser 112d False
25+
endpoint-controller workload-high 150 ByUser 112d False
26+
workload-leader-election leader-election 200 ByUser 112d False
27+
system-node-high node-high 400 ByUser 112d False
28+
system-nodes system 500 ByUser 112d False
29+
[...]
30+
```
31+
32+
To view priority levels:
33+
34+
```console
35+
kubectl get prioritylevelconfiguration
36+
```
37+
38+
Priority level sample output:
39+
40+
```bash
41+
NAME TYPE NOMINALCONCURRENCYSHARES QUEUES HANDSIZE QUEUELENGTHLIMIT AGE
42+
[...]
43+
global-default Limited 20 128 6 50 112d
44+
leader-election Limited 10 16 4 50 112d
45+
node-high Limited 40 64 6 50 112d
46+
system Limited 30 64 6 50 112d
47+
workload-high Limited 40 128 6 50 112d
48+
workload-low Limited 100 128 6 50 112d
49+
[...]
50+
```
51+
52+
## Metric types
53+
54+
As noted earlier, the metrics will be viewed in their raw form and they are all of **counter** type. An individual counter must be sampled multiple times before its current high value can be clearly identified.
55+
56+
To view a counter's type:
57+
58+
```console
59+
kubectl get --raw /metrics | grep flowcontrol_rejected | grep '^#'
60+
```
61+
62+
The output will describe the counter and its type:
63+
64+
```bash
65+
# HELP apiserver_flowcontrol_rejected_requests_total [BETA] Number of requests rejected by API Priority and Fairness subsystem
66+
# TYPE apiserver_flowcontrol_rejected_requests_total counter
67+
```
68+
69+
## Examples
70+
71+
A quick way to get a summary of requests by priority level:
72+
73+
```console
74+
kubectl get --raw /debug/api_priority_and_fairness/dump_priority_levels
75+
```
76+
77+
From here one can drill down into the `Flowschemas` that feed a given priority level to see which one is generating the traffic.
78+
79+
View activity that uses the **nnf-clientmount** credentials:
80+
81+
```console
82+
kubectl get --raw /metrics | grep 'flow_schema=\"nnf-clientmount\"' | head -6
83+
```
84+
85+
View activity that uses the **viewer** user credential:
86+
87+
```console
88+
kubectl get --raw /metrics | grep 'flow_schema=\"nodediag-kubectls\"' | head -6
89+
```
90+
91+
## Resources
92+
93+
### Kubernetes
94+
95+
A description of APF:
96+
[API Priority and Fairness](https://kubernetes.io/docs/concepts/cluster-administration/flow-control/)
97+
98+
Debugging guide:
99+
[Flow Control](https://kubernetes.io/docs/reference/debug-cluster/flow-control/)
100+
101+
### Other sources
102+
103+
An excellent, though dated, description of tunables:
104+
[Kubernetes API and flow control: Managing request quantity and queuing procedure](https://blog.palark.com/kubernetes-api-flow-control-management/)
105+
106+
Slide deck that gets into the algorithms:
107+
[Kubernetes API Priority and Fairness](https://speakerdeck.com/ladicle/kubernetes-api-priority-and-fairness)

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ nav:
2222
- 'Global Lustre': 'guides/global-lustre/readme.md'
2323
- 'Disable or Drain a Node': 'guides/node-management/drain.md'
2424
- 'Auditing': 'guides/monitoring-cluster/auditing.md'
25+
- 'API Priority and Fairness': 'guides/monitoring-cluster/api-priority-and-fairness.md'
2526
- 'Debugging NVMe Namespaces': 'guides/node-management/nvme-namespaces.md'
2627
- 'Directive Breakdown': 'guides/directive-breakdown/readme.md'
2728
- 'System Storage': 'guides/system-storage/readme.md'

0 commit comments

Comments
 (0)