Skip to content

Commit

Permalink
[ACM-5438] Upgrade with resolved merge conflict (#39)
Browse files Browse the repository at this point in the history
* add rolebinding metrics

* fix typo

* fix filename and sort order

* Apply suggestions from code review

Co-authored-by: Manuel Rüger <manuel@rueg.eu>

* fix metrics name

* fix typos

* feat(logging): migrate to structured logging

Signed-off-by: dmpe <John Malc> <cincenko@outlook.com>

* Apply suggestions from code review

Co-authored-by: JUN YANG <yang.jun22@zte.com.cn>

* Apply suggestions from code review

Co-authored-by: JUN YANG <yang.jun22@zte.com.cn>

* Apply suggestions from code review

Co-authored-by: JUN YANG <yang.jun22@zte.com.cn>

* Apply suggestions from code review

Co-authored-by: JUN YANG <yang.jun22@zte.com.cn>

* Replace pkg/errors with stdlib errors

github.com/pkg/errors is archived and not maintained anymore.
Replace it with stdlib functions.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* pkg/customresourcestate implement info and stateSet metric type and refactor configuration file

* Adds detection of booleans in string format to getNum.
* Refactors configuration file to allow definition of different metric types
  having different configuration variables.
* Refactor order of types and funcs in pkg/customersourcestate.
* Allows info and stateSet metrics to iterate over arrays.
* Adds `nilIsZero` config variable to gauge to indicate non-existing values to tread as 0 value instead of returning an error.
* Skip adding a label instead of setting value to `<nil>`.
* Replace namespace and subsystem by metricsNamePrefix
* Adjust docs for customresourcestate metrics to align with new configuration file

* Do not expose info metric for nil objects

* Update dependencies

go v1.18.3 -> v1.18.5
prometheus v2.35.0 -> v2.37.0
golangci-lint v1.46.2 -> v1.48.0

Several go dependencies, among them:

k8s v1.24.2 -> v1.24.4

cloudbuild image
v20211118-2f2d816b90 -> v20220609-2e4c91eb7e

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* graduate new endpoint metrics to STABLE

* graduate kube_endpoint_ports and kube_endpoint_address to STABLE
* graduate kube_endpoint_address_not_ready and
  kube_endpoint_address_available to DEPRECATED as the information is
precomputed during metrics-scraping

Signed-off-by: Mario Constanti <mario@constanti.de>

* feat: Add local storage labels to kube_persistentvolume_info

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

* Make code inline with the other parts

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

* Remove RBAC resources from default exposed metric set

These resources might create a lot of metrics,
so we won't enable them by default for now.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Prevent multiple custom resource configurations for the same resource

* Add host path metrics, fix table formatting

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

* *: Cut v2.6.0

* add exit code

* fix unitests

* create new metric

* unit tests

* remove reason from exitcode

* fix test

* documentation

* Promote two metrics to stable

* Update ci.yml

Signed-off-by: sashashura <93376818+sashashura@users.noreply.github.com>

* add ContainerResourceSourceType for hpa metrics and reduce cyclomatic complexity

* fix/docs: Typo correction in SA metrics

Typo correction in SA metrics documentation in the summary

* Do not expose ingress path metric when service is nil

* Fix return blank string when Service is nil

* Fix none to blank string

* Handle singular labels in allowlist

Handle singular labels in allowlist failing when such a label is
supplied, in order to keep the behaviour in sync with --resources.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Allow Lease metrics to be exported across all namespaces

* update lease store to export namespace

* go.mod: Upgrade to k8s 1.25

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Build with go 1.19

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* README.md: Replace Kubernetes compat matrix

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Represent GVK information as labels

Represent GVK information as labels in the metrics, instead of appending
them to the metric name itself. This would allow users to aggregate
varying GVKs of a CR under the same metric, making operations much more
easier.

* export Lease.Spec.HolderIdentity

* account for nil holderIdentity case

* Import k8s metrics stability framework

* Upgrade dependency component-base to v0.25.2 and add TODO

* Add all stable metrics

* customresourcestate fix type indentation in example

* fixup! Represent GVK information as labels

* fixup! fixup! Represent GVK information as labels

* Harden and add gosec linter

Remediate:
G104: Errors unhandled.
G109: Potential Integer overflow made by strconv.Atoi result conversion to int16/32
G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server
G304: Potential file inclusion via variable
G601: Implicit memory aliasing in for loop.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* .github: Update actions

Context: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* add myself to OWNERs

* Fix typos

* One more typo fix

* Clarify valueFrom comment

* e2e: Test against k8s 1.25.0

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Makefile: Build with go 1.19.3

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* go.mod: Bump dependencies

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Update OWNERS

* Recommend kube-scheduler alternatives

Recommend metrics exposed by the kube-scheduler, in case of the ones below:
* `kube_pod_container_resource_limits`
* `kube_pod_container_resource_requests`

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Allow `labelFromKey` field

Allow `labelFromKey` field for the following types:
* Gauge: Done.
* Info: Done.
* StateSet: N/A (redundant use case, see doc changes for more info).

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Address vulns reported by the security checks

As of this moment, there are 2 vulns in the codebase.
* GO-2022-1095: os/exec@go1.19.2
* GO-2022-1095: syscall@go1.19.2

This commit aims to fix that.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Sharding per node

* Validate options

* Clean

* Move merging fieldselectors into app/server.go and replace namespaceFitler with fieldSelectorFilter

* Refactoring

* Provide scaling example

* Add `govulncheck` cron

Add `govulncheck` cron configuration.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Update README.md

Co-authored-by: Manuel Rüger <manuel@rueg.eu>

* Refactoring

* introduce custom-resources-only flag ...

... to only monitor all known custom-resource configurations instead of
listing each of them explicitly

Signed-off-by: Mario Constanti <mario@constanti.de>

* Support filtering label allowlist by "*"

Support filtering label allowlist by "*", which will expand to the
enabled resources, while infering their values based on its value(s).

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Add retention policy metrics for KEP-1847

* fixup! Allow `labelFromKey` field

* fixup! fixup! Allow `labelFromKey` field

* fixup! fixup! fixup! Allow `labelFromKey` field

* Deprecate VPA

Deprecate VPA metrics in v2.9.0.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* fixup! fixup! fixup! fixup! Allow `labelFromKey` field

* go.mod: Bump exporter-toolkit to 0.8.1

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Incorporate Cobra

s/pflags/cobra/g:
* Use spf13/cobra to handle all flags and sub-commands.
* Remove all spf13/pflag usage, and fallback to the in-build flag
  package if, and when needed.
* Add completion support.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* update kube_node_status_{capacity/allocatable} doc to clarify difference

* Add node deletionTimestamp metric

Adds deletionTimestamp metric, for nodes.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Add --config flag

--config flag defines the path to the kube-state-metrics options config file.

* Implement hot-reloading based on config changes

Reload KSM on-the-fly when a change is detected in the configuration.

Meta changes (will squash)

* Add end-to-end testing to verify hot-reloading

Add end-to-end testing to verify hot-reloading for event-based changes
stemming from the config file. Also,
* sent in a doc fix that was missed
earlier:
https://github.com/kubernetes/kube-state-metrics/pull/1890/files#diff-380eca5a922c0ddbf67f04daefc6823e7ef0e197434d3a826d39c7063cdfa6d6R15,
* updated fsnotify and viper dependencies (v1.6.0 and v1.14.0
  respectively).

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* Add rexagod as reviewer

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>

* add ingress class metrics

* add ingress classs as nondefault resource

* add stability experimental

* autoscaling/v2beta2 HorizontalPodAutoscaler is deprecated in v1.23+

Issue: kubernetes#1711

Problem: kube-state-metrics supports up to (latest k8s release - 3) k8s
version. Since v1.25 has been release we can update it to start using
autoscaler/v2.

Solution: update packages to start using autoscaler/v2

Signed-off-by: JoaoBraveCoding <jmarcal@redhat.com>

* Update internal/store/builder.go

Co-authored-by: Damien Grisonnet <damien.grisonnet@epita.fr>

* fix linter error

* go.mod: Update dependencies

* *: Cut v2.7.0

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Add Metrics for EndpointSlices

Implements https://pkg.go.dev/k8s.io/api/discovery/v1#EndpointSlice

This resourcetype is disabled by default as they are very verbose and
have a high cardinality.
Metrics from endpointslices can be used to identify if specific pods are
part of an endpoint and thus discoverable through a service.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Add CatherineF-dev as reviewer

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>

* Update github.com/prometheus/exporter-toolkit

The latest version (v0.8.2) fixes CVE-2022-46146.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Add metrics for config file changes

This uses code pieces from prometheus/alertmanager in https://github.com/prometheus/alertmanager/blob/main/config/coordinator.go#LL56C26-L56C26
licensed under Apache-2.0.

kube_state_metrics_config_hash{type="config", filename="config.yml"} 4.0061079457904e+13
kube_state_metrics_config_last_reload_success_timestamp_seconds{type="config", filename="config.yml"} 1.6697483049487052e+09
kube_state_metrics_config_last_reload_successful{type="config",
filename="config.yml"} 1

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* Replace "<none>" with empty string for "owner_kind", "owner_name" and "owner_is_controller" dimensions.

Returning empty string instead of "<none>" value for "owner_kind", "owner_name" and "owner_is_controller" dimensions when no metadata.ownerReferences exists in Kubernetes resoures.

* Replace special string "<none>" with empty string for "storageclass" dimension.

Returning empty string instead of special string "<none>" for "storageclass" dimensions of "kube_persistentvolumeclaim_info" metric.

* Update internal/store/persistentvolumeclaim.go

Co-authored-by: Manuel Rüger <manuel@rueg.eu>

* Remove duplicated MetricsWriter implementation

Simplify the implementation of the MetricsWriter to avoid code
duplication between single and multi stores scenarios.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>

* pkg/metrics_store: add error handling to WriteAll

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>

* Add metrics for CustomResourceConfig file

* docs: add status badge for the periodic cronjob

Additionally, rename it to a more fitting name.

* Rename references from master to main branch

* Add kube_pod_status_qos_class gauge to pod metrics

Signed-off-by: frezes <zhangjunhao@kubesphere.io>

* Makefile: Bump to go 1.19.4

* Makefile: Bump to prometheus 2.40.6

* go.mod: Bump to kubernetes 1.26.0

* .github: Bump golangci-lint to 1.50.1

* Make CRS metrics type dynamic

All CRS metrics are hardcoded to "gauge" type, this patch addresses
that.

* Add develop doc on adding new metrics

* Update docs/developer/guide.md

Co-authored-by: Pranshu Srivastava <prasriva@redhat.com>

* Change kube_pod_status_qos_class to experimental metric

Signed-off-by: frezes <zhangjunhao@kubesphere.io>

* docs: Fix typo in kube_node_deletion_timestamp description

Signed-off-by: Grzegorz Głąb <grzesuav@gmail.com>

* docs:fix link

* prefix GVK labels in CustomResourceMonitoring

This will prefix the auto-generated GVK labels for CustomResources with
customresource_ to make it a bit more clear that these labels got generated.

Signed-off-by: Mario Constanti <mario@constanti.de>

* Reload CustomResourceState Config File on Change

This change adds hot reloading support for the customresourcestate
config file.

It also resolves a bug in which the customresourcestate config file was
included in the ksm config file, in which it did not get detected.

It also resolves a bug in which customresourcestatemetrics were not
added when set resources were non-default resources.

Fixes: kubernetes#1892

* replace kube_crd with kube_customresource in docs

Signed-off-by: Mario Constanti <mario@constanti.de>

* fix vpa crd metric names

* update crd monitoring and mention new flags

* Support pod_ready_time and pod_container_ready_time

Co-authored-by: Szymon Grzemski <sz.grzemski@gmail.com>
Signed-off-by: Lan Liang <gcslyp@gmail.com>

* Addressed feedback

* Fixing bad merge in rebase

* Update development guide

* fix --version flag

* Added a test for kube_pod_status_container_ready_time

* tools: Use own go.mod

This reduces the number of deps that will be fetched for building ksm

* clean broken --version flag

* remove unwanted change

* update doc

* Enhance UserAgent with more information

Before:
"User-Agent: v2.7.0"

After:
"User-Agent: kube-state-metrics/v2.7.0 (linux/amd64) kubernetes/1cda0bf9"

* Handle unit length `valueFrom` values

Handle unit length `valueFrom` values and skip strings where we expect
them to be type-cast-able to `float64`, instead of erroring, since that
is the expected behavior, and what's being done for other types.

* support "True" and "False" as string in custom-resource-state for operator status conditions

* lowercase string and simplify logic

Co-authored-by: Manuel Rüger <manuel@rueg.eu>

* Improve command to install tools

* Document how gauges convert types to float

* Improve formating

* Use structured logging

* Fixing emitting of ready time metrics when condition is false

* Set OpenMetrics content header

See: https://github.com/prometheus/common/blob/main/expfmt/encode.go#L86

See: kubernetes#1973

* Migrate all NewFamilyGenerator to NewFamilyGeneratorWithStability

* Clean up NewFamilyGenerator in comments

* Update docs/customresourcestate-metrics.md

* fixup! Handle unit length `valueFrom` values

* Update docs/customresourcestate-metrics.md

* go.mod: Update dependencies

* *: Cut v2.8.0

* fix: public Builder compatibility with the BuilderInterface

* Don't crash on non-existent path values

Don't crash on non-existent path values in CRS.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>

* fixup! Don't crash on non-existent path values

* build: Bump to go 1.19.6

* *: Cut v2.8.1

* Only use OpenMetrics and Text in contentType

* Update pkg/metricshandler/metrics_handler.go

Co-authored-by: Manuel Rüger <manuel@rueg.eu>

* Update golangci-lint version

* Update golang and go deps

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* *: Cut v2.8.2

* checked out upstream upgrade tag and replayed custom changes on top

Signed-off-by: Nathaniel Graham <[nathaniel.graham@protonmail.com, ngraham@redhat.com]>

* removed travis CI yaml file

Signed-off-by: Nathaniel Graham <[nathaniel.graham@protonmail.com, ngraham@redhat.com]>

* updated Dockerfile.prow to try go1.19

Signed-off-by: Nathaniel Graham <[nathaniel.graham@protonmail.com, ngraham@redhat.com]>

* updated go.mod to specify go1.20

Signed-off-by: Nathaniel Graham <[nathaniel.graham@protonmail.com, ngraham@redhat.com]>

---------

Signed-off-by: dmpe <John Malc> <cincenko@outlook.com>
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
Signed-off-by: Mario Constanti <mario@constanti.de>
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Signed-off-by: sashashura <93376818+sashashura@users.noreply.github.com>
Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
Signed-off-by: JoaoBraveCoding <jmarcal@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: frezes <zhangjunhao@kubesphere.io>
Signed-off-by: Grzegorz Głąb <grzesuav@gmail.com>
Signed-off-by: Lan Liang <gcslyp@gmail.com>
Signed-off-by: Nathaniel Graham <[nathaniel.graham@protonmail.com, ngraham@redhat.com]>
Co-authored-by: Kubernetes Prow Robot <k8s-ci-robot@users.noreply.github.com>
Co-authored-by: Kaito Ii <kaitoii1111@gmail.com>
Co-authored-by: Manuel Rüger <manuel@rueg.eu>
Co-authored-by: dmpe <cincenko@outlook.com>
Co-authored-by: JUN YANG <yang.jun22@zte.com.cn>
Co-authored-by: Christian Schlotter <christi.schlotter@gmail.com>
Co-authored-by: Mario Constanti <mario@constanti.de>
Co-authored-by: m.nabokikh <maksim.nabokikh@flant.com>
Co-authored-by: Shaun Sabo <shaun.sabo@gmail.com>
Co-authored-by: Catherine Fang <yinghongfang@google.com>
Co-authored-by: Alex <93376818+sashashura@users.noreply.github.com>
Co-authored-by: whitebear009 <whitebear009@163.com>
Co-authored-by: Quentin DUPUY <86727342+qdupuy@users.noreply.github.com>
Co-authored-by: evir35 <evir35@gmail.com>
Co-authored-by: Pranshu Srivastava <rexagod@gmail.com>
Co-authored-by: Lanting Chiang <lanting.chiang@robinhood.com>
Co-authored-by: Han Kang <hankang@google.com>
Co-authored-by: Pavel Timofeev <timp87@gmail.com>
Co-authored-by: Matthew Cary <mattcary@google.com>
Co-authored-by: Akshit Tyagi <37214399+exitflynn@users.noreply.github.com>
Co-authored-by: Damien Grisonnet <dgrisonn@redhat.com>
Co-authored-by: JoaoBraveCoding <jmarcal@redhat.com>
Co-authored-by: Damien Grisonnet <damien.grisonnet@epita.fr>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Co-authored-by: Paweł Kubica <pawel.kubica@comarch.pl>
Co-authored-by: Paweł Kubica <49437476+pawcykca@users.noreply.github.com>
Co-authored-by: frezes <zhangjunhao@kubesphere.io>
Co-authored-by: Pranshu Srivastava <prasriva@redhat.com>
Co-authored-by: Grzegorz Głąb <grzesuav@gmail.com>
Co-authored-by: yosshi825 <syoshimu@zlab.co.jp>
Co-authored-by: Lan Liang <gcslyp@gmail.com>
Co-authored-by: Szymon Grzemski <sz.grzemski@gmail.com>
Co-authored-by: Ryan Olds <ryanrolds@gmail.com>
Co-authored-by: Ryan R. Olds <rolds@squarespace.com>
Co-authored-by: Benjamin Jorand <benjamin.jorand@gmail.com>
Co-authored-by: Jan Kantert <jan-mpf@kantert.net>
Co-authored-by: jabdoa2 <jabdoa2@users.noreply.github.com>
Co-authored-by: Cedric Lamoriniere <cedric.lamoriniere@datadoghq.com>
Co-authored-by: Artur Rodrigues <arturhoo@gmail.com>
Co-authored-by: Nathaniel Graham <[nathaniel.graham@protonmail.com, ngraham@redhat.com]>
  • Loading branch information
Show file tree
Hide file tree
Showing 233 changed files with 20,681 additions and 7,933 deletions.
25 changes: 0 additions & 25 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Report a bug encountered while running kube-state-metrics
title: ''
labels: kind/bug
assignees: ''

---

<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!
If the matter is security related, please disclose it privately see https://github.com/kubernetes/kube-state-metrics/blob/main/SECURITY.md
-->

**What happened**:

**What you expected to happen**:

**How to reproduce it (as minimally and precisely as possible)**:

**Anything else we need to know?**:

**Environment**:
- kube-state-metrics version:
- Kubernetes version (use `kubectl version`):
- Cloud provider or hardware configuration:
- Other info:
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Feature request
about: Suggest a new feature
title: ''
labels: kind/feature
assignees: ''

---

<!-- Please only use this template for submitting feature requests -->

**What would you like to be added**:

**Why is this needed**:

**Describe the solution you'd like**

**Additional context**
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

**What this PR does / why we need it**:

**How does this change affect the cardinality of KSM**: *(increases, decreases or does not change cardinality)*

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

209 changes: 209 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
name: continuous-integration

on:
push:
branches:
- main
- release*
tags:
- v1.*
- v2.*
pull_request:
branches:
- main
- release*

permissions:
contents: read

env:
E2E_SETUP_KIND: yes
E2E_SETUP_KUBECTL: yes
SUDO: sudo
GO_VERSION: "^1.19"
GOLANGCI_LINT_VERSION: "v1.51.2"

jobs:
ci-go-lint:
name: ci-go-lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }}
make lint
ci-validate-manifests:
name: ci-validate-manifests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: Validate generated manifests
run: |
make validate-manifests
ci-validate-go-modules:
name: ci-validate-go-modules
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: Validate go modules
run: |
make validate-modules
ci-validate-docs:
name: ci-validate-docs
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: Check that all metrics are documented
run: |
make doccheck
ci-unit-tests:
name: ci-unit-tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: Unit tests
run: |
make test-unit
ci-rule-tests:
name: ci-rule-tests
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup promtool
run: |
make install-promtool
- name: Rule tests
run: |
PROMTOOL_CLI=./promtool make test-rules
ci-benchmark-tests:
name: ci-benchmark-tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: Benchmark tests
run: |
make test-benchmark-compare
ci-build-kube-state-metrics:
name: ci-build-kube-state-metrics
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: Build
run: |
make build
ci-e2e-tests:
name: ci-e2e-tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup environment
run: |
make install-tools
- name: End-to-end tests
run: |
make e2e
26 changes: 26 additions & 0 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: govulncheck

on:
schedule:
# Run every Monday
- cron: '0 0 * * 1'

env:
GO_VERSION: "^1.19"

jobs:
ci-security-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout code
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Install govulncheck binary
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run security checks
run: |
govulncheck -v ./...
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
documented_metrics
code_metrics

# E2e tests output
/log
*.bak

# Created by https://www.gitignore.io/api/go

### Go ###
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
vendor

# Folders
_obj
Expand Down
32 changes: 25 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
run:
deadline: 2m
deadline: 5m

linters:
disable-all: true
enable:
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- staticcheck
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- misspell
- gocritic
- govet
- promlinter
- revive
- staticcheck
- unconvert

linters-settings:
goimports:
local-prefixes: k8s.io/kube-state-metrics
local-prefixes: k8s.io/kube-state-metrics,k8s.io/kube-state-metrics/v2

issues:
exclude-use-default: false
exclude-rules:
# We don't check metrics naming in the tests.
- path: _test\.go
linters:
- promlinter
# TODO(mrueg) Improve error handling
- text: "G104:"
linters:
- gosec
- text: "package-comments:"
linters:
- revive
Loading

0 comments on commit 21c309e

Please sign in to comment.