Compare commits

...

56 Commits

Author SHA1 Message Date
John Zheng 61d5880f8c fix previous chart issue for installation, Signed-off-by: John Zheng <john.zheng@hp.com> (#726)
Signed-off-by: John Zheng <john.zheng@hp.com>
2024-06-12 07:19:42 +02:00
dependabot[bot] 12dca32316 Bump github.com/aws/aws-sdk-go-v2/service/sqs from 1.32.2 to 1.32.3 (#715)
Bumps [github.com/aws/aws-sdk-go-v2/service/sqs](https://github.com/aws/aws-sdk-go-v2) from 1.32.2 to 1.32.3.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/sqs/v1.32.2...service/sqs/v1.32.3)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/service/sqs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-03 17:12:02 +02:00
Katyanna Moura 900e78a318 Merge pull request #718 from zalando-incubator/dependabot/go_modules/github.com/aws/aws-sdk-go-v2/config-1.27.16
Bump github.com/aws/aws-sdk-go-v2/config from 1.27.15 to 1.27.16
2024-06-03 16:55:56 +02:00
Katyanna Moura 35e0241cbf Merge pull request #723 from zalando-incubator/static-base-image
Use static base image
2024-06-03 16:55:38 +02:00
Mikkel Oscar Lyderik Larsen cb80a498dd Use static base image
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-06-03 09:09:13 +02:00
dependabot[bot] f76e7033bd Bump github.com/aws/aws-sdk-go-v2/config from 1.27.15 to 1.27.16
Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.27.15 to 1.27.16.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.27.15...config/v1.27.16)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/config
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 07:20:13 +00:00
Katyanna Moura f406e860c1 Merge pull request #713 from zalando-incubator/collector-context
Introduce context for collector interface
2024-05-21 16:38:41 +02:00
Mikkel Oscar Lyderik Larsen 5a543781d7 Introduce context for collector interface
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-05-21 14:00:31 +02:00
Katyanna Moura ca8592013c Merge pull request #712 from zalando-incubator/aws-sdk-v2
Update to aws-sdk-go-v2
2024-05-21 13:40:51 +02:00
Mikkel Oscar Lyderik Larsen 63517ebf70 Update to aws-sdk-go-v2
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-05-21 12:46:22 +02:00
Katyanna Moura 5c942b9245 Merge pull request #711 from johnzheng1975/patch-2
Update README.md -- add kubernetes installation
2024-05-16 10:22:39 +02:00
John Zheng e49845dc93 Update README.md -- add kubernetes installation
update Readme.md, for adding kubernetes installation
 Signed-off-by: John Zheng<john.zheng@hp.com>

Signed-off-by: John <john.zheng@hp.com>
2024-05-16 06:19:51 +00:00
Katyanna Moura f55afc0905 Merge pull request #708 from zalando-incubator/fix-apiserver-setup
Fix custom apiserver setup
2024-05-13 15:51:02 +02:00
Mikkel Oscar Lyderik Larsen 04f350698f Fix apiserver setup
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-05-13 15:32:10 +02:00
Katyanna Moura cafe11a109 Merge pull request #707 from zalando-incubator/kubernetes-v1.29
Update to Kubernetes v1.29
2024-05-13 11:06:13 +02:00
Mikkel Oscar Lyderik Larsen d74b7a1632 Update to Kubernetes v1.29
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-05-13 10:41:51 +02:00
Katyanna Moura 460ed1bd4c Merge pull request #706 from zalando-incubator/dependabot/go_modules/golang.org/x/oauth2-0.20.0
Bump golang.org/x/oauth2 from 0.18.0 to 0.20.0
2024-05-07 10:35:24 +02:00
dependabot[bot] 8831ac62d2 Bump golang.org/x/oauth2 from 0.18.0 to 0.20.0
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.18.0 to 0.20.0.
- [Commits](https://github.com/golang/oauth2/compare/v0.18.0...v0.20.0)

---
updated-dependencies:
- dependency-name: golang.org/x/oauth2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-06 08:14:41 +00:00
Katyanna Moura ae5c2a538a Merge pull request #704 from zalando-incubator/dependabot/go_modules/github.com/szuecs/routegroup-client-0.28.2
Bump github.com/szuecs/routegroup-client from 0.28.1 to 0.28.2
2024-05-06 10:12:42 +02:00
dependabot[bot] 68bd36ed7b Bump github.com/szuecs/routegroup-client from 0.28.1 to 0.28.2
Bumps [github.com/szuecs/routegroup-client](https://github.com/szuecs/routegroup-client) from 0.28.1 to 0.28.2.
- [Release notes](https://github.com/szuecs/routegroup-client/releases)
- [Commits](https://github.com/szuecs/routegroup-client/compare/v0.28.1...v0.28.2)

---
updated-dependencies:
- dependency-name: github.com/szuecs/routegroup-client
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-06 07:39:13 +00:00
dependabot[bot] 7cd565c100 Bump golang.org/x/net from 0.23.0 to 0.24.0 (#703)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.24.0.
- [Commits](https://github.com/golang/net/compare/v0.23.0...v0.24.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-06 09:38:15 +02:00
dependabot[bot] 8f0b25517c Bump github.com/aws/aws-sdk-go from 1.51.11 to 1.51.32 (#705)
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.51.11 to 1.51.32.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG_PENDING.md)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.51.11...v1.51.32)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-06 09:37:57 +02:00
dependabot[bot] c8372976e6 Bump golang.org/x/sync from 0.6.0 to 0.7.0 (#699)
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.6.0 to 0.7.0.
- [Commits](https://github.com/golang/sync/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-06 09:37:24 +02:00
Katyanna Moura dcedc0c17e Merge pull request #695 from zalando-incubator/kubernetes-v1.28
Update to Kubernetes v1.28
2024-04-17 13:30:12 +02:00
Mikkel Oscar Lyderik Larsen f1a2e80d15 Update to Kubernetes v1.28
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-04-17 12:27:35 +02:00
Mikkel Oscar Lyderik Larsen 2f9aefc4e7 Merge pull request #390 from zalando-incubator/dependabot/go_modules/github.com/influxdata/influxdb-client-go-1.4.0
Bump github.com/influxdata/influxdb-client-go from 0.2.0 to 1.4.0
2024-04-09 15:32:42 +02:00
Katyanna Moura 63120a8c1e Remove pointer for influxDBClient
Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2024-04-09 11:46:02 +02:00
Katyanna Moura dcf686b9c5 make test changes
Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2024-04-03 17:02:05 +02:00
Katyanna Moura 77a04c49b6 Update querying
Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2024-04-03 16:38:54 +02:00
dependabot[bot] b237f5a9d2 Bump github.com/influxdata/influxdb-client-go from 0.2.0 to 1.4.0
Bumps [github.com/influxdata/influxdb-client-go](https://github.com/influxdata/influxdb-client-go) from 0.2.0 to 1.4.0.
- [Release notes](https://github.com/influxdata/influxdb-client-go/releases)
- [Changelog](https://github.com/influxdata/influxdb-client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/influxdata/influxdb-client-go/compare/v0.2.0...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/influxdata/influxdb-client-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-03 16:38:33 +02:00
Katyanna Moura 136d31e97f Merge pull request #692 from zalando-incubator/dependabot/go_modules/github.com/szuecs/routegroup-client-0.28.1
Bump github.com/szuecs/routegroup-client from 0.25.0 to 0.28.1
2024-04-03 16:35:45 +02:00
Katyanna Moura 4d4d5d44bf Merge pull request #693 from zalando-incubator/dependabot/go_modules/google.golang.org/grpc-1.57.1
Bump google.golang.org/grpc from 1.57.0 to 1.57.1
2024-04-03 16:35:27 +02:00
dependabot[bot] a46a544bce Bump google.golang.org/grpc from 1.57.0 to 1.57.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.57.0 to 1.57.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.57.0...v1.57.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-03 13:54:49 +00:00
dependabot[bot] ea4a3eb421 Bump github.com/szuecs/routegroup-client from 0.25.0 to 0.28.1
Bumps [github.com/szuecs/routegroup-client](https://github.com/szuecs/routegroup-client) from 0.25.0 to 0.28.1.
- [Release notes](https://github.com/szuecs/routegroup-client/releases)
- [Commits](https://github.com/szuecs/routegroup-client/compare/v0.25.0...v0.28.1)

---
updated-dependencies:
- dependency-name: github.com/szuecs/routegroup-client
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-03 13:53:47 +00:00
Katyanna Moura 897fcdd423 Merge pull request #683 from Demonware/master
Adding Argo Rollouts object support for pod label selector
2024-04-03 15:52:17 +02:00
daftping 61e5cde106 use background context in pod connector test
Signed-off-by: daftping <21245083+daftping@users.noreply.github.com>
2024-04-02 02:46:34 -07:00
daftping f9141fd882 adding Argo Rollouts object support for pod label selector
Signed-off-by: daftping <21245083+daftping@users.noreply.github.com>
2024-04-02 02:38:14 -07:00
Mikkel Oscar Lyderik Larsen aece0b5efa Merge pull request #688 from zalando-incubator/dependabot/go_modules/github.com/aws/aws-sdk-go-1.51.11
Bump github.com/aws/aws-sdk-go from 1.50.38 to 1.51.11
2024-04-02 11:05:03 +02:00
Mikkel Oscar Lyderik Larsen 856ce2c391 Merge pull request #685 from zalando-incubator/dependabot/go_modules/github.com/spyzhov/ajson-0.9.1
Bump github.com/spyzhov/ajson from 0.9.0 to 0.9.1
2024-04-02 11:04:41 +02:00
dependabot[bot] 66b324bb30 Bump github.com/aws/aws-sdk-go from 1.50.38 to 1.51.11
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.50.38 to 1.51.11.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.50.38...v1.51.11)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-01 07:24:24 +00:00
dependabot[bot] c765317359 Bump github.com/spyzhov/ajson from 0.9.0 to 0.9.1
Bumps [github.com/spyzhov/ajson](https://github.com/spyzhov/ajson) from 0.9.0 to 0.9.1.
- [Release notes](https://github.com/spyzhov/ajson/releases)
- [Commits](https://github.com/spyzhov/ajson/compare/v0.9.0...v0.9.1)

---
updated-dependencies:
- dependency-name: github.com/spyzhov/ajson
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-01 07:23:37 +00:00
Mikkel Oscar Lyderik Larsen c973a9e712 Merge pull request #680 from zalando-incubator/kubernetes-v1.27
Update to Kubernetes v1.27
2024-03-25 11:43:31 +01:00
Mikkel Oscar Lyderik Larsen ef26f47884 Update to Kubernetes v1.27
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-03-25 11:31:46 +01:00
Katyanna Moura 2ec9b26ec8 Merge pull request #675 from zalando-incubator/dependabot/go_modules/github.com/szuecs/routegroup-client-0.25.0
Bump github.com/szuecs/routegroup-client from 0.24.0 to 0.25.0
2024-03-01 12:06:32 +01:00
dependabot[bot] 7cc533c892 Bump github.com/szuecs/routegroup-client from 0.24.0 to 0.25.0
Bumps [github.com/szuecs/routegroup-client](https://github.com/szuecs/routegroup-client) from 0.24.0 to 0.25.0.
- [Commits](https://github.com/szuecs/routegroup-client/compare/v0.24.0...v0.25.0)

---
updated-dependencies:
- dependency-name: github.com/szuecs/routegroup-client
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-01 10:44:45 +00:00
Katyanna Moura c9ab7402c5 Merge pull request #677 from zalando-incubator/dependabot/go_modules/golang.org/x/oauth2-0.17.0
Bump golang.org/x/oauth2 from 0.16.0 to 0.17.0
2024-03-01 11:43:26 +01:00
dependabot[bot] 0e22243de6 Bump golang.org/x/oauth2 from 0.16.0 to 0.17.0
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/oauth2/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/oauth2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-01 07:45:46 +00:00
Katyanna Moura 91acacb4f4 Merge pull request #669 from zalando-incubator/update-deps-2024-02
Update deps
2024-02-01 15:16:20 +01:00
Mikkel Oscar Lyderik Larsen 0678ef1131 Update to Kubernetes v1.25
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-02-01 15:01:55 +01:00
Lucas Thiesen 130c67cdf1 Merge pull request #659 from zalando-incubator/rps-metric-typo
Fix typo on metric annotation for external RPS metric
2024-01-19 10:54:25 +01:00
Lucas Thiesen 1661d7c4bc Fix typo on metric annotation for external RPS metric
Signed-off-by: Lucas Thiesen <lucassthiesen@gmail.com>
2024-01-19 10:38:28 +01:00
Rodrigo Reis 905cf8a06f Merge pull request #658 from zalando-incubator/update-deps-2024-01
Update dependencies
2024-01-02 10:24:50 +01:00
Mikkel Oscar Lyderik Larsen 15ceeb7316 Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2024-01-02 10:17:40 +01:00
Rodrigo Reis 776ee93d4d Merge pull request #649 from dilinade/hpa-example-fix
change apiVersion for k8s autoscaling
2023-12-15 17:30:23 +01:00
dilinade 99a194fe1a change apiVersion for k8s autoscaling
Signed-off-by: Dilina <macowtdy@gmail.com>

Signed-off-by: dilinade <nisalya@gmail.com>
2023-12-14 22:01:31 +00:00
Katyanna Moura 7a63a04668 Merge pull request #646 from zalando-incubator/fix-nakadi-table
Fix table for nakadi docs
2023-12-12 15:08:13 +01:00
43 changed files with 2239 additions and 1759 deletions
+9 -4
View File
@@ -38,11 +38,16 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version: '1.22'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -56,7 +61,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -69,4 +74,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
+1 -3
View File
@@ -1,9 +1,7 @@
ARG BASE_IMAGE=registry.opensource.zalan.do/library/alpine-3:latest
ARG BASE_IMAGE=registry.opensource.zalan.do/library/static:latest
FROM ${BASE_IMAGE}
LABEL maintainer="Team Teapot @ Zalando SE <team-teapot@zalando.de>"
RUN apk add --no-cache tzdata
ARG TARGETARCH
ADD build/linux/${TARGETARCH}/kube-metrics-adapter /
+1 -1
View File
@@ -34,7 +34,7 @@ $(GENERATED): go.mod $(CRD_TYPE_SOURCE) $(OPENAPI)
./hack/update-codegen.sh
$(GENERATED_CRDS): $(GENERATED) $(CRD_SOURCES)
go run sigs.k8s.io/controller-tools/cmd/controller-gen crd:crdVersions=v1 paths=./pkg/apis/... output:crd:dir=docs || /bin/true || true
go run sigs.k8s.io/controller-tools/cmd/controller-gen crd:crdVersions=v1 paths=./pkg/apis/... output:crd:dir=docs
mv docs/zalando.org_clusterscalingschedules.yaml docs/cluster_scaling_schedules_crd.yaml
mv docs/zalando.org_scalingschedules.yaml docs/scaling_schedules_crd.yaml
+14 -2
View File
@@ -71,6 +71,15 @@ export GO111MODULE=on # needed if the project is checked out in your $GOPATH.
$ make
```
## Install in Kubernetes
Clone this repository, and run as below:
```sh
$ cd kube-metrics-adapter/docs
$ kubectl apply -f .
```
## Collectors
Collectors are different implementations for getting metrics requested by an
@@ -82,9 +91,12 @@ HPA resource, or via additional annotations on the HPA resource.
## Pod collector
The pod collector allows collecting metrics from each pod matched by the HPA.
The pod collector allows collecting metrics from each pod matching the label selector defined in the HPA's `scaleTargetRef`.
Currently only `json-path` collection is supported.
### Supported HPA `scaleTargetRef`
The Pod Collector utilizes the `scaleTargetRef` specified in an HPA resource to obtain the label selector from the referenced Kubernetes object. This enables the identification and management of pods associated with that object. Currently, the supported Kubernetes objects for this operation are: `Deployment`, `StatefulSet` and [`Rollout`](https://argoproj.github.io/argo-rollouts/features/specification/).
### Supported metrics
| Metric | Description | Type | K8s Versions |
@@ -426,7 +438,7 @@ kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
annotations:
metric-config.external.example-rps.requests-per-second/hostname: www.example1.com,www.example2.com
metric-config.external.example-rps.requests-per-second/hostnames: www.example1.com,www.example2.com
metric-config.external.example-rps.requests-per-second/weight: "42"
spec:
scaleTargetRef:
+1 -1
View File
@@ -42,5 +42,5 @@ pipeline:
make build.linux.amd64 build.linux.arm64
docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use
docker buildx build --rm --build-arg BASE_IMAGE=container-registry.zalando.net/library/alpine-3:latest -t "${IMAGE}:${VERSION}" --platform linux/amd64,linux/arm64 --push .
docker buildx build --rm --build-arg BASE_IMAGE=container-registry.zalando.net/library/static:latest -t "${IMAGE}:${VERSION}" --platform linux/amd64,linux/arm64 --push .
cdp-promote-image "${IMAGE}:${VERSION}"
+36 -23
View File
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: clusterscalingschedules.zalando.org
spec:
group: zalando.org
@@ -23,18 +22,24 @@ spec:
name: v1
schema:
openAPIV3Schema:
description: ClusterScalingSchedule describes a cluster scoped time based
metric to be used in autoscaling operations.
description: |-
ClusterScalingSchedule describes a cluster scoped time based metric
to be used in autoscaling operations.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
@@ -47,25 +52,30 @@ spec:
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
description: |-
Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
to the same metric. New metrics require a new ScalingSchedule resource.
to the same metric. New metrics require a new ScalingSchedule
resource.
items:
description: Schedule is the schedule details to be used inside
a ScalingSchedule.
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formatted date.
description: |-
Defines the starting date of a OneTime schedule. It has to
be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes (default 0) that the configured
value will be returned for the defined schedule.
description: |-
The duration in minutes (default 0) that the configured value will be
returned for the defined schedule.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
description: |-
Defines the ending date of a OneTime schedule. It must be
a RFC3339 formatted date.
format: date-time
type: string
period:
@@ -95,8 +105,9 @@ spec:
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
timezone:
description: The location name corresponding to a file in
the IANA Time Zone database, like Europe/Berlin.
description: |-
The location name corresponding to a file in the IANA
Time Zone database, like Europe/Berlin.
type: string
required:
- days
@@ -104,7 +115,8 @@ spec:
- timezone
type: object
type:
description: Defines if the schedule is a OneTime schedule or
description: |-
Defines if the schedule is a OneTime schedule or
Repeating one. If OneTime, date has to be defined. If Repeating,
Period has to be defined.
enum:
@@ -129,8 +141,9 @@ spec:
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
description: |-
Active is true if at least one of the schedules defined in the
scaling schedule is currently active.
type: boolean
type: object
required:
+1 -1
View File
@@ -1,6 +1,6 @@
apiVersion: v2
name: kube-metrics-adapter
version: 0.2.0
version: 0.2.2
description: kube-metrics-adapter helm chart
home: https://github.com/zalando-incubator/kube-metrics-adapter
maintainers:
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: clusterscalingschedules.zalando.org
spec:
group: zalando.org
@@ -23,18 +22,24 @@ spec:
name: v1
schema:
openAPIV3Schema:
description: ClusterScalingSchedule describes a cluster scoped time based
metric to be used in autoscaling operations.
description: |-
ClusterScalingSchedule describes a cluster scoped time based metric
to be used in autoscaling operations.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
@@ -47,25 +52,30 @@ spec:
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
description: |-
Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
to the same metric. New metrics require a new ScalingSchedule resource.
to the same metric. New metrics require a new ScalingSchedule
resource.
items:
description: Schedule is the schedule details to be used inside
a ScalingSchedule.
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formatted date.
description: |-
Defines the starting date of a OneTime schedule. It has to
be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes (default 0) that the configured
value will be returned for the defined schedule.
description: |-
The duration in minutes (default 0) that the configured value will be
returned for the defined schedule.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
description: |-
Defines the ending date of a OneTime schedule. It must be
a RFC3339 formatted date.
format: date-time
type: string
period:
@@ -95,8 +105,9 @@ spec:
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
timezone:
description: The location name corresponding to a file in
the IANA Time Zone database, like Europe/Berlin.
description: |-
The location name corresponding to a file in the IANA
Time Zone database, like Europe/Berlin.
type: string
required:
- days
@@ -104,7 +115,8 @@ spec:
- timezone
type: object
type:
description: Defines if the schedule is a OneTime schedule or
description: |-
Defines if the schedule is a OneTime schedule or
Repeating one. If OneTime, date has to be defined. If Repeating,
Period has to be defined.
enum:
@@ -129,8 +141,9 @@ spec:
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
description: |-
Active is true if at least one of the schedules defined in the
scaling schedule is currently active.
type: boolean
type: object
required:
@@ -140,10 +153,4 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
{{- end}}
+36 -29
View File
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: scalingschedules.zalando.org
spec:
group: zalando.org
@@ -25,18 +24,24 @@ spec:
name: v1
schema:
openAPIV3Schema:
description: ScalingSchedule describes a namespaced time based metric to be
used in autoscaling operations.
description: |-
ScalingSchedule describes a namespaced time based metric to be used
in autoscaling operations.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
@@ -49,25 +54,30 @@ spec:
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
description: |-
Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
to the same metric. New metrics require a new ScalingSchedule resource.
to the same metric. New metrics require a new ScalingSchedule
resource.
items:
description: Schedule is the schedule details to be used inside
a ScalingSchedule.
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formatted date.
description: |-
Defines the starting date of a OneTime schedule. It has to
be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes (default 0) that the configured
value will be returned for the defined schedule.
description: |-
The duration in minutes (default 0) that the configured value will be
returned for the defined schedule.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
description: |-
Defines the ending date of a OneTime schedule. It must be
a RFC3339 formatted date.
format: date-time
type: string
period:
@@ -97,8 +107,9 @@ spec:
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
timezone:
description: The location name corresponding to a file in
the IANA Time Zone database, like Europe/Berlin.
description: |-
The location name corresponding to a file in the IANA
Time Zone database, like Europe/Berlin.
type: string
required:
- days
@@ -106,7 +117,8 @@ spec:
- timezone
type: object
type:
description: Defines if the schedule is a OneTime schedule or
description: |-
Defines if the schedule is a OneTime schedule or
Repeating one. If OneTime, date has to be defined. If Repeating,
Period has to be defined.
enum:
@@ -131,8 +143,9 @@ spec:
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
description: |-
Active is true if at least one of the schedules defined in the
scaling schedule is currently active.
type: boolean
type: object
required:
@@ -142,10 +155,4 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
{{- end}}
+5 -5
View File
@@ -4,7 +4,7 @@ replicas: 1
registry:
image: registry.opensource.zalan.do/teapot/kube-metrics-adapter
imageTag: v0.2.0
imageTag: v0.2.2
imagePullPolicy: IfNotPresent
service:
@@ -14,15 +14,15 @@ service:
addDirectoryHeader:
contentionProfiling:
profiling:
enableCustomMetricsApi:
enableExternalMetricsApi:
enableCustomMetricsApi: true
enableExternalMetricsApi: true
credentialsDirectory:
disregardIncompatibleHPAs:
http2MaxStreamsPerConnection:
listerKubeConfig:
skipperBackendsAnnotation:
skipperIngressMetrics:
skipperRouteGroupMetrics:
skipperRouteGroupMetrics: true
token:
vmodule:
@@ -95,7 +95,7 @@ resources:
memory: 100Mi
scalingSchedule:
enabled: false
enabled: true
nodeSelector:
kubernetes.io/os: linux
+36 -23
View File
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
controller-gen.kubebuilder.io/version: v0.14.0
name: scalingschedules.zalando.org
spec:
group: zalando.org
@@ -25,18 +24,24 @@ spec:
name: v1
schema:
openAPIV3Schema:
description: ScalingSchedule describes a namespaced time based metric to be
used in autoscaling operations.
description: |-
ScalingSchedule describes a namespaced time based metric to be used
in autoscaling operations.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
@@ -49,25 +54,30 @@ spec:
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
description: |-
Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
to the same metric. New metrics require a new ScalingSchedule resource.
to the same metric. New metrics require a new ScalingSchedule
resource.
items:
description: Schedule is the schedule details to be used inside
a ScalingSchedule.
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formatted date.
description: |-
Defines the starting date of a OneTime schedule. It has to
be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes (default 0) that the configured
value will be returned for the defined schedule.
description: |-
The duration in minutes (default 0) that the configured value will be
returned for the defined schedule.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
description: |-
Defines the ending date of a OneTime schedule. It must be
a RFC3339 formatted date.
format: date-time
type: string
period:
@@ -97,8 +107,9 @@ spec:
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
timezone:
description: The location name corresponding to a file in
the IANA Time Zone database, like Europe/Berlin.
description: |-
The location name corresponding to a file in the IANA
Time Zone database, like Europe/Berlin.
type: string
required:
- days
@@ -106,7 +117,8 @@ spec:
- timezone
type: object
type:
description: Defines if the schedule is a OneTime schedule or
description: |-
Defines if the schedule is a OneTime schedule or
Repeating one. If OneTime, date has to be defined. If Repeating,
Period has to be defined.
enum:
@@ -131,8 +143,9 @@ spec:
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
description: |-
Active is true if at least one of the schedules defined in the
scaling schedule is currently active.
type: boolean
type: object
required:
+1 -1
View File
@@ -1,4 +1,4 @@
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: custom-metrics-consumer
+149 -87
View File
@@ -1,128 +1,190 @@
module github.com/zalando-incubator/kube-metrics-adapter
require (
github.com/aws/aws-sdk-go v1.48.10
github.com/influxdata/influxdb-client-go v0.2.0
github.com/prometheus/client_golang v1.17.0
github.com/argoproj/argo-rollouts v1.6.6
github.com/aws/aws-sdk-go-v2 v1.27.0
github.com/aws/aws-sdk-go-v2/config v1.27.16
github.com/aws/aws-sdk-go-v2/service/sqs v1.32.3
github.com/influxdata/influxdb-client-go v1.4.0
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/common v0.45.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spyzhov/ajson v0.9.0
github.com/stretchr/testify v1.8.4
github.com/szuecs/routegroup-client v0.21.1
github.com/spyzhov/ajson v0.9.1
github.com/stretchr/testify v1.9.0
github.com/szuecs/routegroup-client v0.28.2
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20230601114834-6ed1bba3c85d
golang.org/x/net v0.19.0
golang.org/x/oauth2 v0.13.0
golang.org/x/sync v0.5.0
k8s.io/api v0.24.17
k8s.io/apimachinery v0.24.17
k8s.io/apiserver v0.24.17
k8s.io/client-go v0.24.17
k8s.io/code-generator v0.24.17
k8s.io/component-base v0.24.17
golang.org/x/net v0.25.0
golang.org/x/oauth2 v0.20.0
golang.org/x/sync v0.7.0
k8s.io/api v0.29.4
k8s.io/apimachinery v0.29.4
k8s.io/apiserver v0.29.4
k8s.io/client-go v0.29.4
k8s.io/code-generator v0.29.4
k8s.io/component-base v0.29.4
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20230614213217-ba0abe644833
k8s.io/metrics v0.24.17
sigs.k8s.io/controller-tools v0.9.0
sigs.k8s.io/custom-metrics-apiserver v1.24.0
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00
k8s.io/metrics v0.29.4
sigs.k8s.io/controller-tools v0.14.0
sigs.k8s.io/custom-metrics-apiserver v1.29.0
)
require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/CloudyKit/jet/v6 v6.2.0 // indirect
github.com/Joker/jade v1.1.3 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.16 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.7 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.7 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.9 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.20.9 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.28.10 // indirect
github.com/aws/smithy-go v1.20.2 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.16.0+incompatible // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gobuffalo/flect v0.2.5 // indirect
github.com/deepmap/oapi-codegen v1.16.2 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/flosch/pongo2/v4 v4.0.2 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.10.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2 // indirect
github.com/google/cel-go v0.17.7 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/iris-contrib/schema v0.0.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kataras/blocks v0.0.8 // indirect
github.com/kataras/golog v0.1.12 // indirect
github.com/kataras/iris/v12 v12.2.11 // indirect
github.com/kataras/pio v0.0.13 // indirect
github.com/kataras/sitemap v0.0.6 // indirect
github.com/kataras/tunnel v0.0.4 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/labstack/echo/v4 v4.12.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailgun/raymond/v2 v2.0.48 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.9 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
go.etcd.io/etcd/client/v2 v2.305.7 // indirect
go.etcd.io/etcd/client/v3 v3.5.9 // indirect
go.opentelemetry.io/contrib v0.20.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/otlp v0.20.0 // indirect
go.opentelemetry.io/otel/metric v0.20.0 // indirect
go.opentelemetry.io/otel/sdk v0.20.0 // indirect
go.opentelemetry.io/otel/sdk/export/metric v0.20.0 // indirect
go.opentelemetry.io/otel/sdk/metric v0.20.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.opentelemetry.io/proto/otlp v0.7.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.11.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/tdewolff/minify/v2 v2.20.21 // indirect
github.com/tdewolff/parse/v2 v2.7.14 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yosssi/ace v0.0.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.11 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.11 // indirect
go.etcd.io/etcd/client/v3 v3.5.11 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.0 // indirect
google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.24.0 // indirect
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.37 // indirect
k8s.io/apiextensions-apiserver v0.29.4 // indirect
k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kms v0.29.4 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
replace (
go.opentelemetry.io/cotrib v0.20.0 => go.opentelemetry.io/contrib v0.44.0
go.opentelemetry.io/otel => go.opentelemetry.io/otel v0.20.0
go.opentelemetry.io/otel/sdk => go.opentelemetry.io/otel/sdk v0.20.0
go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v0.20.0
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42
)
go 1.21
go 1.22
+530 -1104
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -33,8 +33,7 @@ type Interface interface {
ZalandoV1() zalandov1.ZalandoV1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
// Clientset contains the clients for groups.
type Clientset struct {
*discovery.DiscoveryClient
zalandoV1 *zalandov1.ZalandoV1Client
@@ -21,10 +21,9 @@ package fake
import (
"context"
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
@@ -35,24 +34,24 @@ type FakeClusterScalingSchedules struct {
Fake *FakeZalandoV1
}
var clusterscalingschedulesResource = schema.GroupVersionResource{Group: "zalando.org", Version: "v1", Resource: "clusterscalingschedules"}
var clusterscalingschedulesResource = v1.SchemeGroupVersion.WithResource("clusterscalingschedules")
var clusterscalingschedulesKind = schema.GroupVersionKind{Group: "zalando.org", Version: "v1", Kind: "ClusterScalingSchedule"}
var clusterscalingschedulesKind = v1.SchemeGroupVersion.WithKind("ClusterScalingSchedule")
// Get takes name of the clusterScalingSchedule, and returns the corresponding clusterScalingSchedule object, and an error if there is any.
func (c *FakeClusterScalingSchedules) Get(ctx context.Context, name string, options v1.GetOptions) (result *zalandoorgv1.ClusterScalingSchedule, err error) {
func (c *FakeClusterScalingSchedules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ClusterScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(clusterscalingschedulesResource, name), &zalandoorgv1.ClusterScalingSchedule{})
Invokes(testing.NewRootGetAction(clusterscalingschedulesResource, name), &v1.ClusterScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ClusterScalingSchedule), err
return obj.(*v1.ClusterScalingSchedule), err
}
// List takes label and field selectors, and returns the list of ClusterScalingSchedules that match those selectors.
func (c *FakeClusterScalingSchedules) List(ctx context.Context, opts v1.ListOptions) (result *zalandoorgv1.ClusterScalingScheduleList, err error) {
func (c *FakeClusterScalingSchedules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterScalingScheduleList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(clusterscalingschedulesResource, clusterscalingschedulesKind, opts), &zalandoorgv1.ClusterScalingScheduleList{})
Invokes(testing.NewRootListAction(clusterscalingschedulesResource, clusterscalingschedulesKind, opts), &v1.ClusterScalingScheduleList{})
if obj == nil {
return nil, err
}
@@ -61,8 +60,8 @@ func (c *FakeClusterScalingSchedules) List(ctx context.Context, opts v1.ListOpti
if label == nil {
label = labels.Everything()
}
list := &zalandoorgv1.ClusterScalingScheduleList{ListMeta: obj.(*zalandoorgv1.ClusterScalingScheduleList).ListMeta}
for _, item := range obj.(*zalandoorgv1.ClusterScalingScheduleList).Items {
list := &v1.ClusterScalingScheduleList{ListMeta: obj.(*v1.ClusterScalingScheduleList).ListMeta}
for _, item := range obj.(*v1.ClusterScalingScheduleList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@@ -71,63 +70,63 @@ func (c *FakeClusterScalingSchedules) List(ctx context.Context, opts v1.ListOpti
}
// Watch returns a watch.Interface that watches the requested clusterScalingSchedules.
func (c *FakeClusterScalingSchedules) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
func (c *FakeClusterScalingSchedules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(clusterscalingschedulesResource, opts))
}
// Create takes the representation of a clusterScalingSchedule and creates it. Returns the server's representation of the clusterScalingSchedule, and an error, if there is any.
func (c *FakeClusterScalingSchedules) Create(ctx context.Context, clusterScalingSchedule *zalandoorgv1.ClusterScalingSchedule, opts v1.CreateOptions) (result *zalandoorgv1.ClusterScalingSchedule, err error) {
func (c *FakeClusterScalingSchedules) Create(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.CreateOptions) (result *v1.ClusterScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(clusterscalingschedulesResource, clusterScalingSchedule), &zalandoorgv1.ClusterScalingSchedule{})
Invokes(testing.NewRootCreateAction(clusterscalingschedulesResource, clusterScalingSchedule), &v1.ClusterScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ClusterScalingSchedule), err
return obj.(*v1.ClusterScalingSchedule), err
}
// Update takes the representation of a clusterScalingSchedule and updates it. Returns the server's representation of the clusterScalingSchedule, and an error, if there is any.
func (c *FakeClusterScalingSchedules) Update(ctx context.Context, clusterScalingSchedule *zalandoorgv1.ClusterScalingSchedule, opts v1.UpdateOptions) (result *zalandoorgv1.ClusterScalingSchedule, err error) {
func (c *FakeClusterScalingSchedules) Update(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.UpdateOptions) (result *v1.ClusterScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(clusterscalingschedulesResource, clusterScalingSchedule), &zalandoorgv1.ClusterScalingSchedule{})
Invokes(testing.NewRootUpdateAction(clusterscalingschedulesResource, clusterScalingSchedule), &v1.ClusterScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ClusterScalingSchedule), err
return obj.(*v1.ClusterScalingSchedule), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeClusterScalingSchedules) UpdateStatus(ctx context.Context, clusterScalingSchedule *zalandoorgv1.ClusterScalingSchedule, opts v1.UpdateOptions) (*zalandoorgv1.ClusterScalingSchedule, error) {
func (c *FakeClusterScalingSchedules) UpdateStatus(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.UpdateOptions) (*v1.ClusterScalingSchedule, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(clusterscalingschedulesResource, "status", clusterScalingSchedule), &zalandoorgv1.ClusterScalingSchedule{})
Invokes(testing.NewRootUpdateSubresourceAction(clusterscalingschedulesResource, "status", clusterScalingSchedule), &v1.ClusterScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ClusterScalingSchedule), err
return obj.(*v1.ClusterScalingSchedule), err
}
// Delete takes name of the clusterScalingSchedule and deletes it. Returns an error if one occurs.
func (c *FakeClusterScalingSchedules) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
func (c *FakeClusterScalingSchedules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteActionWithOptions(clusterscalingschedulesResource, name, opts), &zalandoorgv1.ClusterScalingSchedule{})
Invokes(testing.NewRootDeleteActionWithOptions(clusterscalingschedulesResource, name, opts), &v1.ClusterScalingSchedule{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeClusterScalingSchedules) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
func (c *FakeClusterScalingSchedules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(clusterscalingschedulesResource, listOpts)
_, err := c.Fake.Invokes(action, &zalandoorgv1.ClusterScalingScheduleList{})
_, err := c.Fake.Invokes(action, &v1.ClusterScalingScheduleList{})
return err
}
// Patch applies the patch and returns the patched clusterScalingSchedule.
func (c *FakeClusterScalingSchedules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *zalandoorgv1.ClusterScalingSchedule, err error) {
func (c *FakeClusterScalingSchedules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(clusterscalingschedulesResource, name, pt, data, subresources...), &zalandoorgv1.ClusterScalingSchedule{})
Invokes(testing.NewRootPatchSubresourceAction(clusterscalingschedulesResource, name, pt, data, subresources...), &v1.ClusterScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ClusterScalingSchedule), err
return obj.(*v1.ClusterScalingSchedule), err
}
@@ -21,10 +21,9 @@ package fake
import (
"context"
zalandoorgv1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
@@ -36,25 +35,25 @@ type FakeScalingSchedules struct {
ns string
}
var scalingschedulesResource = schema.GroupVersionResource{Group: "zalando.org", Version: "v1", Resource: "scalingschedules"}
var scalingschedulesResource = v1.SchemeGroupVersion.WithResource("scalingschedules")
var scalingschedulesKind = schema.GroupVersionKind{Group: "zalando.org", Version: "v1", Kind: "ScalingSchedule"}
var scalingschedulesKind = v1.SchemeGroupVersion.WithKind("ScalingSchedule")
// Get takes name of the scalingSchedule, and returns the corresponding scalingSchedule object, and an error if there is any.
func (c *FakeScalingSchedules) Get(ctx context.Context, name string, options v1.GetOptions) (result *zalandoorgv1.ScalingSchedule, err error) {
func (c *FakeScalingSchedules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(scalingschedulesResource, c.ns, name), &zalandoorgv1.ScalingSchedule{})
Invokes(testing.NewGetAction(scalingschedulesResource, c.ns, name), &v1.ScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ScalingSchedule), err
return obj.(*v1.ScalingSchedule), err
}
// List takes label and field selectors, and returns the list of ScalingSchedules that match those selectors.
func (c *FakeScalingSchedules) List(ctx context.Context, opts v1.ListOptions) (result *zalandoorgv1.ScalingScheduleList, err error) {
func (c *FakeScalingSchedules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ScalingScheduleList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(scalingschedulesResource, scalingschedulesKind, c.ns, opts), &zalandoorgv1.ScalingScheduleList{})
Invokes(testing.NewListAction(scalingschedulesResource, scalingschedulesKind, c.ns, opts), &v1.ScalingScheduleList{})
if obj == nil {
return nil, err
@@ -64,8 +63,8 @@ func (c *FakeScalingSchedules) List(ctx context.Context, opts v1.ListOptions) (r
if label == nil {
label = labels.Everything()
}
list := &zalandoorgv1.ScalingScheduleList{ListMeta: obj.(*zalandoorgv1.ScalingScheduleList).ListMeta}
for _, item := range obj.(*zalandoorgv1.ScalingScheduleList).Items {
list := &v1.ScalingScheduleList{ListMeta: obj.(*v1.ScalingScheduleList).ListMeta}
for _, item := range obj.(*v1.ScalingScheduleList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
@@ -74,69 +73,69 @@ func (c *FakeScalingSchedules) List(ctx context.Context, opts v1.ListOptions) (r
}
// Watch returns a watch.Interface that watches the requested scalingSchedules.
func (c *FakeScalingSchedules) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
func (c *FakeScalingSchedules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(scalingschedulesResource, c.ns, opts))
}
// Create takes the representation of a scalingSchedule and creates it. Returns the server's representation of the scalingSchedule, and an error, if there is any.
func (c *FakeScalingSchedules) Create(ctx context.Context, scalingSchedule *zalandoorgv1.ScalingSchedule, opts v1.CreateOptions) (result *zalandoorgv1.ScalingSchedule, err error) {
func (c *FakeScalingSchedules) Create(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.CreateOptions) (result *v1.ScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(scalingschedulesResource, c.ns, scalingSchedule), &zalandoorgv1.ScalingSchedule{})
Invokes(testing.NewCreateAction(scalingschedulesResource, c.ns, scalingSchedule), &v1.ScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ScalingSchedule), err
return obj.(*v1.ScalingSchedule), err
}
// Update takes the representation of a scalingSchedule and updates it. Returns the server's representation of the scalingSchedule, and an error, if there is any.
func (c *FakeScalingSchedules) Update(ctx context.Context, scalingSchedule *zalandoorgv1.ScalingSchedule, opts v1.UpdateOptions) (result *zalandoorgv1.ScalingSchedule, err error) {
func (c *FakeScalingSchedules) Update(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.UpdateOptions) (result *v1.ScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(scalingschedulesResource, c.ns, scalingSchedule), &zalandoorgv1.ScalingSchedule{})
Invokes(testing.NewUpdateAction(scalingschedulesResource, c.ns, scalingSchedule), &v1.ScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ScalingSchedule), err
return obj.(*v1.ScalingSchedule), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeScalingSchedules) UpdateStatus(ctx context.Context, scalingSchedule *zalandoorgv1.ScalingSchedule, opts v1.UpdateOptions) (*zalandoorgv1.ScalingSchedule, error) {
func (c *FakeScalingSchedules) UpdateStatus(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.UpdateOptions) (*v1.ScalingSchedule, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(scalingschedulesResource, "status", c.ns, scalingSchedule), &zalandoorgv1.ScalingSchedule{})
Invokes(testing.NewUpdateSubresourceAction(scalingschedulesResource, "status", c.ns, scalingSchedule), &v1.ScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ScalingSchedule), err
return obj.(*v1.ScalingSchedule), err
}
// Delete takes name of the scalingSchedule and deletes it. Returns an error if one occurs.
func (c *FakeScalingSchedules) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
func (c *FakeScalingSchedules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteActionWithOptions(scalingschedulesResource, c.ns, name, opts), &zalandoorgv1.ScalingSchedule{})
Invokes(testing.NewDeleteActionWithOptions(scalingschedulesResource, c.ns, name, opts), &v1.ScalingSchedule{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeScalingSchedules) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
func (c *FakeScalingSchedules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
action := testing.NewDeleteCollectionAction(scalingschedulesResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &zalandoorgv1.ScalingScheduleList{})
_, err := c.Fake.Invokes(action, &v1.ScalingScheduleList{})
return err
}
// Patch applies the patch and returns the patched scalingSchedule.
func (c *FakeScalingSchedules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *zalandoorgv1.ScalingSchedule, err error) {
func (c *FakeScalingSchedules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ScalingSchedule, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(scalingschedulesResource, c.ns, name, pt, data, subresources...), &zalandoorgv1.ScalingSchedule{})
Invokes(testing.NewPatchSubresourceAction(scalingschedulesResource, c.ns, name, pt, data, subresources...), &v1.ScalingSchedule{})
if obj == nil {
return nil, err
}
return obj.(*zalandoorgv1.ScalingSchedule), err
return obj.(*v1.ScalingSchedule), err
}
@@ -42,11 +42,17 @@ type sharedInformerFactory struct {
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration
transform cache.TransformFunc
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
// wg tracks how many goroutines were started.
wg sync.WaitGroup
// shuttingDown is true when Shutdown has been called. It may still be running
// because it needs to wait for goroutines.
shuttingDown bool
}
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
@@ -75,6 +81,14 @@ func WithNamespace(namespace string) SharedInformerOption {
}
}
// WithTransform sets a transform on all informers.
func WithTransform(transform cache.TransformFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.transform = transform
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
@@ -107,20 +121,39 @@ func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResy
return factory
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
if f.shuttingDown {
return
}
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.wg.Add(1)
// We need a new variable in each loop iteration,
// otherwise the goroutine would use the loop variable
// and that keeps changing.
informer := informer
go func() {
defer f.wg.Done()
informer.Run(stopCh)
}()
f.startedInformers[informerType] = true
}
}
}
// WaitForCacheSync waits for all started informers' cache were synced.
func (f *sharedInformerFactory) Shutdown() {
f.lock.Lock()
f.shuttingDown = true
f.lock.Unlock()
// Will return immediately if there is nothing to wait for.
f.wg.Wait()
}
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
informers := func() map[reflect.Type]cache.SharedIndexInformer {
f.lock.Lock()
@@ -142,7 +175,7 @@ func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[ref
return res
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// InformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
@@ -160,6 +193,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal
}
informer = newFunc(f.client, resyncPeriod)
informer.SetTransform(f.transform)
f.informers[informerType] = informer
return informer
@@ -167,11 +201,58 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
//
// It is typically used like this:
//
// ctx, cancel := context.Background()
// defer cancel()
// factory := NewSharedInformerFactory(client, resyncPeriod)
// defer factory.WaitForStop() // Returns immediately if nothing was started.
// genericInformer := factory.ForResource(resource)
// typedInformer := factory.SomeAPIGroup().V1().SomeType()
// factory.Start(ctx.Done()) // Start processing these informers.
// synced := factory.WaitForCacheSync(ctx.Done())
// for v, ok := range synced {
// if !ok {
// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v)
// return
// }
// }
//
// // Creating informers can also be created after Start, but then
// // Start must be called again:
// anotherGenericInformer := factory.ForResource(resource)
// factory.Start(ctx.Done())
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
// Start initializes all requested informers. They are handled in goroutines
// which run until the stop channel gets closed.
Start(stopCh <-chan struct{})
// Shutdown marks a factory as shutting down. At that point no new
// informers can be started anymore and Start will return without
// doing anything.
//
// In addition, Shutdown blocks until all goroutines have terminated. For that
// to happen, the close channel(s) that they were started with must be closed,
// either before Shutdown gets called or while it is waiting.
//
// Shutdown may be called multiple times, even concurrently. All such calls will
// block until all goroutines have terminated.
Shutdown()
// WaitForCacheSync blocks until all started informers' caches were synced
// or the stop channel gets closed.
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
// ForResource gives generic access to a shared informer of the matching type.
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
// InformerFor returns the SharedIndexInformer for obj using an internal
// client.
InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer
Zalando() zalandoorg.Interface
}
+24 -20
View File
@@ -1,14 +1,14 @@
package collector
import (
"context"
"fmt"
"strconv"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/aws/aws-sdk-go/service/sqs/sqsiface"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
autoscalingv2 "k8s.io/api/autoscaling/v2"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -22,22 +22,26 @@ const (
)
type AWSCollectorPlugin struct {
sessions map[string]*session.Session
configs map[string]aws.Config
}
func NewAWSCollectorPlugin(sessions map[string]*session.Session) *AWSCollectorPlugin {
func NewAWSCollectorPlugin(configs map[string]aws.Config) *AWSCollectorPlugin {
return &AWSCollectorPlugin{
sessions: sessions,
configs: configs,
}
}
// NewCollector initializes a new skipper collector from the specified HPA.
func (c *AWSCollectorPlugin) NewCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
return NewAWSSQSCollector(c.sessions, hpa, config, interval)
func (c *AWSCollectorPlugin) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
return NewAWSSQSCollector(ctx, c.configs, hpa, config, interval)
}
type sqsiface interface {
GetQueueAttributes(ctx context.Context, params *sqs.GetQueueAttributesInput, optFns ...func(*sqs.Options)) (*sqs.GetQueueAttributesOutput, error)
}
type AWSSQSCollector struct {
sqs sqsiface.SQSAPI
sqs sqsiface
interval time.Duration
queueURL string
queueName string
@@ -46,7 +50,7 @@ type AWSSQSCollector struct {
metricType autoscalingv2.MetricSourceType
}
func NewAWSSQSCollector(sessions map[string]*session.Session, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*AWSSQSCollector, error) {
func NewAWSSQSCollector(ctx context.Context, configs map[string]aws.Config, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*AWSSQSCollector, error) {
if config.Metric.Selector == nil {
return nil, fmt.Errorf("selector for queue is not specified")
}
@@ -60,17 +64,17 @@ func NewAWSSQSCollector(sessions map[string]*session.Session, hpa *autoscalingv2
return nil, fmt.Errorf("sqs queue region is not specified on metric")
}
session, ok := sessions[region]
cfg, ok := configs[region]
if !ok {
return nil, fmt.Errorf("the metric region: %s is not configured", region)
}
service := sqs.New(session)
service := sqs.NewFromConfig(cfg)
params := &sqs.GetQueueUrlInput{
QueueName: aws.String(name),
}
resp, err := service.GetQueueUrl(params)
resp, err := service.GetQueueUrl(context.TODO(), params)
if err != nil {
return nil, fmt.Errorf("failed to get queue URL for queue '%s': %v", name, err)
}
@@ -78,7 +82,7 @@ func NewAWSSQSCollector(sessions map[string]*session.Session, hpa *autoscalingv2
return &AWSSQSCollector{
sqs: service,
interval: interval,
queueURL: aws.StringValue(resp.QueueUrl),
queueURL: aws.ToString(resp.QueueUrl),
queueName: name,
namespace: hpa.Namespace,
metric: config.Metric,
@@ -86,19 +90,19 @@ func NewAWSSQSCollector(sessions map[string]*session.Session, hpa *autoscalingv2
}, nil
}
func (c *AWSSQSCollector) GetMetrics() ([]CollectedMetric, error) {
func (c *AWSSQSCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error) {
params := &sqs.GetQueueAttributesInput{
QueueUrl: aws.String(c.queueURL),
AttributeNames: aws.StringSlice([]string{sqs.QueueAttributeNameApproximateNumberOfMessages}),
AttributeNames: []types.QueueAttributeName{types.QueueAttributeNameApproximateNumberOfMessages},
}
resp, err := c.sqs.GetQueueAttributes(params)
resp, err := c.sqs.GetQueueAttributes(ctx, params)
if err != nil {
return nil, err
}
if v, ok := resp.Attributes[sqs.QueueAttributeNameApproximateNumberOfMessages]; ok {
i, err := strconv.Atoi(aws.StringValue(v))
if v, ok := resp.Attributes[string(types.QueueAttributeNameApproximateNumberOfMessages)]; ok {
i, err := strconv.Atoi(v)
if err != nil {
return nil, err
}
+11 -10
View File
@@ -1,6 +1,7 @@
package collector
import (
"context"
"fmt"
"time"
@@ -50,7 +51,7 @@ func NewCollectorFactory() *CollectorFactory {
}
type CollectorPlugin interface {
NewCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
}
type PluginNotFoundError struct {
@@ -120,38 +121,38 @@ func (c *CollectorFactory) RegisterExternalCollector(metrics []string, plugin Co
}
}
func (c *CollectorFactory) NewCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
func (c *CollectorFactory) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
switch config.Type {
case autoscalingv2.PodsMetricSourceType:
// first try to find a plugin by format
if plugin, ok := c.podsPlugins.Named[config.CollectorType]; ok {
return plugin.NewCollector(hpa, config, interval)
return plugin.NewCollector(ctx, hpa, config, interval)
}
// else try to use the default plugin if set
if c.podsPlugins.Any != nil {
return c.podsPlugins.Any.NewCollector(hpa, config, interval)
return c.podsPlugins.Any.NewCollector(ctx, hpa, config, interval)
}
case autoscalingv2.ObjectMetricSourceType:
// first try to find a plugin by kind
if kinds, ok := c.objectPlugins.Named[config.ObjectReference.Kind]; ok {
if plugin, ok := kinds.Named[config.CollectorType]; ok {
return plugin.NewCollector(hpa, config, interval)
return plugin.NewCollector(ctx, hpa, config, interval)
}
if kinds.Any != nil {
return kinds.Any.NewCollector(hpa, config, interval)
return kinds.Any.NewCollector(ctx, hpa, config, interval)
}
break
}
// else try to find a default plugin for this kind
if plugin, ok := c.objectPlugins.Any.Named[config.CollectorType]; ok {
return plugin.NewCollector(hpa, config, interval)
return plugin.NewCollector(ctx, hpa, config, interval)
}
if c.objectPlugins.Any.Any != nil {
return c.objectPlugins.Any.Any.NewCollector(hpa, config, interval)
return c.objectPlugins.Any.Any.NewCollector(ctx, hpa, config, interval)
}
case autoscalingv2.ExternalMetricSourceType:
// First type to get metric type from the `type` label,
@@ -169,7 +170,7 @@ func (c *CollectorFactory) NewCollector(hpa *autoscalingv2.HorizontalPodAutoscal
}
if plugin, ok := c.externalPlugins[pluginKey]; ok {
return plugin.NewCollector(hpa, config, interval)
return plugin.NewCollector(ctx, hpa, config, interval)
}
}
@@ -189,7 +190,7 @@ type CollectedMetric struct {
}
type Collector interface {
GetMetrics() ([]CollectedMetric, error)
GetMetrics(ctx context.Context) ([]CollectedMetric, error)
Interval() time.Duration
}
+4 -3
View File
@@ -1,6 +1,7 @@
package collector
import (
"context"
"testing"
"time"
@@ -13,7 +14,7 @@ type mockCollectorPlugin struct {
Name string
}
func (c *mockCollectorPlugin) NewCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
func (c *mockCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
return &mockCollector{Name: c.Name}, nil
}
@@ -21,7 +22,7 @@ type mockCollector struct {
Name string
}
func (c *mockCollector) GetMetrics() ([]CollectedMetric, error) {
func (c *mockCollector) GetMetrics(_ context.Context) ([]CollectedMetric, error) {
return nil, nil
}
@@ -114,7 +115,7 @@ func TestNewCollector(t *testing.T) {
require.NoError(t, err)
require.Len(t, configs, 1)
collector, err := collectorFactory.NewCollector(tc.hpa, configs[0], 0)
collector, err := collectorFactory.NewCollector(context.Background(), tc.hpa, configs[0], 0)
if tc.expectedCollector == "" {
require.Error(t, err)
} else {
+5 -3
View File
@@ -1,6 +1,7 @@
package collector
import (
"context"
"fmt"
"regexp"
"strconv"
@@ -48,6 +49,7 @@ func NewExternalRPSCollectorPlugin(
// NewCollector initializes a new skipper collector from the specified HPA.
func (p *ExternalRPSCollectorPlugin) NewCollector(
ctx context.Context,
hpa *autoscalingv2.HorizontalPodAutoscaler,
config *MetricConfig,
interval time.Duration,
@@ -95,7 +97,7 @@ func (p *ExternalRPSCollectorPlugin) NewCollector(
),
}
c, err := p.promPlugin.NewCollector(hpa, &confCopy, interval)
c, err := p.promPlugin.NewCollector(ctx, hpa, &confCopy, interval)
if err != nil {
return nil, err
}
@@ -107,8 +109,8 @@ func (p *ExternalRPSCollectorPlugin) NewCollector(
}
// GetMetrics gets hostname metrics from Prometheus
func (c *ExternalRPSCollector) GetMetrics() ([]CollectedMetric, error) {
v, err := c.promCollector.GetMetrics()
func (c *ExternalRPSCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error) {
v, err := c.promCollector.GetMetrics(ctx)
if err != nil {
return nil, err
}
+7 -4
View File
@@ -1,6 +1,7 @@
package collector
import (
"context"
"fmt"
"regexp"
"testing"
@@ -100,6 +101,7 @@ func TestExternalRPSPluginNewCollector(tt *testing.T) {
} {
tt.Run(testcase.msg, func(t *testing.T) {
c, err := plugin.NewCollector(
context.Background(),
&autoscalingv2.HorizontalPodAutoscaler{},
testcase.config,
interval,
@@ -156,7 +158,7 @@ func TestExternalRPSCollectorGetMetrics(tt *testing.T) {
tt.Run(testcase.msg, func(t *testing.T) {
fake := makeCollectorWithStub(testcase.stub)
c := &ExternalRPSCollector{promCollector: fake}
m, err := c.GetMetrics()
m, err := c.GetMetrics(context.Background())
if testcase.shouldWork {
require.Nil(t, err)
@@ -182,6 +184,7 @@ func TestExternalRPSCollectorInterval(t *testing.T) {
pattern: pattern,
}
c, err := plugin.NewCollector(
context.Background(),
&autoscalingv2.HorizontalPodAutoscaler{},
&MetricConfig{Config: map[string]string{"hostnames": "foo.bar.baz"}},
interval,
@@ -227,7 +230,7 @@ func TestExternalRPSCollectorAndCollectorFabricInteraction(t *testing.T) {
require.NoError(t, err)
require.Len(t, conf, 1)
c, err := factory.NewCollector(hpa, conf[0], 0)
c, err := factory.NewCollector(context.Background(), hpa, conf[0], 0)
require.NoError(t, err)
_, ok := c.(*ExternalRPSCollector)
@@ -288,9 +291,9 @@ func TestExternalRPSPrometheusCollectorInteraction(t *testing.T) {
require.Len(t, conf, 2)
collectors := make(map[string]Collector)
collectors["hostname"], err = factory.NewCollector(hpa, conf[0], 0)
collectors["hostname"], err = factory.NewCollector(context.Background(), hpa, conf[0], 0)
require.NoError(t, err)
collectors["prom"], err = factory.NewCollector(hpa, conf[1], 0)
collectors["prom"], err = factory.NewCollector(context.Background(), hpa, conf[1], 0)
require.NoError(t, err)
prom, ok := collectors["prom"].(*PrometheusCollector)
+3 -1
View File
@@ -3,6 +3,7 @@ package collector
import (
"time"
"golang.org/x/net/context"
autoscalingv2 "k8s.io/api/autoscaling/v2"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/metrics/pkg/apis/custom_metrics"
@@ -19,7 +20,7 @@ type FakeCollector struct {
stub func() ([]CollectedMetric, error)
}
func (c *FakeCollector) GetMetrics() ([]CollectedMetric, error) {
func (c *FakeCollector) GetMetrics(_ context.Context) ([]CollectedMetric, error) {
if c.stub != nil {
v, err := c.stub()
return v, err
@@ -33,6 +34,7 @@ func (FakeCollector) Interval() time.Duration {
}
func (p *FakeCollectorPlugin) NewCollector(
_ context.Context,
hpa *autoscalingv2.HorizontalPodAutoscaler,
config *MetricConfig,
interval time.Duration,
+3 -2
View File
@@ -1,6 +1,7 @@
package collector
import (
"context"
"fmt"
"net/url"
"time"
@@ -26,7 +27,7 @@ func NewHTTPCollectorPlugin() (*HTTPCollectorPlugin, error) {
return &HTTPCollectorPlugin{}, nil
}
func (p *HTTPCollectorPlugin) NewCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
func (p *HTTPCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
collector := &HTTPCollector{
namespace: hpa.Namespace,
}
@@ -78,7 +79,7 @@ type HTTPCollector struct {
metric autoscalingv2.MetricIdentifier
}
func (c *HTTPCollector) GetMetrics() ([]CollectedMetric, error) {
func (c *HTTPCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error) {
metric, err := c.metricsGetter.GetMetric(*c.endpoint)
if err != nil {
return nil, err
+3 -2
View File
@@ -1,6 +1,7 @@
package collector
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
@@ -66,9 +67,9 @@ func TestHTTPCollector(t *testing.T) {
Namespace: "default",
},
}
collector, err := plugin.NewCollector(hpa, testConfig, testInterval)
collector, err := plugin.NewCollector(context.Background(), hpa, testConfig, testInterval)
require.NoError(t, err)
metrics, err := collector.GetMetrics()
metrics, err := collector.GetMetrics(context.Background())
require.NoError(t, err)
require.NotNil(t, metrics)
require.Len(t, metrics, 1)
+12 -17
View File
@@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/influxdata/influxdb-client-go"
influxdb "github.com/influxdata/influxdb-client-go"
autoscalingv2 "k8s.io/api/autoscaling/v2"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -38,8 +38,8 @@ func NewInfluxDBCollectorPlugin(client kubernetes.Interface, address, token, org
}, nil
}
func (p *InfluxDBCollectorPlugin) NewCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
return NewInfluxDBCollector(hpa, p.address, p.token, p.org, config, interval)
func (p *InfluxDBCollectorPlugin) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
return NewInfluxDBCollector(ctx, hpa, p.address, p.token, p.org, config, interval)
}
type InfluxDBCollector struct {
@@ -47,7 +47,7 @@ type InfluxDBCollector struct {
token string
org string
influxDBClient *influxdb.Client
influxDBClient influxdb.Client
interval time.Duration
metric autoscalingv2.MetricIdentifier
metricType autoscalingv2.MetricSourceType
@@ -55,7 +55,7 @@ type InfluxDBCollector struct {
namespace string
}
func NewInfluxDBCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, address string, token string, org string, config *MetricConfig, interval time.Duration) (*InfluxDBCollector, error) {
func NewInfluxDBCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, address string, token string, org string, config *MetricConfig, interval time.Duration) (*InfluxDBCollector, error) {
collector := &InfluxDBCollector{
interval: interval,
metric: config.Metric,
@@ -92,10 +92,7 @@ func NewInfluxDBCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, address st
if v, ok := config.Config[influxDBOrgKey]; ok {
org = v
}
influxDbClient, err := influxdb.New(address, token)
if err != nil {
return nil, err
}
influxDbClient := influxdb.NewClient(address, token)
collector.address = address
collector.token = token
collector.org = org
@@ -110,8 +107,9 @@ type queryResult struct {
}
// getValue returns the first result gathered from an InfluxDB instance.
func (c *InfluxDBCollector) getValue() (resource.Quantity, error) {
res, err := c.influxDBClient.QueryCSV(context.Background(), c.query, c.org)
func (c *InfluxDBCollector) getValue(ctx context.Context) (resource.Quantity, error) {
queryAPI := c.influxDBClient.QueryAPI(c.org)
res, err := queryAPI.Query(ctx, c.query)
if err != nil {
return resource.Quantity{}, err
}
@@ -119,19 +117,16 @@ func (c *InfluxDBCollector) getValue() (resource.Quantity, error) {
// Keeping just the first result.
if res.Next() {
qr := queryResult{}
if err := res.Unmarshal(&qr); err != nil {
return resource.Quantity{}, fmt.Errorf("error in unmarshaling query result: %v", err)
}
return *resource.NewMilliQuantity(int64(qr.MetricValue*1000), resource.DecimalSI), nil
}
if err := res.Err; err != nil {
if err := res.Err(); err != nil {
return resource.Quantity{}, fmt.Errorf("error in query result: %v", err)
}
return resource.Quantity{}, fmt.Errorf("empty result returned")
}
func (c *InfluxDBCollector) GetMetrics() ([]CollectedMetric, error) {
v, err := c.getValue()
func (c *InfluxDBCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error) {
v, err := c.getValue(ctx)
if err != nil {
return nil, err
}
+4 -3
View File
@@ -1,6 +1,7 @@
package collector
import (
"context"
"strings"
"testing"
"time"
@@ -38,7 +39,7 @@ func TestInfluxDBCollector_New(t *testing.T) {
"query-name": "range2m",
},
}
c, err := NewInfluxDBCollector(hpa, "http://localhost:9999", "secret", "deadbeef", m, time.Second)
c, err := NewInfluxDBCollector(context.Background(), hpa, "http://localhost:9999", "secret", "deadbeef", m, time.Second)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -79,7 +80,7 @@ func TestInfluxDBCollector_New(t *testing.T) {
"query-name": "range3m",
},
}
c, err := NewInfluxDBCollector(hpa, "http://localhost:8888", "secret", "deadbeef", m, time.Second)
c, err := NewInfluxDBCollector(context.Background(), hpa, "http://localhost:8888", "secret", "deadbeef", m, time.Second)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -149,7 +150,7 @@ func TestInfluxDBCollector_New(t *testing.T) {
CollectorType: "influxdb",
Config: tc.config,
}
_, err := NewInfluxDBCollector(hpa, "http://localhost:9999", "secret", "deadbeef", m, time.Second)
_, err := NewInfluxDBCollector(context.Background(), hpa, "http://localhost:9999", "secret", "deadbeef", m, time.Second)
if err == nil {
t.Fatal("expected error got none")
}
+6 -6
View File
@@ -36,8 +36,8 @@ func NewNakadiCollectorPlugin(nakadi nakadi.Nakadi) (*NakadiCollectorPlugin, err
}
// NewCollector initializes a new Nakadi collector from the specified HPA.
func (c *NakadiCollectorPlugin) NewCollector(hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
return NewNakadiCollector(c.nakadi, hpa, config, interval)
func (c *NakadiCollectorPlugin) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error) {
return NewNakadiCollector(ctx, c.nakadi, hpa, config, interval)
}
// NakadiCollector defines a collector that is able to collect metrics from
@@ -53,7 +53,7 @@ type NakadiCollector struct {
}
// NewNakadiCollector initializes a new NakadiCollector.
func NewNakadiCollector(nakadi nakadi.Nakadi, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*NakadiCollector, error) {
func NewNakadiCollector(_ context.Context, nakadi nakadi.Nakadi, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*NakadiCollector, error) {
if config.Metric.Selector == nil {
return nil, fmt.Errorf("selector for nakadi is not specified")
}
@@ -84,17 +84,17 @@ func NewNakadiCollector(nakadi nakadi.Nakadi, hpa *autoscalingv2.HorizontalPodAu
}
// GetMetrics returns a list of collected metrics for the Nakadi subscription ID.
func (c *NakadiCollector) GetMetrics() ([]CollectedMetric, error) {
func (c *NakadiCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error) {
var value int64
var err error
switch c.nakadiMetricType {
case nakadiMetricTypeConsumerLagSeconds:
value, err = c.nakadi.ConsumerLagSeconds(context.TODO(), c.subscriptionID)
value, err = c.nakadi.ConsumerLagSeconds(ctx, c.subscriptionID)
if err != nil {
return nil, err
}
case nakadiMetricTypeUnconsumedEvents:
value, err = c.nakadi.UnconsumedEvents(context.TODO(), c.subscriptionID)
value, err = c.nakadi.UnconsumedEvents(ctx, c.subscriptionID)
if err != nil {
return nil, err
}

Some files were not shown because too many files have changed in this diff Show More