Compare commits

...

82 Commits

Author SHA1 Message Date
Mikkel Oscar Lyderik Larsen
54e2d2d564 Merge pull request #576 from AlexanderYastrebov/fix-codespell-typos
all: fix typos discovered by codespell
2023-06-12 13:48:47 +02:00
Alexander Yastrebov
16ec43c361 all: fix typos discovered by codespell
```
codespell --skip .git | less
```

See https://github.com/codespell-project/codespell

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
2023-06-12 11:48:39 +02:00
Mikkel Oscar Lyderik Larsen
ffcbfcee48 Merge pull request #574 from zalando-incubator/update-deps-2023-06-01
Update dependencies
2023-06-01 14:00:05 +02:00
Mikkel Oscar Lyderik Larsen
69f95534e8 Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-06-01 13:48:06 +02:00
Lucas Thiesen
c2179a35ba Merge pull request #552 from zalando-incubator/hostname-rps-collector
Add hostname RPS metric collector
2023-05-26 11:13:42 +02:00
Mikkel Oscar Lyderik Larsen
35e3fe83e8 Update README.md
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-05-25 10:14:53 +02:00
Lucas Thiesen
69df60e724 Update flags with new metric collector name
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:58:29 +02:00
Lucas Thiesen
d171e049bf Update documentation with new metric name
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:55:20 +02:00
Lucas Thiesen
b89ca19e6a Rename collector to external RPS
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:38 +02:00
Lucas Thiesen
a276b64576 Fix error string warnings
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:38 +02:00
Lucas Thiesen
ff6d479f1a Compile regex at plugin level for time optimization
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:38 +02:00
Lucas Thiesen
cd986058e4 Delete unwanted comments
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:38 +02:00
Lucas Thiesen
d6a33fed63 Update documentation for multi hostnames per metric and weight param
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:38 +02:00
Lucas Thiesen
b8532b756b Update HPA to autoscaling/v2 in new collectors
Reference links: https://github.com/zalando-incubator/kube-metrics-adapter/pull/551

Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
f28653de74 Use regexp.Compile to avoid performance problems
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
2f5d3f5a42 Change hostname collector type to requests-per-second
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
153d754353 Add support for traffic weight specification
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
02ec2282ab Add multi hostname per metric support
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:37 +02:00
Lucas Thiesen
65dd585813 Add documentation regarding hostname-rps collector to readme
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:36 +02:00
Lucas Thiesen
aa7b64e637 Add hostname RPS metric collector
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:36 +02:00
Lucas Thiesen
7633ac551e Extract fake controller to use it in other tests
Signed-off-by: Lucas Thiesen <lucas.thiesen@zalando.de>
2023-05-23 15:46:36 +02:00
Mikkel Oscar Lyderik Larsen
a103a3295e Merge pull request #563 from antoinedeschenes/helm-use-image-0.2.0 2023-05-12 23:23:44 +02:00
Antoine Deschênes
f63915f7ff helm: bump app version to v0.2.0
Signed-off-by: Antoine Deschênes <antoine.deschenes@linux.com>
2023-05-12 10:26:06 -04:00
Alexander Didenko
c4a1e08fdf Update HPA to autoscaling/v2 apiVersion (#551) 2023-05-03 23:01:19 +02:00
Katyanna Moura
61e0336247 Merge pull request #562 from zalando-incubator/update-deps-2023-05-01
Update dependencies
2023-05-02 10:09:20 +02:00
Mikkel Oscar Lyderik Larsen
2492bdf5c1 Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-05-02 09:19:36 +02:00
Mikkel Oscar Lyderik Larsen
88b7d747d1 Merge pull request #549 from zalando-incubator/scaling-schedule-status
Add scaling schedule controller to updating status
2023-04-12 11:51:53 +02:00
Mikkel Oscar Lyderik Larsen
0794873fcb Add scaling schedule controller to updating status
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-04-06 17:53:35 +02:00
Mikkel Oscar Lyderik Larsen
e2a922f110 Move generic functions to controller package
Move defaultTimeZone to a flag.

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-04-06 17:53:17 +02:00
Mikkel Oscar Lyderik Larsen
b631a4fe08 Update dependencies (#548)
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-04-03 10:03:24 +02:00
Mikkel Oscar Lyderik Larsen
90fea54307 Merge pull request #539 from zalando-incubator/chart-release
added chart release workflow
2023-03-16 13:39:11 +01:00
Sebastien THOMAS
8b6a54627d added chart release workflow
Signed-off-by: Sebastien THOMAS <sebastien.thomas@wunderkind.co>
2023-03-13 22:45:37 +01:00
Martin Linkhorst
75738f1eb7 Merge pull request #538 from zalando-incubator/update-deps-2023-03-01
Update dependencies
2023-03-01 13:59:48 +01:00
Mikkel Oscar Lyderik Larsen
d8934ebbc1 Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-03-01 13:26:19 +01:00
Rodrigo Reis
17bef811f3 Merge pull request #528 from zalando-incubator/dependabot/go_modules/github.com/emicklei/go-restful-2.16.0incompatible
Bump github.com/emicklei/go-restful from 2.15.0+incompatible to 2.16.0+incompatible
2023-02-09 17:44:13 +01:00
dependabot[bot]
7a041c991a Bump github.com/emicklei/go-restful
Bumps [github.com/emicklei/go-restful](https://github.com/emicklei/go-restful) from 2.15.0+incompatible to 2.16.0+incompatible.
- [Release notes](https://github.com/emicklei/go-restful/releases)
- [Changelog](https://github.com/emicklei/go-restful/blob/v3/CHANGES.md)
- [Commits](https://github.com/emicklei/go-restful/compare/v2.15.0...v2.16.0)

---
updated-dependencies:
- dependency-name: github.com/emicklei/go-restful
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 16:00:27 +00:00
Katyanna Moura
979ae68eab Merge pull request #527 from zalando-incubator/update-deps-2023-02-01
Update dependencies
2023-02-01 15:51:19 +01:00
Mikkel Oscar Lyderik Larsen
e9a209aa31 Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-02-01 15:25:58 +01:00
Mikkel Oscar Lyderik Larsen
838edd9082 Update dependencies 2023-01-02 (#516)
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2023-01-02 18:13:28 +01:00
Zak Lawrence A
c50d9ccd18 Merge pull request #506 from zalando-incubator/fix-null-pointer
Fix nil pointer dereference
2022-12-21 15:48:01 +01:00
zlawrence
c60253e90c add test for end date in incorrect format
Signed-off-by: zlawrence <zak.lawrence@zalando.de>
2022-12-21 14:08:44 +01:00
zlawrence
680e0feea1 fix nil pointer dereference
Signed-off-by: zlawrence <zak.lawrence@zalando.de>
2022-12-21 14:08:41 +01:00
Zak Lawrence A
070f9ab299 Merge pull request #505 from zalando-incubator/update-scalingschedule-config
Update scalingschedule config
2022-12-13 20:24:01 +01:00
zlawrence
8ba4d19c35 Add end date support for Repeating schedule. Added tests 2022-12-13 12:53:05 +01:00
zlawrence
37bf73c7fe Add end date support for OneTime schedule 2022-12-12 20:02:15 +01:00
Martin Linkhorst
d01a3f6347 Merge pull request #496 from zalando-incubator/update-deps-2022-11-01
Update dependencies
2022-12-01 13:48:01 +01:00
Mikkel Oscar Lyderik Larsen
50633ba06c Update deps 2022-12
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-12-01 13:05:51 +01:00
Mikkel Oscar Lyderik Larsen
bce27b748c Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-11-01 08:58:12 +01:00
Katyanna Moura
9e057c1075 Merge pull request #471 from zalando-incubator/update-deps-09-2022
Update dependencies and Go version
2022-09-14 18:12:22 +02:00
Mikkel Oscar Lyderik Larsen
55ce2d8c3d Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-09-13 23:21:39 +02:00
Mikkel Oscar Lyderik Larsen
37969486fe Merge pull request #448 from zalando-incubator/multi-arch-image
Build multi-arch image
2022-06-28 11:52:25 +02:00
Mikkel Oscar Lyderik Larsen
1be6357c8e Build multi-arch image
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-06-24 23:34:31 +02:00
Katyanna Moura
7b592c6832 Merge pull request #447 from zalando-incubator/ingress-upgrade-v1
Limit ingress support to only networking.k8s.io/v1
2022-06-22 11:12:21 +02:00
Katyanna Moura
203aaeafb9 Update supported K8s version for skipper-collector
Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2022-06-22 10:27:35 +02:00
Katyanna Moura
5926f1aea1 Limit ingress support to only networking.k8s.io/v1
Given the deprecation of extensions/v1beta1, remove it from Ingress possibilities.

Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2022-06-21 12:46:08 +02:00
Sandor Szücs
be1e1c635d Create codeql-analysis.yml (#446)
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
2022-06-09 11:52:46 +02:00
Mikkel Oscar Lyderik Larsen
094a9f9b9d Merge pull request #443 from zalando-incubator/update-deps-2022-06
Update dependencies + fix CI build
2022-06-01 16:03:37 +02:00
Mikkel Oscar Lyderik Larsen
47d34b328c Update dependencies + fix CI build
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-06-01 12:16:11 +02:00
owengo
4b5b96084b adding nodeSelector + tolerations + affinity + priorityClassName + podAnnotations to helm chart (#421)
Signed-off-by: Olivier Schiavo <olivier.schiavo@wengo.com>

Co-authored-by: Olivier Schiavo <olivier.schiavo@wengo.com>
2022-05-02 16:02:24 +02:00
Mikkel Oscar Lyderik Larsen
18f4c82f07 Update dependencies and default to Go 1.18 (#419)
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-05-02 15:57:34 +02:00
Mikkel Oscar Lyderik Larsen
10dc42b9e9 Merge pull request #401 from zalando-incubator/update-deps-02-14
Update dependencies
2022-02-14 15:05:19 +01:00
Mikkel Oscar Lyderik Larsen
20db592a62 Use cdp-runtime for build (#398)
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-02-14 14:41:57 +01:00
Mikkel Oscar Lyderik Larsen
d0a3ea1934 Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-02-14 14:36:06 +01:00
Mikkel Oscar Lyderik Larsen
837e7b9c5d Update deps 2022 02 (#391)
* Update example

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>

* Update dependencies 2022-02

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2022-02-01 18:13:48 +01:00
Katyanna Moura
9d8359b580 Merge pull request #380 from zalando-incubator/fix-metrics-map
Fix panic when trying to add key to nil map
2022-01-12 11:36:53 +01:00
Katyanna Moura
71a8e99d1f Fix panic when trying to add key to nil map
Bug was introduced trying to solved the following issue:
> When scenarios where two HPAs reference the same object but have
different metric calculation (e.g. ingresses with different weights),
kube-metrics-adapter calculates the two metrics but always overrides
one of the metrics when saving it to the store.

This commit fixes a issue where without the added `return` the system
was continuing in an invalid states where `labels2metric` wasn't
properly initialized, causing the system to panic.

Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2022-01-12 11:29:38 +01:00
Katyanna Moura
4d4c70c553 Fix test filename to match related file
Having the test filename prefix exactly as the tested file name helps systems
to identify the correlation.

Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2022-01-12 11:29:38 +01:00
Katyanna Moura
2ccd6903d9 Merge pull request #376 from zalando-incubator/custommetricsselector
Use labels hash in the custom metrics store and metrics store 💅
2021-11-25 10:24:44 +01:00
Jonathan Juares Beber
f58db31f98 Define stronger types for metrics store
The metrics store, both the custom and external one, make heavy usage of
maps of strings to strings. This leads to a presumable confusing or at
least hard to read codebase.

This commit tries to increase readability and maintainability of the
metric stores by using custom types. This commit has no effect in
performance or functionality, it's pure aesthetics.

Co-authored-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
2021-11-24 17:41:03 +01:00
Jonathan Juares Beber
0bf8f5dd0f Use labels hash in the custom metrics store
The current implementation of the metrics store for custom metrics uses
just the object name as key. When scenarios where two HPAs reference the
same object but have different metric calculation (e.g. ingresses with
different weights), kube-metrics-adapter calculates the two metrics but
always overrides one of the metrics when saving it to the store.

This commit implements the use of a labels hash in the custom metrics
store. This way, metrics are identified not just by the referenced
object, but also by its selectors.

Co-authored-by: Katyanna Moura <amelie.kn@gmail.com>
Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
2021-11-23 18:11:18 +01:00
Jonathan Juares Beber
e600557636 Merge pull request #375 from zalando-incubator/kube1.21
Upgrade Kubernetes and its friends to 1.21
2021-10-28 10:35:11 +02:00
Jonathan Juares Beber
0f06db7cdf Upgrade Kubernetes and its friends to 1.21
This commit upgrades all the Kubernetes dependencies to 1.21.5. It
includes regenerated clients and specs.

Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
2021-10-27 20:58:18 +02:00
Jonathan Juares Beber
1c9038b2cc Merge pull request #374 from zalando-incubator/configurable-buckets
Make the number of ramp steps configurable
2021-10-25 10:21:32 +02:00
Jonathan Juares Beber
fd4ead837e Make the number of ramp steps configurable
In #371 we introduced steps to make the scaling up possible even when
the HPA forces a 10% change. The problem is that 10% might not be
sufficient for some specific scaling scenarios.

For example, a an application targeting 12 pods and using a
ScalingSchedule with the value of 10000 to achieve that, will require a
target of 833. With 10 ramp steps the 90% bucket will return a metric of
9000 and the HPA calculates (9000/833) 10.8 pods, rounding to 11 pods.
Once the metric reaches the time to return 100% it will won't be
effective, since the change of the current number of pods (11) and the
desired one (12) is less than 10%.

This commit does not try to tackle this problem completely, since the
10% rule is not fixed, might change among different clusters and is also
dependent on the value given to each ScalingSchedule. Therefore, this
commit makes the number of ramp steps configurable via the
`--scaling-schedule-ramp-steps` config flag, defaulting to 10.

Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
2021-10-22 15:35:11 +02:00
Mikkel Oscar Lyderik Larsen
f46f801811 Merge pull request #373 from zalando-incubator/json-path-array
Handle more complex array in json path
2021-10-19 10:04:04 +02:00
Mikkel Oscar Lyderik Larsen
4acdf72ef7 Handle more complex array in json path
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-10-14 09:34:15 +02:00
Jonathan Juares Beber
e04cd10bfc Merge pull request #371 from zalando-incubator/scaling-chunks
Use 10 buckets on ScalingSchedule ramp-up/down
2021-10-01 10:39:57 +02:00
Jonathan Juares Beber
8fe330941a Use 10 buckets on ScalingSchedule ramp-up/down
The HPA has a feature to do not scale up and down when the change in the
metric is less than 10%:

> We'll skip scaling if the ratio is sufficiently close to 1.0 (within a
> globally-configurable tolerance, from the
> `--horizontal-pod-autoscaler-tolerance` flag, which defaults to 0.1.

It could lead to pods scaling up to 10% less than the target for
ScalingSchedules and then not scaling to the actual value if the metric
calculated before was less than 10% of the target.

This commit uses 10 fixed buckets for scaling, this way we know the
metric returned during a scaling event is at least 10% more than a
previous one calculated during the period of ramp up. The same is valid
for the scaling down during a ramp-down

Signed-off-by: Jonathan Juares Beber <jonathanbeber@gmail.com>
2021-09-30 19:01:59 +02:00
aermakov-zalando
0730c6ef1e Merge pull request #370 from zalando-incubator/schedule-scaling-window
Scheduled scaling: scale up/down slowly
2021-09-24 15:47:44 +02:00
Alexey Ermakov
c5411c74b7 Scheduled scaling: add an optional scaling window
Signed-off-by: Alexey Ermakov <alexey.ermakov@zalando.de>
2021-09-24 15:33:49 +02:00
aermakov-zalando
4ba6b66441 Merge pull request #369 from zalando-incubator/fix-list
Fix the type for ClusterScalingScheduleList
2021-09-17 11:37:47 +02:00
Alexey Ermakov
0dbe769e1b Fix the type for ClusterScalingScheduleList
Signed-off-by: Alexey Ermakov <alexey.ermakov@zalando.de>
2021-09-17 11:29:52 +02:00
68 changed files with 3868 additions and 1031 deletions

View File

@ -1,7 +1,11 @@
name: ci
on: [push, pull_request]
env:
GO111MODULE: on
on:
push:
branches-ignore:
- 'gh-pages'
pull_request:
branches-ignore:
- 'gh-pages'
jobs:
tests:
runs-on: ubuntu-latest
@ -9,14 +13,10 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.16'
go-version: '^1.19'
- run: go version
- run: go get github.com/mattn/goveralls
env:
GO111MODULE: off
- run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_RELEASE}
env:
GOLANGCI_RELEASE: v1.37.0
- run: go install github.com/mattn/goveralls@latest
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- run: make build.docker
- run: make test
- run: make check

72
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '29 17 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# 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
# 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
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

27
.github/workflows/release-chart.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Release Charts
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.4.0
with:
charts_dir: docs
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

View File

@ -1,19 +1,15 @@
run:
linters-settings:
golint:
min-confidence: 0.9
concurrency: 4
linters:
disable-all: true
enable:
- staticcheck
- ineffassign
- golint
- goimports
- errcheck
issues:
exclude-rules:
# Exclude some staticcheck messages
- linters:
- staticcheck
text: "SA9003:"
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- varcheck

View File

@ -50,7 +50,7 @@ contribution is in line with our goals.
- Make sure you sign-off on your commits `git commit -s -m "adding X to change Y"`
- Write good commit messages (see below).
- Push your changes to a topic branch in your fork of the repository.
- As you push your changes, update the pull request with new infomation and tasks as you complete them
- As you push your changes, update the pull request with new information and tasks as you complete them
- Project maintainers might comment on your work as you progress
- When you are done, remove the `work in progess` label and ping the maintainers for a review
- Your pull request must receive a :thumbsup: from two [maintainers](MAINTAINERS)

View File

@ -1,9 +1,11 @@
FROM registry.opensource.zalan.do/library/alpine-3.12:latest
ARG BASE_IMAGE=registry.opensource.zalan.do/library/alpine-3.13:latest
FROM ${BASE_IMAGE}
LABEL maintainer="Team Teapot @ Zalando SE <team-teapot@zalando.de>"
RUN apk add --no-cache tzdata
# add binary
ADD build/linux/kube-metrics-adapter /
ARG TARGETARCH
ADD build/linux/${TARGETARCH}/kube-metrics-adapter /
ENTRYPOINT ["/kube-metrics-adapter"]

View File

@ -50,7 +50,9 @@ $(OPENAPI): go.mod
build.local: build/$(BINARY) $(GENERATED_CRDS)
build.linux: build/linux/$(BINARY)
build.osx: build/osx/$(BINARY)
build.linux.amd64: build/linux/amd64/$(BINARY)
build.linux.arm64: build/linux/arm64/$(BINARY)
build/$(BINARY): go.mod $(SOURCES) $(GENERATED)
CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
@ -58,11 +60,14 @@ build/$(BINARY): go.mod $(SOURCES) $(GENERATED)
build/linux/$(BINARY): go.mod $(SOURCES) $(GENERATED)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" .
build/osx/$(BINARY): go.mod $(SOURCES) $(GENERATED)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" .
build/linux/amd64/$(BINARY): go.mod $(SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/amd64/$(BINARY) -ldflags "$(LDFLAGS)" .
build/linux/arm64/$(BINARY): go.mod $(SOURCES)
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/arm64/$(BINARY) -ldflags "$(LDFLAGS)" .
build.docker: build.linux
docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) .
docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) --build-arg TARGETARCH= .
build.push: build.docker
docker push "$(IMAGE):$(TAG)"

142
README.md
View File

@ -17,7 +17,7 @@ Here's an example of a `HorizontalPodAutoscaler` resource configured to get
`requests-per-second` metrics from each pod of the deployment `myapp`.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -54,10 +54,8 @@ policy](https://kubernetes.io/docs/setup/release/version-skew-policy/) offered
for Kubernetes, this project aims to support the latest three minor releases of
Kubernetes.
The default supported API is `autoscaling/v2beta2` (available since `v1.12`).
This API MUST be available in the cluster which is the default. However for
GKE, this requires GKE v1.15.7 according to this [GKE
Issue](https://issuetracker.google.com/issues/135624588).
The default supported API is `autoscaling/v2` (available since `v1.23`).
This API MUST be available in the cluster which is the default.
## Building
@ -99,7 +97,7 @@ This is an example of using the pod collector to collect metrics from a json
metrics endpoint of each pod matched by the HPA.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -219,7 +217,7 @@ with the result of the query.
This allows having multiple prometheus queries associated with a single HPA.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -320,7 +318,7 @@ box so users don't have to define those manually.
| Metric | Description | Type | Kind | K8s Versions |
| ----------- | -------------- | ------ | ---- | ---- |
| `requests-per-second` | Scale based on requests per second for a certain ingress or routegroup. | Object | `Ingress`, `RouteGroup` | `>=1.14` |
| `requests-per-second` | Scale based on requests per second for a certain ingress or routegroup. | Object | `Ingress`, `RouteGroup` | `>=1.19` |
### Example
@ -331,7 +329,7 @@ This is an example of an HPA that will scale based on `requests-per-second` for
an ingress called `myapp`.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -365,7 +363,7 @@ This is an example of an HPA that will scale based on `requests-per-second` for
a routegroup called `myapp`.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -404,6 +402,64 @@ the `backend` label under `matchLabels` for the metric. The ingress annotation
where the backend weights can be obtained can be specified through the flag
`--skipper-backends-annotation`.
## External RPS collector
The External RPS collector, like Skipper collector, is a simple wrapper around the Prometheus collector to
make it easy to define an HPA for scaling based on the RPS measured for a given hostname. When
[skipper](https://github.com/zalando/skipper) is used as the ingress
implementation in your cluster everything should work automatically, in case another reverse proxy is used as ingress, like [Nginx](https://github.com/kubernetes/ingress-nginx) for example, its necessary to configure which prometheus metric should be used through `--external-rps-metric-name <metric-name>` flag. Assuming `skipper-ingress` is being used or the appropriate metric name is passed using the flag mentioned previously this collector provides the correct Prometheus queries out of the
box so users don't have to define those manually.
### Supported metrics
| Metric | Description | Type | Kind | K8s Versions |
| ------------ | -------------- | ------- | -- | -- |
| `requests-per-second` | Scale based on requests per second for a certain hostname. | External | | `>=1.12` |
### Example: External Metric
This is an example of an HPA that will scale based on `requests-per-second` for the RPS measured in the hostnames called: `www.example1.com` and `www.example2.com`; and weighted by 42%.
```yaml
apiVersion: autoscaling/v2
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/weight: "42"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: custom-metrics-consumer
minReplicas: 1
maxReplicas: 10
metrics:
- type: External
external:
metric:
name: example-rps
selector:
matchLabels:
type: requests-per-second
target:
type: AverageValue
averageValue: "42"
```
### Multiple hostnames per metric
This metric supports a relation of n:1 between hostnames and metrics. The way it works is the measured RPS is the sum of the RPS rate of each of the specified hostnames. This value is further modified by the weight parameter explained below.
### Metric weighting based on backend
There are ingress-controllers, like skipper-ingress, that supports sending traffic to different backends based on some kind of configuration, in case of skipper annotations
present on the `Ingress` object, or weights on the RouteGroup backends. By
default the number of replicas will be calculated based on the full traffic
served by these components. If however only the traffic being routed to
a specific hostname should be used then the weight for the configured hostname(s) might be specified via the `weight` annotation `metric-config.external.<metric-name>.request-per-second/weight` for the metric being configured.
## InfluxDB collector
The InfluxDB collector maps [Flux](https://github.com/influxdata/flux) queries to metrics that can be used for scaling.
@ -426,7 +482,7 @@ the query name which will be associated with the result of the query. This
allows having multiple flux queries associated with a single HPA.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -514,7 +570,7 @@ This is an example of an HPA that will scale based on the length of an SQS
queue.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -566,7 +622,7 @@ This is an example of an HPA that will scale based on the specified value
exposed by a ZMON check with id `1234`.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -663,7 +719,7 @@ This is an example of using the HTTP collector to collect metrics from a json
metrics endpoint specified in the annotations.
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
@ -720,12 +776,63 @@ The `ScalingSchedule` and `ClusterScalingSchedule` collectors allow
collecting time-based metrics from the respective CRD objects specified
in the HPA.
These collectors are disabled by default, you have to start the server
with the `--scaling-schedule` flag to enable it. Remember to deploy the CRDs
`ScalingSchedule` and `ClusterScalingSchedule` and allow the service
account used by the server to read, watch and list them.
### Supported metrics
| Metric | Description | Type | K8s Versions |
| ---------- | -------------- | ------- | -- |
| ObjectName | The metric is calculated and stored for each `ScalingSchedule` and `ClusterScalingSchedule` referenced in the HPAs | `ScalingSchedule` and `ClusterScalingSchedule` | `>=1.16` |
### Ramp-up and ramp-down feature
To avoid abrupt scaling due to time based metrics,the `SchalingSchedule`
collector has a feature of ramp-up and ramp-down the metric over a
specific period of time. The duration of the scaling window can be
configured individually in the `[Cluster]ScalingSchedule` object, via
the option `scalingWindowDurationMinutes` or globally for all scheduled
events, and defaults to a globally configured value if not specified.
The default for the latter is set to 10 minutes, but can be changed
using the `--scaling-schedule-default-scaling-window` flag.
This spreads the scale events around, creating less load on the other
components, and helping the rest of the metrics (like the CPU ones) to
adjust as well.
The [HPA algorithm][algo-details] does not make changes if the metric
change is less than the specified by the
`horizontal-pod-autoscaler-tolerance` flag:
> We'll skip scaling if the ratio is sufficiently close to 1.0 (within a
> globally-configurable tolerance, from the
> `--horizontal-pod-autoscaler-tolerance` flag, which defaults to 0.1.
With that in mind, the ramp-up and ramp-down feature divides the scaling
over the specified period of time in buckets, trying to achieve changes
bigger than the configured tolerance. The number of buckets defaults to
10 and can be configured by the `--scaling-schedule-ramp-steps` flag.
**Important**: note that the ramp-up and ramp-down feature can lead to
deployments achieving less than the specified number of pods, due to the
HPA 10% change rule and the ceiling function applied to the desired
number of the pods (check the [algorithm details][algo-details]). It
varies with the configured metric for `ScalingSchedule` events, the
number of pods and the configured `horizontal-pod-autoscaler-tolerance`
flag of your kubernetes installation. [This gist][gist] contains the code to
simulate the situations a deployment with different number of pods, with
a metric of 10000 can face with 10 buckets (max of 90% of the metric
returned) and 5 buckets (max of 80% of the metric returned). The ramp-up
and ramp-down feature can be disabled by setting
`--scaling-schedule-default-scaling-window` to 0 and abrupt scalings can
be handled via [scaling policies][policies].
[algo-details]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details
[gist]: https://gist.github.com/jonathanbeber/37f1f918ab7ef6101c6ce56cc2cef3a2
[policies]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#scaling-policies
### Example
This is an example of using the ScalingSchedule collectors to collect
@ -779,7 +886,7 @@ An HPA can reference the deployed `ClusterScalingSchedule` object as
this example:
```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: "myapp-hpa"
@ -826,8 +933,3 @@ Note that these number of pods are just considering these custom
metrics, the normal HPA behavior still applies, such as: in case of
multiple metrics the biggest number of pods is the utilized one, HPA max
and min replica configuration, autoscaling policies, etc.
These collectors are disabled by default, you have to start the server
with the `--scaling-schedule` flag to enable it. Remember to deploy the CRDs
`ScalingSchedule` and `ClusterScalingSchedule` and allow the service
account used by the server to read, watch and list them.

View File

@ -1,7 +1,9 @@
version: "2017-09-20"
pipeline:
- id: build
overlay: ci/golang
vm_config:
type: linux
image: "cdp-runtime/go"
cache:
paths:
- /go/pkg/mod # pkg cache for Go modules
@ -28,3 +30,17 @@ pipeline:
IMAGE=$IMAGE VERSION=$VERSION make build.docker
git diff --stat --exit-code
IMAGE=$IMAGE VERSION=$VERSION make build.push
- desc: Build and push image to Zalando's registry
cmd: |
if [[ $CDP_TARGET_BRANCH == master && ! $CDP_PULL_REQUEST_NUMBER ]]; then
IMAGE=container-registry-test.zalando.net/teapot/kube-metrics-adapter
VERSION=$(git describe --tags --always)
else
IMAGE=container-registry-test.zalando.net/teapot/kube-metrics-adapter-test
VERSION=$CDP_BUILD_VERSION
fi
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 .
cdp-promote-image "${IMAGE}:${VERSION}"

View File

@ -1,10 +1,9 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.0
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: clusterscalingschedules.zalando.org
spec:
@ -16,7 +15,12 @@ spec:
singular: clusterscalingschedule
scope: Cluster
versions:
- name: v1
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ClusterScalingSchedule describes a cluster scoped time based
@ -37,6 +41,11 @@ spec:
spec:
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
properties:
scalingWindowDurationMinutes:
description: Fade the scheduled values in and out over this many minutes.
If unset, the default per-cluster value will be used.
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
@ -47,13 +56,18 @@ spec:
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formated date.
It has to be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes 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.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
@ -72,6 +86,10 @@ spec:
- Sat
type: string
type: array
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
@ -96,9 +114,9 @@ spec:
value:
description: The metric value that will be returned for the
defined schedule.
format: int64
type: integer
required:
- durationMinutes
- type
- value
type: object
@ -106,11 +124,22 @@ spec:
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""

View File

@ -1,6 +1,6 @@
apiVersion: v2
name: kube-metrics-adapter
version: 0.1.11
version: 0.2.0
description: kube-metrics-adapter helm chart
home: https://github.com/zalando-incubator/kube-metrics-adapter
maintainers:

View File

@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.0
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: clusterscalingschedules.zalando.org
spec:
@ -15,7 +15,12 @@ spec:
singular: clusterscalingschedule
scope: Cluster
versions:
- name: v1
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ClusterScalingSchedule describes a cluster scoped time based
@ -36,6 +41,11 @@ spec:
spec:
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
properties:
scalingWindowDurationMinutes:
description: Fade the scheduled values in and out over this many minutes.
If unset, the default per-cluster value will be used.
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
@ -46,13 +56,18 @@ spec:
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formated date.
It has to be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes 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.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
@ -71,6 +86,10 @@ spec:
- Sat
type: string
type: array
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
@ -95,9 +114,9 @@ spec:
value:
description: The metric value that will be returned for the
defined schedule.
format: int64
type: integer
required:
- durationMinutes
- type
- value
type: object
@ -105,11 +124,22 @@ spec:
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""

View File

@ -16,8 +16,23 @@ spec:
labels:
application: kube-metrics-adapter
version: {{ .Values.registry.imageTag }}
{{- if .Values.podAnnotations }}
annotations: {{- toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
spec:
serviceAccountName: kube-metrics-adapter
{{- if .Values.nodeSelector }}
nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{ toYaml .Values.tolerations | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity: {{ toYaml .Values.affinity | nindent 8 }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- end }}
containers:
- name: kube-metrics-adapter
image: {{ .Values.registry.image}}:{{ .Values.registry.imageTag }}
@ -149,6 +164,9 @@ spec:
{{- if .Values.skipperIngressMetrics }}
- --skipper-ingress-metrics={{ .Values.skipperIngressMetrics }}
{{- end}}
{{- if .Values.skipperRouteGroupMetrics }}
- --skipper-routegroup-metrics={{ .Values.skipperRouteGroupMetrics }}
{{- end}}
{{- if .Values.log.stderrThreshold }}
- --stderrthreshold={{ .Values.log.stderrThreshold }}
{{- end}}

View File

@ -59,12 +59,22 @@ rules:
- statefulsets
verbs:
- get
{{- if .Values.skipperRouteGroupMetrics }}
- apiGroups:
- extensions
- networking.k8s.io
resources:
- ingresses
verbs:
- get
{{- end }}
{{- if .Values.skipperRouteGroupMetrics }}
- apiGroups:
- zalando.org
resources:
- routegroups
verbs:
- get
{{- end }}
- apiGroups:
- autoscaling
resources:
@ -83,6 +93,13 @@ rules:
- get
- list
- watch
- apiGroups:
- zalando.org
resources:
- clusterscalingschedules/status
- scalingschedules/status
verbs:
- update
{{- end}}
---
apiVersion: rbac.authorization.k8s.io/v1

View File

@ -3,19 +3,26 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.0
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: scalingschedules.zalando.org
spec:
group: zalando.org
names:
categories:
- all
kind: ScalingSchedule
listKind: ScalingScheduleList
plural: scalingschedules
singular: scalingschedule
scope: Namespaced
versions:
- name: v1
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ScalingSchedule describes a namespaced time based metric to be
@ -36,6 +43,11 @@ spec:
spec:
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
properties:
scalingWindowDurationMinutes:
description: Fade the scheduled values in and out over this many minutes.
If unset, the default per-cluster value will be used.
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
@ -46,13 +58,18 @@ spec:
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formated date.
It has to be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes 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.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
@ -71,6 +88,10 @@ spec:
- Sat
type: string
type: array
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
@ -95,9 +116,9 @@ spec:
value:
description: The metric value that will be returned for the
defined schedule.
format: int64
type: integer
required:
- durationMinutes
- type
- value
type: object
@ -105,11 +126,22 @@ spec:
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""

View File

@ -4,7 +4,7 @@ replicas: 1
registry:
image: registry.opensource.zalan.do/teapot/kube-metrics-adapter
imageTag: v0.1.10
imageTag: v0.2.0
imagePullPolicy: IfNotPresent
service:
@ -22,6 +22,7 @@ http2MaxStreamsPerConnection:
listerKubeConfig:
skipperBackendsAnnotation:
skipperIngressMetrics:
skipperRouteGroupMetrics:
token:
vmodule:
@ -95,3 +96,14 @@ resources:
scalingSchedule:
enabled: false
nodeSelector:
kubernetes.io/os: linux
tolerations: []
affinity: {}
priorityClassName: ""
podAnnotations: {}

View File

@ -67,7 +67,6 @@ rules:
# only relevant if running with the flag:
# --skipper-ingress-metrics
- apiGroups:
- extensions
- networking.k8s.io
resources:
- ingresses
@ -98,6 +97,13 @@ rules:
- get
- list
- watch
- apiGroups:
- zalando.org
resources:
- clusterscalingschedules/status
- scalingschedules/status
verbs:
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding

View File

@ -1,22 +1,28 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.0
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: scalingschedules.zalando.org
spec:
group: zalando.org
names:
categories:
- all
kind: ScalingSchedule
listKind: ScalingScheduleList
plural: scalingschedules
singular: scalingschedule
scope: Namespaced
versions:
- name: v1
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ScalingSchedule describes a namespaced time based metric to be
@ -37,6 +43,11 @@ spec:
spec:
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
properties:
scalingWindowDurationMinutes:
description: Fade the scheduled values in and out over this many minutes.
If unset, the default per-cluster value will be used.
format: int64
type: integer
schedules:
description: Schedules is the list of schedules for this ScalingSchedule
resource. All the schedules defined here will result on the value
@ -47,13 +58,18 @@ spec:
properties:
date:
description: Defines the starting date of a OneTime schedule.
It has to be a RFC3339 formated date.
It has to be a RFC3339 formatted date.
format: date-time
type: string
durationMinutes:
description: The duration in minutes 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.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
@ -72,6 +88,10 @@ spec:
- Sat
type: string
type: array
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
@ -96,9 +116,9 @@ spec:
value:
description: The metric value that will be returned for the
defined schedule.
format: int64
type: integer
required:
- durationMinutes
- type
- value
type: object
@ -106,11 +126,22 @@ spec:
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""

View File

@ -1,5 +1,5 @@
FROM registry.opensource.zalan.do/stups/alpine:latest
MAINTAINER Team Teapot @ Zalando SE <team-teapot@zalando.de>
FROM registry.opensource.zalan.do/library/alpine-3.13:latest
LABEL maintainer="Team Teapot @ Zalando SE <team-teapot@zalando.de>"
# add binary
ADD build/linux/custom-metrics-consumer /

View File

@ -39,7 +39,7 @@ spec:
- type: Object
object:
describedObject:
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
name: custom-metrics-consumer
metric:

View File

@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: custom-metrics-consumer

View File

@ -11,7 +11,9 @@ import (
func metricsHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
_, err := w.Write([]byte(fmt.Sprintf(`{"queue": {"length": %d}}`, size)))
log.Fatalf("failed to write: %v", err)
if err != nil {
log.Fatalf("failed to write: %v", err)
}
}
var (

147
go.mod
View File

@ -1,35 +1,126 @@
module github.com/zalando-incubator/kube-metrics-adapter
require (
github.com/NYTimes/gziphandler v1.0.1 // indirect
github.com/aws/aws-sdk-go v1.40.22
github.com/go-openapi/spec v0.20.3
github.com/aws/aws-sdk-go v1.44.273
github.com/influxdata/influxdb-client-go v0.2.0
github.com/influxdata/line-protocol v0.0.0-20201012155213-5f565037cbc9 // indirect
github.com/kubernetes-sigs/custom-metrics-apiserver v0.0.0-20201216091021-1b9fa998bbaa
github.com/mailru/easyjson v0.7.7 // indirect
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.26.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/spyzhov/ajson v0.4.2
github.com/stretchr/testify v1.7.0
github.com/szuecs/routegroup-client v0.18.3
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20180921141935-824b77fb1f84
go.uber.org/zap v1.13.0 // indirect
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.20.9
k8s.io/apimachinery v0.20.9
k8s.io/apiserver v0.20.9
k8s.io/client-go v0.20.9
k8s.io/code-generator v0.20.9
k8s.io/component-base v0.20.9
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/common v0.44.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.7.0
github.com/spyzhov/ajson v0.8.0
github.com/stretchr/testify v1.8.2
github.com/szuecs/routegroup-client v0.21.1
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20230223125308-aff25efae501
golang.org/x/net v0.10.0
golang.org/x/oauth2 v0.8.0
golang.org/x/sync v0.2.0
k8s.io/api v0.23.0
k8s.io/apimachinery v0.23.0
k8s.io/apiserver v0.23.0
k8s.io/client-go v0.23.0
k8s.io/code-generator v0.23.0
k8s.io/component-base v0.23.0
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
k8s.io/metrics v0.20.9
sigs.k8s.io/controller-tools v0.5.0
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf
k8s.io/metrics v0.22.17
sigs.k8s.io/controller-tools v0.8.0
sigs.k8s.io/custom-metrics-apiserver v1.22.0
)
go 1.16
require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // 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/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.3 // 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.3 // indirect
github.com/gobuffalo/flect v0.2.3 // 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/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/imdario/mergo v0.3.13 // 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/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // 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/matttproud/golang_protobuf_extensions v1.0.4 // 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/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/v2 v2.305.6 // indirect
go.etcd.io/etcd/client/v3 v3.5.6 // 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.11.1 // 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 v1.11.1 // 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.11.1 // 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.6.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
google.golang.org/grpc v1.52.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.23.0 // indirect
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
k8s.io/klog/v2 v2.90.0 // indirect
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30 // 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
)
replace (
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
)
go 1.20

804
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ import (
"strings"
"time"
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
autoscalingv2 "k8s.io/api/autoscaling/v2"
)
const (

View File

@ -4,7 +4,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
autoscalingv2 "k8s.io/api/autoscaling/v2"
)
func TestParser(t *testing.T) {

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
package v1
import (
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@ -11,11 +13,16 @@ import (
// ScalingSchedule describes a namespaced time based metric to be used
// in autoscaling operations.
// +k8s:deepcopy-gen=true
// +kubebuilder:resource:categories=all
// +kubebuilder:printcolumn:name="Active",type=boolean,JSONPath=`.status.active`,description="Whether one or more schedules are currently active."
// +kubebuilder:subresource:status
type ScalingSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ScalingScheduleSpec `json:"spec"`
// +optional
Status ScalingScheduleStatus `json:"status"`
}
// +genclient
@ -26,17 +33,26 @@ type ScalingSchedule struct {
// ClusterScalingSchedule describes a cluster scoped time based metric
// to be used in autoscaling operations.
// +k8s:deepcopy-gen=true
// +kubebuilder:resource:categories=all
// +kubebuilder:printcolumn:name="Active",type=boolean,JSONPath=`.status.active`,description="Whether one or more schedules are currently active."
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
type ClusterScalingSchedule struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ScalingScheduleSpec `json:"spec"`
// +optional
Status ScalingScheduleStatus `json:"status"`
}
// ScalingScheduleSpec is the spec part of the ScalingSchedule.
// +k8s:deepcopy-gen=true
type ScalingScheduleSpec struct {
// Fade the scheduled values in and out over this many minutes. If unset, the default per-cluster value will be used.
// +optional
ScalingWindowDurationMinutes *int64 `json:"scalingWindowDurationMinutes,omitempty"`
// 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
@ -52,14 +68,23 @@ type Schedule struct {
// +optional
Period *SchedulePeriod `json:"period,omitempty"`
// Defines the starting date of a OneTime schedule. It has to
// be a RFC3339 formated date.
// be a RFC3339 formatted date.
// +optional
Date *ScheduleDate `json:"date,omitempty"`
// The duration in minutes that the configured value will be
// Defines the ending date of a OneTime schedule. It must be
// a RFC3339 formatted date.
// +optional
EndDate *ScheduleDate `json:"endDate,omitempty"`
// The duration in minutes (default 0) that the configured value will be
// returned for the defined schedule.
// +optional
DurationMinutes int `json:"durationMinutes"`
// The metric value that will be returned for the defined schedule.
Value int `json:"value"`
Value int64 `json:"value"`
}
func (in Schedule) Duration() time.Duration {
return time.Duration(in.DurationMinutes) * time.Minute
}
// Defines if the schedule is a OneTime schedule or
@ -80,6 +105,10 @@ type SchedulePeriod struct {
// The startTime has the format HH:MM
// +kubebuilder:validation:Pattern="(([0-1][0-9])|([2][0-3])):([0-5][0-9])"
StartTime string `json:"startTime"`
// The endTime has the format HH:MM
// +kubebuilder:validation:Pattern="(([0-1][0-9])|([2][0-3])):([0-5][0-9])"
// +optional
EndTime string `json:"endTime"`
// The days that this schedule will be active.
Days []ScheduleDay `json:"days"`
// The location name corresponding to a file in the IANA
@ -106,6 +135,16 @@ const (
// +kubebuilder:validation:Format="date-time"
type ScheduleDate string
// ScalingScheduleStatus is the status section of the ScalingSchedule.
// +k8s:deepcopy-gen=true
type ScalingScheduleStatus struct {
// Active is true if at least one of the schedules defined in the
// scaling schedule is currently active.
// +kubebuilder:default:=false
// +optional
Active bool `json:"active"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ScalingScheduleList is a list of namespaced scaling schedules.
@ -119,11 +158,11 @@ type ScalingScheduleList struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ScalingScheduleList is a list of cluster scoped scaling schedules.
// ClusterScalingScheduleList is a list of cluster scoped scaling schedules.
// +k8s:deepcopy-gen=true
type ClusterScalingScheduleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ScalingSchedule `json:"items"`
Items []ClusterScalingSchedule `json:"items"`
}

View File

@ -31,6 +31,7 @@ func (in *ClusterScalingSchedule) DeepCopyInto(out *ClusterScalingSchedule) {
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
return
}
@ -59,7 +60,7 @@ func (in *ClusterScalingScheduleList) DeepCopyInto(out *ClusterScalingScheduleLi
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ScalingSchedule, len(*in))
*out = make([]ClusterScalingSchedule, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
@ -91,6 +92,7 @@ func (in *ScalingSchedule) DeepCopyInto(out *ScalingSchedule) {
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
return
}
@ -148,6 +150,11 @@ func (in *ScalingScheduleList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ScalingScheduleSpec) DeepCopyInto(out *ScalingScheduleSpec) {
*out = *in
if in.ScalingWindowDurationMinutes != nil {
in, out := &in.ScalingWindowDurationMinutes, &out.ScalingWindowDurationMinutes
*out = new(int64)
**out = **in
}
if in.Schedules != nil {
in, out := &in.Schedules, &out.Schedules
*out = make([]Schedule, len(*in))
@ -168,6 +175,22 @@ func (in *ScalingScheduleSpec) DeepCopy() *ScalingScheduleSpec {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ScalingScheduleStatus) DeepCopyInto(out *ScalingScheduleStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScalingScheduleStatus.
func (in *ScalingScheduleStatus) DeepCopy() *ScalingScheduleStatus {
if in == nil {
return nil
}
out := new(ScalingScheduleStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Schedule) DeepCopyInto(out *Schedule) {
*out = *in
@ -181,6 +204,11 @@ func (in *Schedule) DeepCopyInto(out *Schedule) {
*out = new(ScheduleDate)
**out = **in
}
if in.EndDate != nil {
in, out := &in.EndDate, &out.EndDate
*out = new(ScheduleDate)
**out = **in
}
return
}

View File

@ -20,6 +20,7 @@ package versioned
import (
"fmt"
"net/http"
zalandov1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/typed/zalando.org/v1"
discovery "k8s.io/client-go/discovery"
@ -55,22 +56,41 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
// NewForConfig creates a new Clientset for the given config.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfig will generate a rate-limiter in configShallowCopy.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
// share the transport between all clients
httpClient, err := rest.HTTPClientFor(&configShallowCopy)
if err != nil {
return nil, err
}
return NewForConfigAndClient(&configShallowCopy, httpClient)
}
// NewForConfigAndClient creates a new Clientset for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
if configShallowCopy.Burst <= 0 {
return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
}
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.zalandoV1, err = zalandov1.NewForConfig(&configShallowCopy)
cs.zalandoV1, err = zalandov1.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
@ -80,11 +100,11 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.zalandoV1 = zalandov1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
cs, err := NewForConfig(c)
if err != nil {
panic(err)
}
return cs
}
// New creates a new Clientset for the given RESTClient.

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