mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2025-01-09 09:51:38 +00:00
Compare commits
102 Commits
automate/r
...
v0.1.14
Author | SHA1 | Date | |
---|---|---|---|
|
0730c6ef1e | ||
|
c5411c74b7 | ||
|
4ba6b66441 | ||
|
0dbe769e1b | ||
|
582a78d4ec | ||
|
481df883e5 | ||
|
318d47e05e | ||
|
190f0db092 | ||
|
c618494177 | ||
|
a08860d06c | ||
|
6b0afe5180 | ||
|
9722e38f62 | ||
|
35aa03c771 | ||
|
34c833e04a | ||
|
c93c1dd7bb | ||
|
59d39bc51c | ||
|
4066e450e5 | ||
|
8415373f3d | ||
|
d1969a3020 | ||
|
582c94255f | ||
|
c626f414db | ||
|
1d4beab7a4 | ||
|
eefd5ef512 | ||
|
599b3bf805 | ||
|
ecf21df9c0 | ||
|
ecd296e644 | ||
|
446b7f01ea | ||
|
0ad7296d56 | ||
|
9da155554b | ||
|
d7f9664d52 | ||
|
85f6dda229 | ||
|
64a6b85c73 | ||
|
f41af0d82b | ||
|
194bede7a3 | ||
|
c4f5efb6a7 | ||
|
51e9378ee6 | ||
|
ce27ef1798 | ||
|
a73ef467cd | ||
|
e6a04531fb | ||
|
7289e6f8e2 | ||
|
60b1dc097a | ||
|
6b46cc2599 | ||
|
6f9aba8db8 | ||
|
a382dbfe7b | ||
|
7a68304389 | ||
|
7044e79b08 | ||
|
e16bacb24e | ||
|
726c1e691d | ||
|
debc90ca72 | ||
|
6343c8ea15 | ||
|
eb0575f11e | ||
|
52bfbbb1b0 | ||
|
cf5872ef08 | ||
|
b5432fb1f3 | ||
|
5466badd90 | ||
|
aef1837e47 | ||
|
4e86d6ae34 | ||
|
2874c1a6a7 | ||
|
b5006746f0 | ||
|
9496ab7fd3 | ||
|
aa7f86291e | ||
|
486a6c4262 | ||
|
aaf66f31a0 | ||
|
e5bee93bf6 | ||
|
aae3772472 | ||
|
76d3726e5b | ||
|
ea4a651afe | ||
|
721c6553d8 | ||
|
5aa2272e37 | ||
|
b9300d1e46 | ||
|
5747b6c9de | ||
|
6d15a1635a | ||
|
4090ab8b32 | ||
|
1f56abf931 | ||
|
f216070630 | ||
|
8725f02db7 | ||
|
240452ca27 | ||
|
45d7863e73 | ||
|
87f249d36b | ||
|
9967a55df8 | ||
|
adf0792079 | ||
|
99fa5c42ed | ||
|
188cc91574 | ||
|
a8ff0ed6f0 | ||
|
cc9279b283 | ||
|
9bb7d976a0 | ||
|
816661f7fd | ||
|
7ae70d798d | ||
|
0ef5ad1cfe | ||
|
c86235636b | ||
|
2d119e68e4 | ||
|
df3efe0e39 | ||
|
a5b5cb91c3 | ||
|
ebcf99ad27 | ||
|
3d450ad2c2 | ||
|
78a9b5c253 | ||
|
4e2b9d9788 | ||
|
38aeb4deed | ||
|
b7aa886546 | ||
|
942e753f87 | ||
|
86ed6ec102 | ||
|
b313c963b6 |
25
.github/workflows/ci.yaml
vendored
Normal file
25
.github/workflows/ci.yaml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: ci
|
||||
on: [push, pull_request]
|
||||
env:
|
||||
GO111MODULE: on
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.16'
|
||||
- run: go version
|
||||
- run: go get github.com/mattn/goveralls
|
||||
env:
|
||||
GO111MODULE: off
|
||||
- run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_RELEASE}
|
||||
env:
|
||||
GOLANGCI_RELEASE: v1.37.0
|
||||
- run: make build.docker
|
||||
- run: make test
|
||||
- run: make check
|
||||
- run: goveralls -coverprofile=profile.cov -service=github
|
||||
env:
|
||||
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
build/
|
||||
apiserver.local.config/
|
||||
.idea/
|
||||
profile.cov
|
||||
vendor/
|
||||
|
20
.travis.yml
20
.travis.yml
@ -1,20 +0,0 @@
|
||||
language: go
|
||||
dist: xenial
|
||||
|
||||
go:
|
||||
- "1.14.x"
|
||||
|
||||
env:
|
||||
- GO111MODULE=on GOLANGCI_RELEASE="v1.21.0"
|
||||
|
||||
before_install:
|
||||
- GO111MODULE=off go get github.com/mattn/goveralls
|
||||
- GO111MODULE=off go get github.com/lawrencewoodman/roveralls
|
||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_RELEASE}
|
||||
|
||||
script:
|
||||
- make test
|
||||
- make build.docker
|
||||
- make check
|
||||
- roveralls
|
||||
- goveralls -v -coverprofile=roveralls.coverprofile -service=travis-ci
|
@ -1,6 +1,8 @@
|
||||
FROM registry.opensource.zalan.do/library/alpine-3.12:latest
|
||||
LABEL maintainer="Team Teapot @ Zalando SE <team-teapot@zalando.de>"
|
||||
|
||||
RUN apk add --no-cache tzdata
|
||||
|
||||
# add binary
|
||||
ADD build/linux/kube-metrics-adapter /
|
||||
|
||||
|
26
Makefile
26
Makefile
@ -10,6 +10,10 @@ GOPKGS = $(shell go list ./...)
|
||||
BUILD_FLAGS ?= -v
|
||||
OPENAPI ?= pkg/api/generated/openapi/zz_generated.openapi.go
|
||||
LDFLAGS ?= -X main.version=$(VERSION) -w -s
|
||||
CRD_SOURCES = $(shell find pkg/apis/zalando.org -name '*.go')
|
||||
CRD_TYPE_SOURCE = pkg/apis/zalando.org/v1/types.go
|
||||
GENERATED_CRDS = docs/scaling_schedules_crd.yaml
|
||||
GENERATED = pkg/apis/zalando.org/v1/zz_generated.deepcopy.go
|
||||
|
||||
|
||||
default: build.local
|
||||
@ -18,14 +22,22 @@ clean:
|
||||
rm -rf build
|
||||
rm -rf $(OPENAPI)
|
||||
|
||||
test:
|
||||
go test -v $(GOPKGS)
|
||||
test: $(GENERATED)
|
||||
go test -v -coverprofile=profile.cov $(GOPKGS)
|
||||
|
||||
check:
|
||||
check: $(GENERATED)
|
||||
go mod download
|
||||
golangci-lint run --timeout=2m ./...
|
||||
|
||||
|
||||
$(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
|
||||
mv docs/zalando.org_clusterscalingschedules.yaml docs/cluster_scaling_schedules_crd.yaml
|
||||
mv docs/zalando.org_scalingschedules.yaml docs/scaling_schedules_crd.yaml
|
||||
|
||||
$(OPENAPI): go.mod
|
||||
go run k8s.io/kube-openapi/cmd/openapi-gen \
|
||||
--go-header-file hack/boilerplate.go.txt \
|
||||
@ -36,17 +48,17 @@ $(OPENAPI): go.mod
|
||||
-O zz_generated.openapi \
|
||||
-r /dev/null
|
||||
|
||||
build.local: build/$(BINARY)
|
||||
build.local: build/$(BINARY) $(GENERATED_CRDS)
|
||||
build.linux: build/linux/$(BINARY)
|
||||
build.osx: build/osx/$(BINARY)
|
||||
|
||||
build/$(BINARY): go.mod $(SOURCES) $(OPENAPI)
|
||||
build/$(BINARY): go.mod $(SOURCES) $(GENERATED)
|
||||
CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
|
||||
|
||||
build/linux/$(BINARY): go.mod $(SOURCES) $(OPENAPI)
|
||||
build/linux/$(BINARY): go.mod $(SOURCES) $(GENERATED)
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" .
|
||||
|
||||
build/osx/$(BINARY): go.mod $(SOURCES) $(OPENAPI)
|
||||
build/osx/$(BINARY): go.mod $(SOURCES) $(GENERATED)
|
||||
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" .
|
||||
|
||||
build.docker: build.linux
|
||||
|
125
docs/cluster_scaling_schedules_crd.yaml
Normal file
125
docs/cluster_scaling_schedules_crd.yaml
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.5.0
|
||||
creationTimestamp: null
|
||||
name: clusterscalingschedules.zalando.org
|
||||
spec:
|
||||
group: zalando.org
|
||||
names:
|
||||
kind: ClusterScalingSchedule
|
||||
listKind: ClusterScalingScheduleList
|
||||
plural: clusterscalingschedules
|
||||
singular: clusterscalingschedule
|
||||
scope: Cluster
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
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'
|
||||
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'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
|
||||
properties:
|
||||
scalingWindowDurationMinutes:
|
||||
description: Fade the scheduled values in and out over this many minutes.
|
||||
If unset, the default per-cluster value will be used.
|
||||
format: int64
|
||||
type: integer
|
||||
schedules:
|
||||
description: Schedules is the list of schedules for this ScalingSchedule
|
||||
resource. All the schedules defined here will result on the value
|
||||
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 formated date.
|
||||
format: date-time
|
||||
type: string
|
||||
durationMinutes:
|
||||
description: The duration in minutes that the configured value
|
||||
will be returned for the defined schedule.
|
||||
type: integer
|
||||
period:
|
||||
description: Defines the details of a Repeating schedule.
|
||||
properties:
|
||||
days:
|
||||
description: The days that this schedule will be active.
|
||||
items:
|
||||
description: ScheduleDay represents the valid inputs for
|
||||
days in a SchedulePeriod.
|
||||
enum:
|
||||
- Sun
|
||||
- Mon
|
||||
- Tue
|
||||
- Wed
|
||||
- Thu
|
||||
- Fri
|
||||
- Sat
|
||||
type: string
|
||||
type: array
|
||||
startTime:
|
||||
description: The startTime has the format HH:MM
|
||||
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.
|
||||
type: string
|
||||
required:
|
||||
- days
|
||||
- startTime
|
||||
- timezone
|
||||
type: object
|
||||
type:
|
||||
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:
|
||||
- OneTime
|
||||
- Repeating
|
||||
type: string
|
||||
value:
|
||||
description: The metric value that will be returned for the
|
||||
defined schedule.
|
||||
format: int64
|
||||
type: integer
|
||||
required:
|
||||
- durationMinutes
|
||||
- type
|
||||
- value
|
||||
type: object
|
||||
type: array
|
||||
required:
|
||||
- schedules
|
||||
type: object
|
||||
required:
|
||||
- spec
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
@ -1,4 +1,4 @@
|
||||
apiVersion: apiregistration.k8s.io/v1beta1
|
||||
apiVersion: apiregistration.k8s.io/v1
|
||||
kind: APIService
|
||||
metadata:
|
||||
name: v1beta1.custom.metrics.k8s.io
|
||||
|
@ -28,6 +28,7 @@ spec:
|
||||
- --prometheus-server=http://prometheus.kube-system.svc.cluster.local
|
||||
- --skipper-ingress-metrics
|
||||
- --aws-external-metrics
|
||||
- --scaling-schedule
|
||||
env:
|
||||
- name: AWS_REGION
|
||||
value: eu-central-1
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: apiregistration.k8s.io/v1beta1
|
||||
apiVersion: apiregistration.k8s.io/v1
|
||||
kind: APIService
|
||||
metadata:
|
||||
name: v1beta1.external.metrics.k8s.io
|
||||
|
@ -1,6 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: kube-metrics-adapter
|
||||
version: 0.1.9
|
||||
version: 0.1.11
|
||||
description: kube-metrics-adapter helm chart
|
||||
home: https://github.com/zalando-incubator/kube-metrics-adapter
|
||||
maintainers:
|
||||
|
119
docs/helm/templates/cluster_scaling_schedules_crd.yaml
Normal file
119
docs/helm/templates/cluster_scaling_schedules_crd.yaml
Normal file
@ -0,0 +1,119 @@
|
||||
{{- if .Values.scalingSchedule.enabled }}
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.5.0
|
||||
creationTimestamp: null
|
||||
name: clusterscalingschedules.zalando.org
|
||||
spec:
|
||||
group: zalando.org
|
||||
names:
|
||||
kind: ClusterScalingSchedule
|
||||
listKind: ClusterScalingScheduleList
|
||||
plural: clusterscalingschedules
|
||||
singular: clusterscalingschedule
|
||||
scope: Cluster
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
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'
|
||||
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'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
|
||||
properties:
|
||||
schedules:
|
||||
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.
|
||||
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 formated date.
|
||||
format: date-time
|
||||
type: string
|
||||
durationMinutes:
|
||||
description: The duration in minutes that the configured value
|
||||
will be returned for the defined schedule.
|
||||
type: integer
|
||||
period:
|
||||
description: Defines the details of a Repeating schedule.
|
||||
properties:
|
||||
days:
|
||||
description: The days that this schedule will be active.
|
||||
items:
|
||||
description: ScheduleDay represents the valid inputs for
|
||||
days in a SchedulePeriod.
|
||||
enum:
|
||||
- Sun
|
||||
- Mon
|
||||
- Tue
|
||||
- Wed
|
||||
- Thu
|
||||
- Fri
|
||||
- Sat
|
||||
type: string
|
||||
type: array
|
||||
startTime:
|
||||
description: The startTime has the format HH:MM
|
||||
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.
|
||||
type: string
|
||||
required:
|
||||
- days
|
||||
- startTime
|
||||
- timezone
|
||||
type: object
|
||||
type:
|
||||
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:
|
||||
- OneTime
|
||||
- Repeating
|
||||
type: string
|
||||
value:
|
||||
description: The metric value that will be returned for the
|
||||
defined schedule.
|
||||
type: integer
|
||||
required:
|
||||
- durationMinutes
|
||||
- type
|
||||
- value
|
||||
type: object
|
||||
type: array
|
||||
required:
|
||||
- schedules
|
||||
type: object
|
||||
required:
|
||||
- spec
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
||||
{{- end}}
|
@ -1,5 +1,5 @@
|
||||
{{- if .Values.enableCustomMetricsApi }}
|
||||
apiVersion: apiregistration.k8s.io/v1beta1
|
||||
apiVersion: apiregistration.k8s.io/v1
|
||||
kind: APIService
|
||||
metadata:
|
||||
name: v1beta1.custom.metrics.k8s.io
|
||||
@ -12,4 +12,4 @@ spec:
|
||||
insecureSkipTLSVerify: {{ .Values.tls.skipTLSVerify }}
|
||||
groupPriorityMinimum: 100
|
||||
versionPriority: 100
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
|
@ -182,6 +182,9 @@ spec:
|
||||
{{- if .Values.zmon.tokenName }}
|
||||
- --zmon-token-name={{ .Values.zmon.tokenName }}
|
||||
{{- end}}
|
||||
{{- if .Values.scalingSchedule.enabled }}
|
||||
- --scaling-schedule
|
||||
{{- end}}
|
||||
resources:
|
||||
limits:
|
||||
cpu: {{ .Values.resources.limits.cpu }}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{- if .Values.enableExternalMetricsApi }}
|
||||
apiVersion: apiregistration.k8s.io/v1beta1
|
||||
apiVersion: apiregistration.k8s.io/v1
|
||||
kind: APIService
|
||||
metadata:
|
||||
name: v1beta1.external.metrics.k8s.io
|
||||
|
@ -73,6 +73,17 @@ rules:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
{{- if .Values.scalingSchedule.enabled }}
|
||||
- apiGroups:
|
||||
- zalando.org
|
||||
resources:
|
||||
- clusterscalingschedules
|
||||
- scalingschedules
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
{{- end}}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
|
119
docs/helm/templates/scaling_schedules_crd.yaml
Normal file
119
docs/helm/templates/scaling_schedules_crd.yaml
Normal file
@ -0,0 +1,119 @@
|
||||
{{- if .Values.scalingSchedule.enabled }}
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.5.0
|
||||
creationTimestamp: null
|
||||
name: scalingschedules.zalando.org
|
||||
spec:
|
||||
group: zalando.org
|
||||
names:
|
||||
kind: ScalingSchedule
|
||||
listKind: ScalingScheduleList
|
||||
plural: scalingschedules
|
||||
singular: scalingschedule
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
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'
|
||||
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'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
|
||||
properties:
|
||||
schedules:
|
||||
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.
|
||||
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 formated date.
|
||||
format: date-time
|
||||
type: string
|
||||
durationMinutes:
|
||||
description: The duration in minutes that the configured value
|
||||
will be returned for the defined schedule.
|
||||
type: integer
|
||||
period:
|
||||
description: Defines the details of a Repeating schedule.
|
||||
properties:
|
||||
days:
|
||||
description: The days that this schedule will be active.
|
||||
items:
|
||||
description: ScheduleDay represents the valid inputs for
|
||||
days in a SchedulePeriod.
|
||||
enum:
|
||||
- Sun
|
||||
- Mon
|
||||
- Tue
|
||||
- Wed
|
||||
- Thu
|
||||
- Fri
|
||||
- Sat
|
||||
type: string
|
||||
type: array
|
||||
startTime:
|
||||
description: The startTime has the format HH:MM
|
||||
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.
|
||||
type: string
|
||||
required:
|
||||
- days
|
||||
- startTime
|
||||
- timezone
|
||||
type: object
|
||||
type:
|
||||
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:
|
||||
- OneTime
|
||||
- Repeating
|
||||
type: string
|
||||
value:
|
||||
description: The metric value that will be returned for the
|
||||
defined schedule.
|
||||
type: integer
|
||||
required:
|
||||
- durationMinutes
|
||||
- type
|
||||
- value
|
||||
type: object
|
||||
type: array
|
||||
required:
|
||||
- schedules
|
||||
type: object
|
||||
required:
|
||||
- spec
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
||||
{{- end}}
|
@ -4,7 +4,7 @@ replicas: 1
|
||||
|
||||
registry:
|
||||
image: registry.opensource.zalan.do/teapot/kube-metrics-adapter
|
||||
imageTag: v0.1.9
|
||||
imageTag: v0.1.10
|
||||
imagePullPolicy: IfNotPresent
|
||||
|
||||
service:
|
||||
@ -92,3 +92,6 @@ resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
|
||||
scalingSchedule:
|
||||
enabled: false
|
||||
|
@ -64,12 +64,23 @@ rules:
|
||||
- statefulsets
|
||||
verbs:
|
||||
- get
|
||||
# only relevant if running with the flag:
|
||||
# --skipper-ingress-metrics
|
||||
- apiGroups:
|
||||
- extensions
|
||||
- networking.k8s.io
|
||||
resources:
|
||||
- ingresses
|
||||
verbs:
|
||||
- get
|
||||
# only relevant if running with the flag:
|
||||
# --skipper-routegroup-metrics
|
||||
- apiGroups:
|
||||
- zalando.org
|
||||
resources:
|
||||
- routegroups
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- autoscaling
|
||||
resources:
|
||||
@ -78,6 +89,15 @@ rules:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- zalando.org
|
||||
resources:
|
||||
- clusterscalingschedules
|
||||
- scalingschedules
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
|
125
docs/scaling_schedules_crd.yaml
Normal file
125
docs/scaling_schedules_crd.yaml
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
controller-gen.kubebuilder.io/version: v0.5.0
|
||||
creationTimestamp: null
|
||||
name: scalingschedules.zalando.org
|
||||
spec:
|
||||
group: zalando.org
|
||||
names:
|
||||
kind: ScalingSchedule
|
||||
listKind: ScalingScheduleList
|
||||
plural: scalingschedules
|
||||
singular: scalingschedule
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
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'
|
||||
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'
|
||||
type: string
|
||||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: ScalingScheduleSpec is the spec part of the ScalingSchedule.
|
||||
properties:
|
||||
scalingWindowDurationMinutes:
|
||||
description: Fade the scheduled values in and out over this many minutes.
|
||||
If unset, the default per-cluster value will be used.
|
||||
format: int64
|
||||
type: integer
|
||||
schedules:
|
||||
description: Schedules is the list of schedules for this ScalingSchedule
|
||||
resource. All the schedules defined here will result on the value
|
||||
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 formated date.
|
||||
format: date-time
|
||||
type: string
|
||||
durationMinutes:
|
||||
description: The duration in minutes that the configured value
|
||||
will be returned for the defined schedule.
|
||||
type: integer
|
||||
period:
|
||||
description: Defines the details of a Repeating schedule.
|
||||
properties:
|
||||
days:
|
||||
description: The days that this schedule will be active.
|
||||
items:
|
||||
description: ScheduleDay represents the valid inputs for
|
||||
days in a SchedulePeriod.
|
||||
enum:
|
||||
- Sun
|
||||
- Mon
|
||||
- Tue
|
||||
- Wed
|
||||
- Thu
|
||||
- Fri
|
||||
- Sat
|
||||
type: string
|
||||
type: array
|
||||
startTime:
|
||||
description: The startTime has the format HH:MM
|
||||
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.
|
||||
type: string
|
||||
required:
|
||||
- days
|
||||
- startTime
|
||||
- timezone
|
||||
type: object
|
||||
type:
|
||||
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:
|
||||
- OneTime
|
||||
- Repeating
|
||||
type: string
|
||||
value:
|
||||
description: The metric value that will be returned for the
|
||||
defined schedule.
|
||||
format: int64
|
||||
type: integer
|
||||
required:
|
||||
- durationMinutes
|
||||
- type
|
||||
- value
|
||||
type: object
|
||||
type: array
|
||||
required:
|
||||
- schedules
|
||||
type: object
|
||||
required:
|
||||
- spec
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
status:
|
||||
acceptedNames:
|
||||
kind: ""
|
||||
plural: ""
|
||||
conditions: []
|
||||
storedVersions: []
|
47
go.mod
47
go.mod
@ -2,35 +2,34 @@ module github.com/zalando-incubator/kube-metrics-adapter
|
||||
|
||||
require (
|
||||
github.com/NYTimes/gziphandler v1.0.1 // indirect
|
||||
github.com/aws/aws-sdk-go v1.36.19
|
||||
github.com/go-openapi/spec v0.20.0
|
||||
github.com/googleapis/gnostic v0.2.0 // indirect
|
||||
github.com/aws/aws-sdk-go v1.40.22
|
||||
github.com/go-openapi/spec v0.20.3
|
||||
github.com/influxdata/influxdb-client-go v0.2.0
|
||||
github.com/influxdata/line-protocol v0.0.0-20201012155213-5f565037cbc9 // indirect
|
||||
github.com/kubernetes-incubator/custom-metrics-apiserver v0.0.0-20201023074945-51cc7b53320e
|
||||
github.com/mattn/go-colorable v0.1.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.10 // indirect
|
||||
github.com/onsi/gomega v1.8.1 // indirect
|
||||
github.com/prometheus/client_golang v1.9.0
|
||||
github.com/prometheus/common v0.15.0
|
||||
github.com/sirupsen/logrus v1.7.0
|
||||
github.com/spf13/cobra v0.0.7
|
||||
github.com/kubernetes-sigs/custom-metrics-apiserver v0.0.0-20201216091021-1b9fa998bbaa
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/prometheus/common v0.26.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/spf13/cobra v1.1.3
|
||||
github.com/spyzhov/ajson v0.4.2
|
||||
github.com/stretchr/testify v1.6.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/szuecs/routegroup-client v0.18.3
|
||||
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20180921141935-824b77fb1f84
|
||||
go.uber.org/zap v1.13.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||
golang.org/x/tools v0.0.0-20200204192400-7124308813f3 // indirect
|
||||
honnef.co/go/tools v0.0.1-2020.1.3 // indirect
|
||||
k8s.io/api v0.18.14
|
||||
k8s.io/apimachinery v0.18.14
|
||||
k8s.io/apiserver v0.18.14
|
||||
k8s.io/client-go v0.18.14
|
||||
k8s.io/component-base v0.18.14
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
k8s.io/api v0.20.9
|
||||
k8s.io/apimachinery v0.20.9
|
||||
k8s.io/apiserver v0.20.9
|
||||
k8s.io/client-go v0.20.9
|
||||
k8s.io/code-generator v0.20.9
|
||||
k8s.io/component-base v0.20.9
|
||||
k8s.io/klog v1.0.0
|
||||
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
|
||||
k8s.io/metrics v0.18.8
|
||||
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
|
||||
k8s.io/metrics v0.20.9
|
||||
sigs.k8s.io/controller-tools v0.5.0
|
||||
)
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
@ -1,6 +1,23 @@
|
||||
// +build tools
|
||||
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// This package imports things required by build scripts, to force `go mod` to see them as dependencies
|
||||
package tools
|
||||
|
||||
import _ "k8s.io/kube-openapi/cmd/openapi-gen"
|
||||
import (
|
||||
_ "k8s.io/code-generator"
|
||||
_ "k8s.io/kube-openapi/cmd/openapi-gen"
|
||||
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
|
||||
)
|
||||
|
74
hack/update-codegen.sh
Executable file
74
hack/update-codegen.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SRC="github.com"
|
||||
GOPKG="${SRC}/zalando-incubator/kube-metrics-adapter"
|
||||
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"
|
||||
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 \
|
||||
--bounding-dirs "${APIS_PKG}" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-base "$OUTPUT_BASE"
|
||||
|
||||
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" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-base "$OUTPUT_BASE"
|
||||
|
||||
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" \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||
--output-base "$OUTPUT_BASE"
|
||||
|
||||
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" \
|
||||
--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}"
|
@ -12,13 +12,15 @@ const (
|
||||
customMetricsPrefix = "metric-config."
|
||||
perReplicaMetricsConfKey = "per-replica"
|
||||
intervalMetricsConfKey = "interval"
|
||||
minPodReadyAgeConfKey = "min-pod-ready-age"
|
||||
)
|
||||
|
||||
type AnnotationConfigs struct {
|
||||
CollectorType string
|
||||
Configs map[string]string
|
||||
PerReplica bool
|
||||
Interval time.Duration
|
||||
CollectorType string
|
||||
Configs map[string]string
|
||||
PerReplica bool
|
||||
Interval time.Duration
|
||||
MinPodReadyAge time.Duration
|
||||
}
|
||||
|
||||
type MetricConfigKey struct {
|
||||
@ -89,6 +91,15 @@ func (m AnnotationConfigMap) Parse(annotations map[string]string) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if parts[1] == minPodReadyAgeConfKey {
|
||||
minPodReadyAge, err := time.ParseDuration(val)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse min-pod-ready-age value %s for %s: %v", val, key, err)
|
||||
}
|
||||
config.MinPodReadyAge = minPodReadyAge
|
||||
continue
|
||||
}
|
||||
|
||||
config.Configs[parts[1]] = val
|
||||
}
|
||||
return nil
|
||||
|
@ -24,10 +24,11 @@ func TestParser(t *testing.T) {
|
||||
{
|
||||
Name: "pod metrics",
|
||||
Annotations: map[string]string{
|
||||
"metric-config.pods.requests-per-second.json-path/json-key": "$.http_server.rps",
|
||||
"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",
|
||||
"metric-config.pods.requests-per-second.json-path/json-key": "$.http_server.rps",
|
||||
"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",
|
||||
"metric-config.pods.requests-per-second.json-path/min-pod-ready-age": "30s",
|
||||
},
|
||||
MetricName: "requests-per-second",
|
||||
MetricType: autoscalingv2.PodsMetricSourceType,
|
||||
|
File diff suppressed because it is too large
Load Diff
6
pkg/apis/zalando.org/register.go
Normal file
6
pkg/apis/zalando.org/register.go
Normal file
@ -0,0 +1,6 @@
|
||||
package zalando
|
||||
|
||||
const (
|
||||
// GroupName is the group name used in this package.
|
||||
GroupName = "zalando.org"
|
||||
)
|
38
pkg/apis/zalando.org/v1/register.go
Normal file
38
pkg/apis/zalando.org/v1/register.go
Normal file
@ -0,0 +1,38 @@
|
||||
// Package v1 contains API Schema definitions for the zalando v1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=zalando.org
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/zalando-incubator/kube-metrics-adapter/pkg/apis/zalando.org"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
// AddToScheme applies all the stored functions to the scheme. A non-nil error
|
||||
// indicates that one function failed and the attempt was abandoned.
|
||||
AddToScheme = schemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// SchemeGroupVersion is the group version used to register these objects.
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: zalando.GroupName, Version: "v1"}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&ScalingSchedule{},
|
||||
&ClusterScalingSchedule{},
|
||||
&ScalingScheduleList{},
|
||||
&ClusterScalingScheduleList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
139
pkg/apis/zalando.org/v1/types.go
Normal file
139
pkg/apis/zalando.org/v1/types.go
Normal file
@ -0,0 +1,139 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ScalingSchedule describes a namespaced time based metric to be used
|
||||
// in autoscaling operations.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ScalingSchedule struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ScalingScheduleSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ClusterScalingSchedule describes a cluster scoped time based metric
|
||||
// to be used in autoscaling operations.
|
||||
// +k8s:deepcopy-gen=true
|
||||
// +kubebuilder:resource:scope=Cluster
|
||||
type ClusterScalingSchedule struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ScalingScheduleSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// ScalingScheduleSpec is the spec part of the ScalingSchedule.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ScalingScheduleSpec struct {
|
||||
// Fade the scheduled values in and out over this many minutes. If unset, the default per-cluster value will be used.
|
||||
// +optional
|
||||
ScalingWindowDurationMinutes *int64 `json:"scalingWindowDurationMinutes,omitempty"`
|
||||
|
||||
// Schedules is the list of schedules for this ScalingSchedule
|
||||
// resource. All the schedules defined here will result on the value
|
||||
// to the same metric. New metrics require a new ScalingSchedule
|
||||
// resource.
|
||||
Schedules []Schedule `json:"schedules"`
|
||||
}
|
||||
|
||||
// Schedule is the schedule details to be used inside a ScalingSchedule.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type Schedule struct {
|
||||
Type ScheduleType `json:"type"`
|
||||
// Defines the details of a Repeating schedule.
|
||||
// +optional
|
||||
Period *SchedulePeriod `json:"period,omitempty"`
|
||||
// Defines the starting date of a OneTime schedule. It has to
|
||||
// be a RFC3339 formated date.
|
||||
// +optional
|
||||
Date *ScheduleDate `json:"date,omitempty"`
|
||||
// The duration in minutes that the configured value will be
|
||||
// returned for the defined schedule.
|
||||
DurationMinutes int `json:"durationMinutes"`
|
||||
// The metric value that will be returned for the defined schedule.
|
||||
Value int64 `json:"value"`
|
||||
}
|
||||
|
||||
func (in Schedule) Duration() time.Duration {
|
||||
return time.Duration(in.DurationMinutes) * time.Minute
|
||||
}
|
||||
|
||||
// Defines if the schedule is a OneTime schedule or
|
||||
// Repeating one. If OneTime, date has to be defined. If Repeating,
|
||||
// Period has to be defined.
|
||||
// +kubebuilder:validation:Enum=OneTime;Repeating
|
||||
type ScheduleType string
|
||||
|
||||
const (
|
||||
OneTimeSchedule ScheduleType = "OneTime"
|
||||
RepeatingSchedule ScheduleType = "Repeating"
|
||||
)
|
||||
|
||||
// SchedulePeriod is the details to be used for a Schedule of the
|
||||
// Repeating type.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type SchedulePeriod struct {
|
||||
// The startTime has the format HH:MM
|
||||
// +kubebuilder:validation:Pattern="(([0-1][0-9])|([2][0-3])):([0-5][0-9])"
|
||||
StartTime string `json:"startTime"`
|
||||
// The days that this schedule will be active.
|
||||
Days []ScheduleDay `json:"days"`
|
||||
// The location name corresponding to a file in the IANA
|
||||
// Time Zone database, like Europe/Berlin.
|
||||
Timezone string `json:"timezone"`
|
||||
}
|
||||
|
||||
// ScheduleDay represents the valid inputs for days in a SchedulePeriod.
|
||||
// +kubebuilder:validation:Enum=Sun;Mon;Tue;Wed;Thu;Fri;Sat
|
||||
type ScheduleDay string
|
||||
|
||||
const (
|
||||
SundaySchedule ScheduleDay = "Sun"
|
||||
MondaySchedule ScheduleDay = "Mon"
|
||||
TuesdaySchedule ScheduleDay = "Tue"
|
||||
WednesdaySchedule ScheduleDay = "Wed"
|
||||
ThursdaySchedule ScheduleDay = "Thu"
|
||||
FridaySchedule ScheduleDay = "Fri"
|
||||
SaturdaySchedule ScheduleDay = "Sat"
|
||||
)
|
||||
|
||||
// ScheduleDate is a RFC3339 representation of the date for a Schedule
|
||||
// of the OneTime type.
|
||||
// +kubebuilder:validation:Format="date-time"
|
||||
type ScheduleDate string
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ScalingScheduleList is a list of namespaced scaling schedules.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ScalingScheduleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []ScalingSchedule `json:"items"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// ClusterScalingScheduleList is a list of cluster scoped scaling schedules.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ClusterScalingScheduleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []ClusterScalingSchedule `json:"items"`
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user