mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2025-05-12 08:21:54 +00:00
Compare commits
119 Commits
fix-nakadi
...
b44fcbaae8
Author | SHA1 | Date | |
---|---|---|---|
b44fcbaae8 | |||
eb27f6037f | |||
6149308e6d | |||
62cc9c98f3 | |||
e03222b12b | |||
063d3de6d2 | |||
9c8837c8ff | |||
ec55cda1f8 | |||
f7dfe8aedf | |||
e0a1ca5de6 | |||
876074ab75 | |||
5da796fc9a | |||
5f6a683d64 | |||
d416441688 | |||
4204daa44f | |||
f02956ea35 | |||
e580c5b5f5 | |||
58000627d6 | |||
8fefda5935 | |||
26baf4baed | |||
4168dae7dd | |||
6c95e44756 | |||
9f26d4b2ed | |||
c26604c36b | |||
ca9031228b | |||
48f0df44d9 | |||
964c4ecf04 | |||
498f85e7b1 | |||
bdb374c4c1 | |||
802bf08508 | |||
ffe65bf915 | |||
9ff49a9b5f | |||
68fcf9bd2d | |||
b4447316c1 | |||
477f9fd9b9 | |||
24e7b2439c | |||
cd133b0781 | |||
bf1a0b4631 | |||
b371621159 | |||
0e88d4f910 | |||
81e28c98eb | |||
527a5fcde7 | |||
17d91ad77d | |||
45ea288963 | |||
b0f2f2ce47 | |||
a3bf15429c | |||
4d4dfe07b2 | |||
79918e0525 | |||
06e0010ce3 | |||
52d0261ab9 | |||
5863416214 | |||
108b45ed79 | |||
f90c0a1455 | |||
42f93ea557 | |||
c4123ff203 | |||
853addb5ab | |||
99a20bb7f6 | |||
9ca418320b | |||
b8c79becde | |||
8245fbe772 | |||
8cfc92e81c | |||
f9489767ed | |||
a7007d6924 | |||
61d5880f8c | |||
12dca32316 | |||
900e78a318 | |||
35e0241cbf | |||
cb80a498dd | |||
f76e7033bd | |||
f406e860c1 | |||
5a543781d7 | |||
ca8592013c | |||
63517ebf70 | |||
5c942b9245 | |||
e49845dc93 | |||
f55afc0905 | |||
04f350698f | |||
cafe11a109 | |||
d74b7a1632 | |||
460ed1bd4c | |||
8831ac62d2 | |||
ae5c2a538a | |||
68bd36ed7b | |||
7cd565c100 | |||
8f0b25517c | |||
c8372976e6 | |||
dcedc0c17e | |||
f1a2e80d15 | |||
2f9aefc4e7 | |||
63120a8c1e | |||
dcf686b9c5 | |||
77a04c49b6 | |||
b237f5a9d2 | |||
136d31e97f | |||
4d4d5d44bf | |||
a46a544bce | |||
ea4a3eb421 | |||
897fcdd423 | |||
61e5cde106 | |||
f9141fd882 | |||
aece0b5efa | |||
856ce2c391 | |||
66b324bb30 | |||
c765317359 | |||
c973a9e712 | |||
ef26f47884 | |||
2ec9b26ec8 | |||
7cc533c892 | |||
c9ab7402c5 | |||
0e22243de6 | |||
91acacb4f4 | |||
0678ef1131 | |||
130c67cdf1 | |||
1661d7c4bc | |||
905cf8a06f | |||
15ceeb7316 | |||
776ee93d4d | |||
99a194fe1a | |||
7a63a04668 |
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@ -3,9 +3,16 @@ updates:
|
||||
- package-ecosystem: gomod
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: monthly
|
||||
time: "07:00"
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
groups:
|
||||
all-go-mod-patch-and-minor:
|
||||
patterns: ["*"]
|
||||
update-types: ["patch", "minor"]
|
||||
ignore:
|
||||
# Ignore k8s and its transitives modules as they are upgraded manually
|
||||
- dependency-name: "k8s.io/*"
|
||||
update-types: [ "version-update:semver-major", "version-update:semver-minor" ]
|
||||
- package-ecosystem: docker
|
||||
directory: "/"
|
||||
schedule:
|
||||
|
6
.github/workflows/ci.yaml
vendored
6
.github/workflows/ci.yaml
vendored
@ -10,10 +10,10 @@ jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '^1.19'
|
||||
go-version: '^1.23'
|
||||
- run: go version
|
||||
- run: go install github.com/mattn/goveralls@latest
|
||||
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
|
13
.github/workflows/codeql-analysis.yml
vendored
13
.github/workflows/codeql-analysis.yml
vendored
@ -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,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 /
|
||||
|
22
Makefile
22
Makefile
@ -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
|
||||
|
||||
@ -42,11 +42,21 @@ $(OPENAPI): go.mod
|
||||
go run k8s.io/kube-openapi/cmd/openapi-gen \
|
||||
--go-header-file hack/boilerplate.go.txt \
|
||||
--logtostderr \
|
||||
-i k8s.io/metrics/pkg/apis/custom_metrics,k8s.io/metrics/pkg/apis/custom_metrics/v1beta1,k8s.io/metrics/pkg/apis/custom_metrics/v1beta2,k8s.io/metrics/pkg/apis/external_metrics,k8s.io/metrics/pkg/apis/external_metrics/v1beta1,k8s.io/metrics/pkg/apis/metrics,k8s.io/metrics/pkg/apis/metrics/v1beta1,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/version,k8s.io/api/core/v1 \
|
||||
-p pkg/api/generated/openapi \
|
||||
-o . \
|
||||
-O zz_generated.openapi \
|
||||
-r /dev/null
|
||||
--output-dir pkg/api/generated/openapi \
|
||||
--output-pkg github.com/zalando-incubator/kube-metrics-adapter/pkg/api/generated/openapi \
|
||||
--output-file zz_generated.openapi.go \
|
||||
-r /dev/null \
|
||||
k8s.io/metrics/pkg/apis/custom_metrics \
|
||||
k8s.io/metrics/pkg/apis/custom_metrics/v1beta1 \
|
||||
k8s.io/metrics/pkg/apis/custom_metrics/v1beta2 \
|
||||
k8s.io/metrics/pkg/apis/external_metrics \
|
||||
k8s.io/metrics/pkg/apis/external_metrics/v1beta1 \
|
||||
k8s.io/metrics/pkg/apis/metrics \
|
||||
k8s.io/metrics/pkg/apis/metrics/v1beta1 \
|
||||
k8s.io/apimachinery/pkg/apis/meta/v1 \
|
||||
k8s.io/apimachinery/pkg/api/resource \
|
||||
k8s.io/apimachinery/pkg/version \
|
||||
k8s.io/api/core/v1
|
||||
|
||||
build.local: build/$(BINARY) $(GENERATED_CRDS)
|
||||
build.linux: build/linux/$(BINARY)
|
||||
|
24
README.md
24
README.md
@ -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 |
|
||||
@ -104,6 +116,7 @@ metadata:
|
||||
annotations:
|
||||
# metric-config.<metricType>.<metricName>.<collectorType>/<configKey>
|
||||
metric-config.pods.requests-per-second.json-path/json-key: "$.http_server.rps"
|
||||
metric-config.pods.requests-per-second.json-path/json-eval: "ceil($['active processes'] / $['total processes'] * 100)" # cannot use both json-eval and json-key
|
||||
metric-config.pods.requests-per-second.json-path/path: /metrics
|
||||
metric-config.pods.requests-per-second.json-path/port: "9090"
|
||||
metric-config.pods.requests-per-second.json-path/scheme: "https"
|
||||
@ -146,6 +159,10 @@ The json-path query support depends on the
|
||||
See the README for possible queries. It's expected that the metric you query
|
||||
returns something that can be turned into a `float64`.
|
||||
|
||||
The `json-eval` configuration option allows for more complex calculations to be
|
||||
performed on the extracted metric. The `json-eval` expression is evaluated using
|
||||
[ajson's script engine](https://github.com/spyzhov/ajson?tab=readme-ov-file#script-engine).
|
||||
|
||||
The other configuration options `path`, `port` and `scheme` specify where the metrics
|
||||
endpoint is exposed on the pod. The `path` and `port` options do not have default values
|
||||
so they must be defined. The `scheme` is optional and defaults to `http`.
|
||||
@ -426,7 +443,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:
|
||||
@ -813,6 +830,7 @@ metadata:
|
||||
annotations:
|
||||
# metric-config.<metricType>.<metricName>.<collectorType>/<configKey>
|
||||
metric-config.external.unique-metric-name.json-path/json-key: "$.some-metric.value"
|
||||
metric-config.external.unique-metric-name.json-path/json-eval: ceil($['active processes'] / $['total processes'] * 100) # cannot use both json-eval and json-key
|
||||
metric-config.external.unique-metric-name.json-path/endpoint: "http://metric-source.app-namespace:8080/metrics"
|
||||
metric-config.external.unique-metric-name.json-path/aggregator: "max"
|
||||
metric-config.external.unique-metric-name.json-path/interval: "60s" # optional
|
||||
@ -840,6 +858,8 @@ The HTTP collector similar to the Pod Metrics collector. The following
|
||||
configuration values are supported:
|
||||
|
||||
- `json-key` to specify the JSON path of the metric to be queried
|
||||
- `json-eval` to specify an evaluate string to [evaluate on the script engine](https://github.com/spyzhov/ajson?tab=readme-ov-file#script-engine),
|
||||
cannot be used in conjunction with `json-key`
|
||||
- `endpoint` the fully formed path to query for the metric. In the above example a Kubernetes _Service_
|
||||
in the namespace `app-namespace` is called.
|
||||
- `aggregator` is only required if the metric is an array of values and specifies how the values
|
||||
|
@ -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}"
|
||||
|
@ -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.16.5
|
||||
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,6 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: kube-metrics-adapter
|
||||
version: 0.2.0
|
||||
version: 0.2.3
|
||||
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}}
|
||||
|
@ -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}}
|
||||
|
@ -3,3 +3,4 @@ apiVersion: v1
|
||||
metadata:
|
||||
name: kube-metrics-adapter
|
||||
namespace: {{ .Values.namespace }}
|
||||
annotations: {{- toYaml .Values.serviceAccountAnnotations | nindent 4 }}
|
||||
|
@ -4,7 +4,7 @@ replicas: 1
|
||||
|
||||
registry:
|
||||
image: registry.opensource.zalan.do/teapot/kube-metrics-adapter
|
||||
imageTag: v0.2.0
|
||||
imageTag: v0.2.3
|
||||
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
|
||||
@ -107,3 +107,5 @@ affinity: {}
|
||||
priorityClassName: ""
|
||||
|
||||
podAnnotations: {}
|
||||
|
||||
serviceAccountAnnotations: {}
|
||||
|
@ -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.16.5
|
||||
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,4 +1,4 @@
|
||||
apiVersion: autoscaling/v2beta2
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: custom-metrics-consumer
|
||||
|
253
go.mod
253
go.mod
@ -1,128 +1,191 @@
|
||||
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/prometheus/common v0.45.0
|
||||
github.com/argoproj/argo-rollouts v1.8.0
|
||||
github.com/aws/aws-sdk-go-v2 v1.36.2
|
||||
github.com/aws/aws-sdk-go-v2/config v1.29.7
|
||||
github.com/aws/aws-sdk-go-v2/service/sqs v1.37.15
|
||||
github.com/influxdata/influxdb-client-go v1.4.0
|
||||
github.com/prometheus/client_golang v1.21.0
|
||||
github.com/prometheus/common v0.62.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/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
|
||||
github.com/spf13/cobra v1.9.1
|
||||
github.com/spyzhov/ajson v0.9.6
|
||||
github.com/stretchr/testify v1.10.0
|
||||
github.com/szuecs/routegroup-client v0.28.2
|
||||
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20240619093047-7853f3386b71
|
||||
golang.org/x/net v0.35.0
|
||||
golang.org/x/oauth2 v0.26.0
|
||||
golang.org/x/sync v0.11.0
|
||||
k8s.io/api v0.31.6
|
||||
k8s.io/apimachinery v0.31.6
|
||||
k8s.io/apiserver v0.31.6
|
||||
k8s.io/client-go v0.31.6
|
||||
k8s.io/code-generator v0.31.6
|
||||
k8s.io/component-base v0.31.6
|
||||
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-20240620174524-b456828f718b
|
||||
k8s.io/metrics v0.31.6
|
||||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
|
||||
sigs.k8s.io/controller-tools v0.16.5
|
||||
sigs.k8s.io/custom-metrics-apiserver v1.30.1-0.20241105195130-84dc8cfe2555
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.4.0 // 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/antlr4-go/antlr/v4 v4.13.0 // 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.60 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.29 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.33 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.33 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.14 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.16 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.15 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.33.15 // indirect
|
||||
github.com/aws/smithy-go v1.22.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/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.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/bytedance/sonic v1.11.9 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // 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.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/deepmap/oapi-codegen v1.16.3 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
|
||||
github.com/fatih/color v1.18.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/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.4 // 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.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
||||
github.com/go-openapi/jsonreference v0.21.0 // indirect
|
||||
github.com/go-openapi/swag v0.23.0 // 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.22.0 // indirect
|
||||
github.com/gobuffalo/flect v1.0.3 // indirect
|
||||
github.com/goccy/go-json v0.10.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/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-20241205020045-f7e15b2f3e62 // indirect
|
||||
github.com/google/cel-go v0.20.1 // 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.20.0 // 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.11 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
||||
github.com/kylelemons/godebug v1.1.0 // 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/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // 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/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/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // 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.6 // indirect
|
||||
github.com/stoewer/go-strcase v1.3.0 // indirect
|
||||
github.com/tdewolff/minify/v2 v2.20.34 // indirect
|
||||
github.com/tdewolff/parse/v2 v2.7.15 // 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/x448/float16 v0.8.4 // indirect
|
||||
github.com/yosssi/ace v0.0.5 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.14 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 // 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.33.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
|
||||
golang.org/x/mod v0.21.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/term v0.29.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.26.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||
google.golang.org/grpc v1.68.1 // indirect
|
||||
google.golang.org/protobuf v1.36.1 // indirect
|
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0 // 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.31.2 // indirect
|
||||
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
|
||||
k8s.io/klog/v2 v2.130.1 // indirect
|
||||
k8s.io/kms v0.31.6 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // 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.23
|
||||
|
@ -24,51 +24,40 @@ CUSTOM_RESOURCE_NAME="zalando.org"
|
||||
CUSTOM_RESOURCE_VERSION="v1"
|
||||
|
||||
SCRIPT_ROOT="$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
OUTPUT_BASE="$(dirname "${BASH_SOURCE[0]}")/"
|
||||
|
||||
# generate the code with:
|
||||
# --output-base because this script should also be able to run inside the vendor dir of
|
||||
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
|
||||
# instead of the $GOPATH directly. For normal projects this can be dropped.
|
||||
|
||||
OUTPUT_PKG="${GOPKG}/pkg/client"
|
||||
OUTPUT_DIR="pkg/client"
|
||||
OUTPUT_PKG="${GOPKG}/${OUTPUT_DIR}"
|
||||
APIS_PKG="${GOPKG}/pkg/apis"
|
||||
GROUPS_WITH_VERSIONS="${CUSTOM_RESOURCE_NAME}:${CUSTOM_RESOURCE_VERSION}"
|
||||
|
||||
echo "Generating deepcopy funcs"
|
||||
go run k8s.io/code-generator/cmd/deepcopy-gen \
|
||||
--input-dirs "${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}" \
|
||||
-O zz_generated.deepcopy \
|
||||
--output-file zz_generated.deepcopy.go \
|
||||
--bounding-dirs "${APIS_PKG}" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-base "$OUTPUT_BASE"
|
||||
"${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}"
|
||||
|
||||
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}"
|
||||
go run k8s.io/code-generator/cmd/client-gen \
|
||||
--clientset-name versioned \
|
||||
--input-base "" \
|
||||
--input "${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}" \
|
||||
--output-package "${OUTPUT_PKG}/clientset" \
|
||||
--output-pkg "${OUTPUT_PKG}/clientset" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-base "$OUTPUT_BASE"
|
||||
--output-dir "${OUTPUT_DIR}/clientset"
|
||||
|
||||
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers"
|
||||
go run k8s.io/code-generator/cmd/lister-gen \
|
||||
--input-dirs "${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}" \
|
||||
--output-package "${OUTPUT_PKG}/listers" \
|
||||
--output-pkg "${OUTPUT_PKG}/listers" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-base "$OUTPUT_BASE"
|
||||
--output-dir "${OUTPUT_DIR}/listers" \
|
||||
"${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}"
|
||||
|
||||
echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers"
|
||||
go run k8s.io/code-generator/cmd/informer-gen \
|
||||
--input-dirs "${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}" \
|
||||
--versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}/${CLIENTSET_NAME_VERSIONED:-versioned}" \
|
||||
--listers-package "${OUTPUT_PKG}/listers" \
|
||||
--output-package "${OUTPUT_PKG}/informers" \
|
||||
--output-pkg "${OUTPUT_PKG}/informers" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-base "$OUTPUT_BASE"
|
||||
|
||||
# hack to make the generated code work with Go module based projects
|
||||
cp -r "$OUTPUT_BASE/$GOPKG/pkg/apis" ./pkg
|
||||
cp -r "$OUTPUT_BASE/$GOPKG/pkg/client" ./pkg
|
||||
rm -rf "${OUTPUT_BASE:?}${SRC}"
|
||||
--output-dir "${OUTPUT_DIR}/informers" \
|
||||
"${APIS_PKG}/${CUSTOM_RESOURCE_NAME}/${CUSTOM_RESOURCE_VERSION}"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,13 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// ScalingScheduler is an interface that represents a ScalingSchedule resource,
|
||||
// namespaced or cluster wide.
|
||||
type ScalingScheduler interface {
|
||||
Identifier() string
|
||||
ResourceSpec() ScalingScheduleSpec
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
@ -25,6 +32,17 @@ type ScalingSchedule struct {
|
||||
Status ScalingScheduleStatus `json:"status"`
|
||||
}
|
||||
|
||||
// Identifier returns the namespaced scalingScale Identifier in the format
|
||||
// `<namespace>/<name>`.
|
||||
func (s *ScalingSchedule) Identifier() string {
|
||||
return s.ObjectMeta.Namespace + "/" + s.ObjectMeta.Name
|
||||
}
|
||||
|
||||
// ResourceSpec returns the ScalingScheduleSpec of the ScalingSchedule.
|
||||
func (s *ScalingSchedule) ResourceSpec() ScalingScheduleSpec {
|
||||
return s.Spec
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@ -46,6 +64,17 @@ type ClusterScalingSchedule struct {
|
||||
Status ScalingScheduleStatus `json:"status"`
|
||||
}
|
||||
|
||||
// Identifier returns the cluster scalingScale Identifier in the format
|
||||
// `<name>`.
|
||||
func (s *ClusterScalingSchedule) Identifier() string {
|
||||
return s.ObjectMeta.Name
|
||||
}
|
||||
|
||||
// ResourceSpec returns the ScalingScheduleSpec of the ClusterScalingSchedule.
|
||||
func (s *ClusterScalingSchedule) ResourceSpec() ScalingScheduleSpec {
|
||||
return s.Spec
|
||||
}
|
||||
|
||||
// ScalingScheduleSpec is the spec part of the ScalingSchedule.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ScalingScheduleSpec struct {
|
||||
|
@ -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
|
||||
|
@ -31,8 +31,12 @@ import (
|
||||
|
||||
// NewSimpleClientset returns a clientset that will respond with the provided objects.
|
||||
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
|
||||
// without applying any validations and/or defaults. It shouldn't be considered a replacement
|
||||
// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement
|
||||
// for a real clientset and is mostly useful in simple unit tests.
|
||||
//
|
||||
// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves
|
||||
// server side apply testing. NewClientset is only available when apply configurations are generated (e.g.
|
||||
// via --with-applyconfig).
|
||||
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
|
||||
for _, obj := range objects {
|
||||
|
@ -20,14 +20,13 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
scheme "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/scheme"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
)
|
||||
|
||||
// ClusterScalingSchedulesGetter has a method to return a ClusterScalingScheduleInterface.
|
||||
@ -40,6 +39,7 @@ type ClusterScalingSchedulesGetter interface {
|
||||
type ClusterScalingScheduleInterface interface {
|
||||
Create(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.CreateOptions) (*v1.ClusterScalingSchedule, error)
|
||||
Update(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.UpdateOptions) (*v1.ClusterScalingSchedule, error)
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
UpdateStatus(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.UpdateOptions) (*v1.ClusterScalingSchedule, error)
|
||||
Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
|
||||
DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
@ -52,133 +52,18 @@ type ClusterScalingScheduleInterface interface {
|
||||
|
||||
// clusterScalingSchedules implements ClusterScalingScheduleInterface
|
||||
type clusterScalingSchedules struct {
|
||||
client rest.Interface
|
||||
*gentype.ClientWithList[*v1.ClusterScalingSchedule, *v1.ClusterScalingScheduleList]
|
||||
}
|
||||
|
||||
// newClusterScalingSchedules returns a ClusterScalingSchedules
|
||||
func newClusterScalingSchedules(c *ZalandoV1Client) *clusterScalingSchedules {
|
||||
return &clusterScalingSchedules{
|
||||
client: c.RESTClient(),
|
||||
gentype.NewClientWithList[*v1.ClusterScalingSchedule, *v1.ClusterScalingScheduleList](
|
||||
"clusterscalingschedules",
|
||||
c.RESTClient(),
|
||||
scheme.ParameterCodec,
|
||||
"",
|
||||
func() *v1.ClusterScalingSchedule { return &v1.ClusterScalingSchedule{} },
|
||||
func() *v1.ClusterScalingScheduleList { return &v1.ClusterScalingScheduleList{} }),
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the clusterScalingSchedule, and returns the corresponding clusterScalingSchedule object, and an error if there is any.
|
||||
func (c *clusterScalingSchedules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ClusterScalingSchedule, err error) {
|
||||
result = &v1.ClusterScalingSchedule{}
|
||||
err = c.client.Get().
|
||||
Resource("clusterscalingschedules").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ClusterScalingSchedules that match those selectors.
|
||||
func (c *clusterScalingSchedules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterScalingScheduleList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1.ClusterScalingScheduleList{}
|
||||
err = c.client.Get().
|
||||
Resource("clusterscalingschedules").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested clusterScalingSchedules.
|
||||
func (c *clusterScalingSchedules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Resource("clusterscalingschedules").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch(ctx)
|
||||
}
|
||||
|
||||
// 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 *clusterScalingSchedules) Create(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.CreateOptions) (result *v1.ClusterScalingSchedule, err error) {
|
||||
result = &v1.ClusterScalingSchedule{}
|
||||
err = c.client.Post().
|
||||
Resource("clusterscalingschedules").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(clusterScalingSchedule).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// 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 *clusterScalingSchedules) Update(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.UpdateOptions) (result *v1.ClusterScalingSchedule, err error) {
|
||||
result = &v1.ClusterScalingSchedule{}
|
||||
err = c.client.Put().
|
||||
Resource("clusterscalingschedules").
|
||||
Name(clusterScalingSchedule.Name).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(clusterScalingSchedule).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
func (c *clusterScalingSchedules) UpdateStatus(ctx context.Context, clusterScalingSchedule *v1.ClusterScalingSchedule, opts metav1.UpdateOptions) (result *v1.ClusterScalingSchedule, err error) {
|
||||
result = &v1.ClusterScalingSchedule{}
|
||||
err = c.client.Put().
|
||||
Resource("clusterscalingschedules").
|
||||
Name(clusterScalingSchedule.Name).
|
||||
SubResource("status").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(clusterScalingSchedule).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the clusterScalingSchedule and deletes it. Returns an error if one occurs.
|
||||
func (c *clusterScalingSchedules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Resource("clusterscalingschedules").
|
||||
Name(name).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *clusterScalingSchedules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOpts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Resource("clusterscalingschedules").
|
||||
VersionedParams(&listOpts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched clusterScalingSchedule.
|
||||
func (c *clusterScalingSchedules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterScalingSchedule, err error) {
|
||||
result = &v1.ClusterScalingSchedule{}
|
||||
err = c.client.Patch(pt).
|
||||
Resource("clusterscalingschedules").
|
||||
Name(name).
|
||||
SubResource(subresources...).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
@ -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,34 +34,36 @@ 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) {
|
||||
emptyResult := &v1.ClusterScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootGetAction(clusterscalingschedulesResource, name), &zalandoorgv1.ClusterScalingSchedule{})
|
||||
Invokes(testing.NewRootGetActionWithOptions(clusterscalingschedulesResource, name, options), emptyResult)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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) {
|
||||
emptyResult := &v1.ClusterScalingScheduleList{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootListAction(clusterscalingschedulesResource, clusterscalingschedulesKind, opts), &zalandoorgv1.ClusterScalingScheduleList{})
|
||||
Invokes(testing.NewRootListActionWithOptions(clusterscalingschedulesResource, clusterscalingschedulesKind, opts), emptyResult)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
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 +72,67 @@ 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))
|
||||
InvokesWatch(testing.NewRootWatchActionWithOptions(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) {
|
||||
emptyResult := &v1.ClusterScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootCreateAction(clusterscalingschedulesResource, clusterScalingSchedule), &zalandoorgv1.ClusterScalingSchedule{})
|
||||
Invokes(testing.NewRootCreateActionWithOptions(clusterscalingschedulesResource, clusterScalingSchedule, opts), emptyResult)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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) {
|
||||
emptyResult := &v1.ClusterScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateAction(clusterscalingschedulesResource, clusterScalingSchedule), &zalandoorgv1.ClusterScalingSchedule{})
|
||||
Invokes(testing.NewRootUpdateActionWithOptions(clusterscalingschedulesResource, clusterScalingSchedule, opts), emptyResult)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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) (result *v1.ClusterScalingSchedule, err error) {
|
||||
emptyResult := &v1.ClusterScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootUpdateSubresourceAction(clusterscalingschedulesResource, "status", clusterScalingSchedule), &zalandoorgv1.ClusterScalingSchedule{})
|
||||
Invokes(testing.NewRootUpdateSubresourceActionWithOptions(clusterscalingschedulesResource, "status", clusterScalingSchedule, opts), emptyResult)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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 {
|
||||
action := testing.NewRootDeleteCollectionAction(clusterscalingschedulesResource, listOpts)
|
||||
func (c *FakeClusterScalingSchedules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
action := testing.NewRootDeleteCollectionActionWithOptions(clusterscalingschedulesResource, opts, 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) {
|
||||
emptyResult := &v1.ClusterScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewRootPatchSubresourceAction(clusterscalingschedulesResource, name, pt, data, subresources...), &zalandoorgv1.ClusterScalingSchedule{})
|
||||
Invokes(testing.NewRootPatchSubresourceActionWithOptions(clusterscalingschedulesResource, name, pt, data, opts, subresources...), emptyResult)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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,36 +35,38 @@ 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) {
|
||||
emptyResult := &v1.ScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(scalingschedulesResource, c.ns, name), &zalandoorgv1.ScalingSchedule{})
|
||||
Invokes(testing.NewGetActionWithOptions(scalingschedulesResource, c.ns, name, options), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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) {
|
||||
emptyResult := &v1.ScalingScheduleList{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(scalingschedulesResource, scalingschedulesKind, c.ns, opts), &zalandoorgv1.ScalingScheduleList{})
|
||||
Invokes(testing.NewListActionWithOptions(scalingschedulesResource, scalingschedulesKind, c.ns, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
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 +75,73 @@ 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))
|
||||
InvokesWatch(testing.NewWatchActionWithOptions(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) {
|
||||
emptyResult := &v1.ScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(scalingschedulesResource, c.ns, scalingSchedule), &zalandoorgv1.ScalingSchedule{})
|
||||
Invokes(testing.NewCreateActionWithOptions(scalingschedulesResource, c.ns, scalingSchedule, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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) {
|
||||
emptyResult := &v1.ScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(scalingschedulesResource, c.ns, scalingSchedule), &zalandoorgv1.ScalingSchedule{})
|
||||
Invokes(testing.NewUpdateActionWithOptions(scalingschedulesResource, c.ns, scalingSchedule, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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) (result *v1.ScalingSchedule, err error) {
|
||||
emptyResult := &v1.ScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateSubresourceAction(scalingschedulesResource, "status", c.ns, scalingSchedule), &zalandoorgv1.ScalingSchedule{})
|
||||
Invokes(testing.NewUpdateSubresourceActionWithOptions(scalingschedulesResource, "status", c.ns, scalingSchedule, opts), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, 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 {
|
||||
action := testing.NewDeleteCollectionAction(scalingschedulesResource, c.ns, listOpts)
|
||||
func (c *FakeScalingSchedules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionActionWithOptions(scalingschedulesResource, c.ns, opts, 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) {
|
||||
emptyResult := &v1.ScalingSchedule{}
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(scalingschedulesResource, c.ns, name, pt, data, subresources...), &zalandoorgv1.ScalingSchedule{})
|
||||
Invokes(testing.NewPatchSubresourceActionWithOptions(scalingschedulesResource, c.ns, name, pt, data, opts, subresources...), emptyResult)
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
return emptyResult, err
|
||||
}
|
||||
return obj.(*zalandoorgv1.ScalingSchedule), err
|
||||
return obj.(*v1.ScalingSchedule), err
|
||||
}
|
||||
|
@ -20,14 +20,13 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
scheme "github.com/zalando-incubator/kube-metrics-adapter/pkg/client/clientset/versioned/scheme"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
)
|
||||
|
||||
// ScalingSchedulesGetter has a method to return a ScalingScheduleInterface.
|
||||
@ -40,6 +39,7 @@ type ScalingSchedulesGetter interface {
|
||||
type ScalingScheduleInterface interface {
|
||||
Create(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.CreateOptions) (*v1.ScalingSchedule, error)
|
||||
Update(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.UpdateOptions) (*v1.ScalingSchedule, error)
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
UpdateStatus(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.UpdateOptions) (*v1.ScalingSchedule, error)
|
||||
Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
|
||||
DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
@ -52,144 +52,18 @@ type ScalingScheduleInterface interface {
|
||||
|
||||
// scalingSchedules implements ScalingScheduleInterface
|
||||
type scalingSchedules struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
*gentype.ClientWithList[*v1.ScalingSchedule, *v1.ScalingScheduleList]
|
||||
}
|
||||
|
||||
// newScalingSchedules returns a ScalingSchedules
|
||||
func newScalingSchedules(c *ZalandoV1Client, namespace string) *scalingSchedules {
|
||||
return &scalingSchedules{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
gentype.NewClientWithList[*v1.ScalingSchedule, *v1.ScalingScheduleList](
|
||||
"scalingschedules",
|
||||
c.RESTClient(),
|
||||
scheme.ParameterCodec,
|
||||
namespace,
|
||||
func() *v1.ScalingSchedule { return &v1.ScalingSchedule{} },
|
||||
func() *v1.ScalingScheduleList { return &v1.ScalingScheduleList{} }),
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the scalingSchedule, and returns the corresponding scalingSchedule object, and an error if there is any.
|
||||
func (c *scalingSchedules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ScalingSchedule, err error) {
|
||||
result = &v1.ScalingSchedule{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ScalingSchedules that match those selectors.
|
||||
func (c *scalingSchedules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ScalingScheduleList, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = &v1.ScalingScheduleList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested scalingSchedules.
|
||||
func (c *scalingSchedules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Watch(ctx)
|
||||
}
|
||||
|
||||
// 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 *scalingSchedules) Create(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.CreateOptions) (result *v1.ScalingSchedule, err error) {
|
||||
result = &v1.ScalingSchedule{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(scalingSchedule).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// 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 *scalingSchedules) Update(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.UpdateOptions) (result *v1.ScalingSchedule, err error) {
|
||||
result = &v1.ScalingSchedule{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
Name(scalingSchedule.Name).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(scalingSchedule).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStatus was generated because the type contains a Status member.
|
||||
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
|
||||
func (c *scalingSchedules) UpdateStatus(ctx context.Context, scalingSchedule *v1.ScalingSchedule, opts metav1.UpdateOptions) (result *v1.ScalingSchedule, err error) {
|
||||
result = &v1.ScalingSchedule{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
Name(scalingSchedule.Name).
|
||||
SubResource("status").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(scalingSchedule).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the scalingSchedule and deletes it. Returns an error if one occurs.
|
||||
func (c *scalingSchedules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
Name(name).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *scalingSchedules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
var timeout time.Duration
|
||||
if listOpts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
VersionedParams(&listOpts, scheme.ParameterCodec).
|
||||
Timeout(timeout).
|
||||
Body(&opts).
|
||||
Do(ctx).
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched scalingSchedule.
|
||||
func (c *scalingSchedules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ScalingSchedule, err error) {
|
||||
result = &v1.ScalingSchedule{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("scalingschedules").
|
||||
Name(name).
|
||||
SubResource(subresources...).
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Body(data).
|
||||
Do(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
@ -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,59 @@ 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.
|
||||
// Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync.
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@ package v1
|
||||
|
||||
import (
|
||||
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/listers"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
@ -39,30 +39,10 @@ type ClusterScalingScheduleLister interface {
|
||||
|
||||
// clusterScalingScheduleLister implements the ClusterScalingScheduleLister interface.
|
||||
type clusterScalingScheduleLister struct {
|
||||
indexer cache.Indexer
|
||||
listers.ResourceIndexer[*v1.ClusterScalingSchedule]
|
||||
}
|
||||
|
||||
// NewClusterScalingScheduleLister returns a new ClusterScalingScheduleLister.
|
||||
func NewClusterScalingScheduleLister(indexer cache.Indexer) ClusterScalingScheduleLister {
|
||||
return &clusterScalingScheduleLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all ClusterScalingSchedules in the indexer.
|
||||
func (s *clusterScalingScheduleLister) List(selector labels.Selector) (ret []*v1.ClusterScalingSchedule, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1.ClusterScalingSchedule))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the ClusterScalingSchedule from the index for a given name.
|
||||
func (s *clusterScalingScheduleLister) Get(name string) (*v1.ClusterScalingSchedule, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1.Resource("clusterscalingschedule"), name)
|
||||
}
|
||||
return obj.(*v1.ClusterScalingSchedule), nil
|
||||
return &clusterScalingScheduleLister{listers.New[*v1.ClusterScalingSchedule](indexer, v1.Resource("clusterscalingschedule"))}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ package v1
|
||||
|
||||
import (
|
||||
v1 "github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/listers"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
@ -38,25 +38,17 @@ type ScalingScheduleLister interface {
|
||||
|
||||
// scalingScheduleLister implements the ScalingScheduleLister interface.
|
||||
type scalingScheduleLister struct {
|
||||
indexer cache.Indexer
|
||||
listers.ResourceIndexer[*v1.ScalingSchedule]
|
||||
}
|
||||
|
||||
// NewScalingScheduleLister returns a new ScalingScheduleLister.
|
||||
func NewScalingScheduleLister(indexer cache.Indexer) ScalingScheduleLister {
|
||||
return &scalingScheduleLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all ScalingSchedules in the indexer.
|
||||
func (s *scalingScheduleLister) List(selector labels.Selector) (ret []*v1.ScalingSchedule, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1.ScalingSchedule))
|
||||
})
|
||||
return ret, err
|
||||
return &scalingScheduleLister{listers.New[*v1.ScalingSchedule](indexer, v1.Resource("scalingschedule"))}
|
||||
}
|
||||
|
||||
// ScalingSchedules returns an object that can list and get ScalingSchedules.
|
||||
func (s *scalingScheduleLister) ScalingSchedules(namespace string) ScalingScheduleNamespaceLister {
|
||||
return scalingScheduleNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
return scalingScheduleNamespaceLister{listers.NewNamespaced[*v1.ScalingSchedule](s.ResourceIndexer, namespace)}
|
||||
}
|
||||
|
||||
// ScalingScheduleNamespaceLister helps list and get ScalingSchedules.
|
||||
@ -74,26 +66,5 @@ type ScalingScheduleNamespaceLister interface {
|
||||
// scalingScheduleNamespaceLister implements the ScalingScheduleNamespaceLister
|
||||
// interface.
|
||||
type scalingScheduleNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all ScalingSchedules in the indexer for a given namespace.
|
||||
func (s scalingScheduleNamespaceLister) List(selector labels.Selector) (ret []*v1.ScalingSchedule, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1.ScalingSchedule))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the ScalingSchedule from the indexer for a given namespace and name.
|
||||
func (s scalingScheduleNamespaceLister) Get(name string) (*v1.ScalingSchedule, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1.Resource("scalingschedule"), name)
|
||||
}
|
||||
return obj.(*v1.ScalingSchedule), nil
|
||||
listers.ResourceIndexer[*v1.ScalingSchedule]
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user