mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
update documentation for metrics with deprecated version and version of k8s
Change-Id: Ia04d21f6644e7fc498304c0035d6f1ae58766a91
This commit is contained in:
parent
7a46516369
commit
dfff6e4364
@ -37,3 +37,16 @@ To update the documented list of metrics for k8s/website, please run:
|
|||||||
```console
|
```console
|
||||||
./test/instrumentation/update-documentation.sh
|
./test/instrumentation/update-documentation.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Then you need to copy the output to the appropriate website directory. Please
|
||||||
|
define the directory in which the website repo lives in an env variable like so:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
export WEBSITE_ROOT=<path to website root>
|
||||||
|
```
|
||||||
|
|
||||||
|
And then from the root of the k8s/k8s repository, please run this command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cp ./test/instrumentation/documentation/documentation.md $WEBSITE_ROOT/content/en/docs/reference/instrumentation/metrics.md
|
||||||
|
```
|
@ -287,31 +287,11 @@ func (c *metricDecoder) decodeMetricVecForTimingRatioHistogram(call *ast.CallExp
|
|||||||
func (c *metricDecoder) decodeLabelsFromArray(exprs []ast.Expr) ([]string, error) {
|
func (c *metricDecoder) decodeLabelsFromArray(exprs []ast.Expr) ([]string, error) {
|
||||||
retval := []string{}
|
retval := []string{}
|
||||||
for _, e := range exprs {
|
for _, e := range exprs {
|
||||||
id, ok := e.(*ast.Ident)
|
v, err := c.decodeString(e)
|
||||||
if !ok {
|
if err != nil || v == nil {
|
||||||
if bl, ok := e.(*ast.BasicLit); ok {
|
return nil, newDecodeErrorf(e, errNonStringAttribute)
|
||||||
v, err := stringValue(bl)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
retval = append(retval, v)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return nil, newDecodeErrorf(e, errInvalidNewMetricCall)
|
|
||||||
}
|
}
|
||||||
variableExpr, found := c.variables[id.Name]
|
retval = append(retval, *v)
|
||||||
if !found {
|
|
||||||
return nil, newDecodeErrorf(e, "couldn't find variable for labels")
|
|
||||||
}
|
|
||||||
bl, ok := variableExpr.(*ast.BasicLit)
|
|
||||||
if !ok {
|
|
||||||
return nil, newDecodeErrorf(e, "couldn't interpret variable for labels")
|
|
||||||
}
|
|
||||||
v, err := stringValue(bl)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
retval = append(retval, v)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval, nil
|
return retval, nil
|
||||||
@ -652,9 +632,7 @@ func (c *metricDecoder) decodeInt64(expr ast.Expr) (int64, error) {
|
|||||||
return i, err2
|
return i, err2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case *ast.CallExpr:
|
case *ast.CallExpr:
|
||||||
_, ok := v.Fun.(*ast.SelectorExpr)
|
_, ok := v.Fun.(*ast.SelectorExpr)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,7 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
flag "github.com/spf13/pflag"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"k8s.io/component-base/metrics"
|
"k8s.io/component-base/metrics"
|
||||||
@ -47,9 +48,10 @@ description: >-
|
|||||||
Details of the metric data that Kubernetes components export.
|
Details of the metric data that Kubernetes components export.
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Metrics (v{{.GeneratedVersion}})
|
||||||
|
|
||||||
## Metrics (auto-generated {{.GeneratedDate.Format "2006 Jan 02"}})
|
<!-- (auto-generated {{.GeneratedDate.Format "2006 Jan 02"}}) -->
|
||||||
|
<!-- (auto-generated v{{.GeneratedVersion}}) -->
|
||||||
This page details the metrics that different Kubernetes components export. You can query the metrics endpoint for these
|
This page details the metrics that different Kubernetes components export. You can query the metrics endpoint for these
|
||||||
components using an HTTP scrape, and fetch the current metrics data in Prometheus format.
|
components using an HTTP scrape, and fetch the current metrics data in Prometheus format.
|
||||||
|
|
||||||
@ -64,6 +66,7 @@ components using an HTTP scrape, and fetch the current metrics data in Prometheu
|
|||||||
<th class="metric_help">Help</th>
|
<th class="metric_help">Help</th>
|
||||||
<th class="metric_labels">Labels</th>
|
<th class="metric_labels">Labels</th>
|
||||||
<th class="metric_const_labels">Const Labels</th>
|
<th class="metric_const_labels">Const Labels</th>
|
||||||
|
<th class="metric_deprecated_version">Deprecated Version</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -72,8 +75,9 @@ components using an HTTP scrape, and fetch the current metrics data in Prometheu
|
|||||||
<td class="metric_stability_level" data-stability="{{$metric.StabilityLevel | ToLower}}">{{$metric.StabilityLevel}}</td>
|
<td class="metric_stability_level" data-stability="{{$metric.StabilityLevel | ToLower}}">{{$metric.StabilityLevel}}</td>
|
||||||
<td class="metric_type" data-type="{{$metric.Type | ToLower}}">{{$metric.Type}}</td>
|
<td class="metric_type" data-type="{{$metric.Type | ToLower}}">{{$metric.Type}}</td>
|
||||||
<td class="metric_description">{{$metric.Help}}</td>
|
<td class="metric_description">{{$metric.Help}}</td>
|
||||||
{{if not $metric.Labels }}<td class="metric_labels_varying">None</td>{{else }}<td class="metric_labels_varying">{{range $label := $metric.Labels}}<div class="metric_label">{{$label}}</div>{{end}}</td>{{end}}
|
{{if not $metric.Labels }}<td class="metric_labels_varying"></td>{{else }}<td class="metric_labels_varying">{{range $label := $metric.Labels}}<div class="metric_label">{{$label}}</div>{{end}}</td>{{end}}
|
||||||
{{if not $metric.ConstLabels }}<td class="metric_labels_constant">None</td>{{else }}<td class="metric_labels_constant">{{$metric.ConstLabels}}</td>{{end}}</tr>{{end}}
|
{{if not $metric.ConstLabels }}<td class="metric_labels_constant"></td>{{else }}<td class="metric_labels_constant">{{range $key, $value := $metric.ConstLabels}}<div class="metric_label">{{$key}}:{{$value}}</div>{{end}}</td>{{end}}
|
||||||
|
{{if not $metric.DeprecatedVersion }}<td class="metric_deprecated_version"></td>{{else }}<td class="metric_deprecated_version">{{$metric.DeprecatedVersion}}</td>{{end}}</tr>{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@ -88,6 +92,7 @@ components using an HTTP scrape, and fetch the current metrics data in Prometheu
|
|||||||
<th class="metric_help">Help</th>
|
<th class="metric_help">Help</th>
|
||||||
<th class="metric_labels">Labels</th>
|
<th class="metric_labels">Labels</th>
|
||||||
<th class="metric_const_labels">Const Labels</th>
|
<th class="metric_const_labels">Const Labels</th>
|
||||||
|
<th class="metric_deprecated_version">Deprecated Version</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -96,20 +101,28 @@ components using an HTTP scrape, and fetch the current metrics data in Prometheu
|
|||||||
<td class="metric_stability_level" data-stability="{{$metric.StabilityLevel | ToLower}}">{{$metric.StabilityLevel}}</td>
|
<td class="metric_stability_level" data-stability="{{$metric.StabilityLevel | ToLower}}">{{$metric.StabilityLevel}}</td>
|
||||||
<td class="metric_type" data-type="{{$metric.Type | ToLower}}">{{$metric.Type}}</td>
|
<td class="metric_type" data-type="{{$metric.Type | ToLower}}">{{$metric.Type}}</td>
|
||||||
<td class="metric_description">{{$metric.Help}}</td>
|
<td class="metric_description">{{$metric.Help}}</td>
|
||||||
{{if not $metric.Labels }}<td class="metric_labels_varying">None</td>{{else }}<td class="metric_labels_varying">{{range $label := $metric.Labels}}<div class="metric_label">{{$label}}</div>{{end}}</td>{{end}}
|
{{if not $metric.Labels }}<td class="metric_labels_varying"></td>{{else }}<td class="metric_labels_varying">{{range $label := $metric.Labels}}<div class="metric_label">{{$label}}</div>{{end}}</td>{{end}}
|
||||||
{{if not $metric.ConstLabels }}<td class="metric_labels_constant">None</td>{{else }}<td class="metric_labels_constant">{{$metric.ConstLabels}}</td>{{end}}</tr>{{end}}
|
{{if not $metric.ConstLabels }}<td class="metric_labels_constant"></td>{{else }}<td class="metric_labels_constant">{{range $key, $value := $metric.ConstLabels}}<div class="metric_label">{{$key}}:{{$value}}</div>{{end}}</td>{{end}}
|
||||||
|
{{if not $metric.DeprecatedVersion }}<td class="metric_deprecated_version"></td>{{else }}<td class="metric_deprecated_version">{{$metric.DeprecatedVersion}}</td>{{end}}</tr>{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
AlphaMetrics []metric
|
AlphaMetrics []metric
|
||||||
StableMetrics []metric
|
StableMetrics []metric
|
||||||
GeneratedDate time.Time
|
GeneratedDate time.Time
|
||||||
|
GeneratedVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var major string
|
||||||
|
var minor string
|
||||||
|
flag.StringVar(&major, "major", "", "k8s major version")
|
||||||
|
flag.StringVar(&minor, "minor", "", "k8s minor version")
|
||||||
|
println(major, minor)
|
||||||
|
flag.Parse()
|
||||||
dat, err := os.ReadFile("test/instrumentation/documentation/documentation-list.yaml")
|
dat, err := os.ReadFile("test/instrumentation/documentation/documentation-list.yaml")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
var parsedMetrics []metric
|
var parsedMetrics []metric
|
||||||
@ -131,9 +144,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
sortedMetrics := byStabilityLevel(parsedMetrics)
|
sortedMetrics := byStabilityLevel(parsedMetrics)
|
||||||
data := templateData{
|
data := templateData{
|
||||||
AlphaMetrics: sortedMetrics["ALPHA"],
|
AlphaMetrics: sortedMetrics["ALPHA"],
|
||||||
StableMetrics: sortedMetrics["STABLE"],
|
StableMetrics: sortedMetrics["STABLE"],
|
||||||
GeneratedDate: time.Now(),
|
GeneratedDate: time.Now(),
|
||||||
|
GeneratedVersion: fmt.Sprintf("%v.%v", major, parseMinor(minor)),
|
||||||
}
|
}
|
||||||
err = t.Execute(&tpl, data)
|
err = t.Execute(&tpl, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -192,3 +206,7 @@ func byStabilityLevel(ms []metric) map[string][]metric {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseMinor(m string) string {
|
||||||
|
return strings.Trim(m, `+`)
|
||||||
|
}
|
||||||
|
@ -121,7 +121,9 @@ kube::update::documentation::list() {
|
|||||||
kube::update::documentation() {
|
kube::update::documentation() {
|
||||||
stability_check_setup
|
stability_check_setup
|
||||||
temp_file=$(mktemp)
|
temp_file=$(mktemp)
|
||||||
doUpdateDocs=$(go run "test/instrumentation/documentation/main.go" -- 1>"${temp_file}")
|
arg1=$1
|
||||||
|
arg2=$2
|
||||||
|
doUpdateDocs=$(go run "test/instrumentation/documentation/main.go" --major $arg1 --minor $arg2 -- 1>"${temp_file}")
|
||||||
if ! $doUpdateDocs; then
|
if ! $doUpdateDocs; then
|
||||||
echo "${red}!!! updating documentation has failed! ${reset}" >&2
|
echo "${red}!!! updating documentation has failed! ${reset}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -24,6 +24,12 @@ set -o pipefail
|
|||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
|
||||||
source "${KUBE_ROOT}/test/instrumentation/stability-utils.sh"
|
source "${KUBE_ROOT}/test/instrumentation/stability-utils.sh"
|
||||||
|
source "${KUBE_ROOT}/hack/lib/version.sh"
|
||||||
|
|
||||||
|
# extract version env variables so we can pass them in
|
||||||
|
kube::version::get_version_vars
|
||||||
|
|
||||||
|
# update the documented list of metrics
|
||||||
kube::update::documentation::list
|
kube::update::documentation::list
|
||||||
kube::update::documentation
|
# now write the actual documentation file
|
||||||
|
kube::update::documentation $KUBE_GIT_MAJOR $KUBE_GIT_MINOR
|
||||||
|
Loading…
Reference in New Issue
Block a user