Compare commits

..

2 Commits

Author SHA1 Message Date
Sandor Szücs
37547ce460 add missing VERSION file
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
2021-01-21 17:01:40 +01:00
Sandor Szücs
7a0c251972 automate release of all merge to master similar to stackset-controller
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
2021-01-21 17:00:23 +01:00
98 changed files with 1465 additions and 10350 deletions

View File

@ -1,25 +0,0 @@
name: ci
on:
push:
branches-ignore:
- 'gh-pages'
pull_request:
branches-ignore:
- 'gh-pages'
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.19'
- run: go version
- run: go install github.com/mattn/goveralls@latest
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- run: make build.docker
- run: make test
- run: make check
- run: goveralls -coverprofile=profile.cov -service=github
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

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

View File

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

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
build/
apiserver.local.config/
.idea/
profile.cov
vendor/

View File

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

20
.travis.yml Normal file
View File

@ -0,0 +1,20 @@
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

View File

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

View File

@ -1,11 +1,7 @@
ARG BASE_IMAGE=registry.opensource.zalan.do/library/alpine-3.13:latest
FROM ${BASE_IMAGE}
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
ARG TARGETARCH
ADD build/linux/${TARGETARCH}/kube-metrics-adapter /
# add binary
ADD build/linux/kube-metrics-adapter /
ENTRYPOINT ["/kube-metrics-adapter"]

View File

@ -10,10 +10,6 @@ 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
@ -22,22 +18,14 @@ clean:
rm -rf build
rm -rf $(OPENAPI)
test: $(GENERATED)
go test -v -coverprofile=profile.cov $(GOPKGS)
test:
go test -v $(GOPKGS)
check: $(GENERATED)
check:
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 \
@ -48,26 +36,21 @@ $(OPENAPI): go.mod
-O zz_generated.openapi \
-r /dev/null
build.local: build/$(BINARY) $(GENERATED_CRDS)
build.local: build/$(BINARY)
build.linux: build/linux/$(BINARY)
build.linux.amd64: build/linux/amd64/$(BINARY)
build.linux.arm64: build/linux/arm64/$(BINARY)
build.osx: build/osx/$(BINARY)
build/$(BINARY): go.mod $(SOURCES) $(GENERATED)
build/$(BINARY): go.mod $(SOURCES) $(OPENAPI)
CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
build/linux/$(BINARY): go.mod $(SOURCES) $(GENERATED)
build/linux/$(BINARY): go.mod $(SOURCES) $(OPENAPI)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" .
build/linux/amd64/$(BINARY): go.mod $(SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/amd64/$(BINARY) -ldflags "$(LDFLAGS)" .
build/linux/arm64/$(BINARY): go.mod $(SOURCES)
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/arm64/$(BINARY) -ldflags "$(LDFLAGS)" .
build/osx/$(BINARY): go.mod $(SOURCES) $(OPENAPI)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" .
build.docker: build.linux
docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) --build-arg TARGETARCH= .
docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) .
build.push: build.docker
docker push "$(IMAGE):$(TAG)"

355
README.md

File diff suppressed because it is too large Load Diff

1
VERSION Normal file
View File

@ -0,0 +1 @@
v0.1

View File

@ -1,9 +1,7 @@
version: "2017-09-20"
pipeline:
- id: build
vm_config:
type: linux
image: "cdp-runtime/go"
overlay: ci/golang
cache:
paths:
- /go/pkg/mod # pkg cache for Go modules
@ -22,7 +20,15 @@ pipeline:
cmd: |
if [[ $CDP_TARGET_BRANCH == master && ! $CDP_PULL_REQUEST_NUMBER ]]; then
IMAGE=registry-write.opensource.zalan.do/teapot/kube-metrics-adapter
VERSION=$(git describe --tags --always)
LATEST_VERSION=$(git describe --tags --always | awk -F \- '{print $1}')
CUR_PART=$(echo $LATEST_VERSION | awk -F . '{print $1"."$2}')
VERSION_PART=$(cat VERSION)
OLD_PATCH=$(echo $LATEST_VERSION | awk -F . '{print $3}')
NEW_PATCH=$((OLD_PATCH + 1))
if [ "$CUR_PART" != "$VERSION_PART" ]; then NEW_PATCH=0; fi
VERSION=${VERSION_PART}.${NEW_PATCH}
echo "Creating release for tag: ${VERSION}"
else
IMAGE=registry-write.opensource.zalan.do/teapot/kube-metrics-adapter-test
VERSION=$CDP_BUILD_VERSION
@ -30,17 +36,18 @@ pipeline:
IMAGE=$IMAGE VERSION=$VERSION make build.docker
git diff --stat --exit-code
IMAGE=$IMAGE VERSION=$VERSION make build.push
- desc: Build and push image to Zalando's registry
cmd: |
if [[ $CDP_TARGET_BRANCH == master && ! $CDP_PULL_REQUEST_NUMBER ]]; then
IMAGE=container-registry-test.zalando.net/teapot/kube-metrics-adapter
VERSION=$(git describe --tags --always)
else
IMAGE=container-registry-test.zalando.net/teapot/kube-metrics-adapter-test
VERSION=$CDP_BUILD_VERSION
echo "create release page"
tf=$(mktemp)
echo -e "### Changes\n" >$tf
git log -1 --pretty=%B | grep -v 'Signed-off-by:' | grep -v -E '^\s*$' | grep -vE '^\*' >>$tf
echo -e "\n### Docker image\n" >>$tf
echo -e "Docker image is available in Zalando's Open Source registry:\n" >>$tf
echo -e '```' >>$tf
echo -e "docker run -it registry.opensource.zalan.do/teapot/kube-metrics-adapter:${VERSION} --help" >>$tf
echo -e '```' >>$tf
echo "################################"
cat $tf
echo "################################"
git gh-release --message-from-file "${tf}" $VERSION
fi
make build.linux.amd64 build.linux.arm64
docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use
docker buildx build --rm --build-arg BASE_IMAGE=container-registry.zalando.net/library/alpine-3:latest -t "${IMAGE}:${VERSION}" --platform linux/amd64,linux/arm64 --push .
cdp-promote-image "${IMAGE}:${VERSION}"

View File

@ -1,148 +0,0 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: clusterscalingschedules.zalando.org
spec:
group: zalando.org
names:
kind: ClusterScalingSchedule
listKind: ClusterScalingScheduleList
plural: clusterscalingschedules
singular: clusterscalingschedule
scope: Cluster
versions:
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ClusterScalingSchedule describes a cluster scoped time based
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 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.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
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
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
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:
- type
- value
type: object
type: array
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

@ -1,4 +1,4 @@
apiVersion: apiregistration.k8s.io/v1
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1beta1.custom.metrics.k8s.io

View File

@ -28,7 +28,6 @@ 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

View File

@ -1,4 +1,4 @@
apiVersion: apiregistration.k8s.io/v1
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1beta1.external.metrics.k8s.io

View File

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

View File

@ -1,149 +0,0 @@
{{- if .Values.scalingSchedule.enabled }}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: clusterscalingschedules.zalando.org
spec:
group: zalando.org
names:
kind: ClusterScalingSchedule
listKind: ClusterScalingScheduleList
plural: clusterscalingschedules
singular: clusterscalingschedule
scope: Cluster
versions:
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ClusterScalingSchedule describes a cluster scoped time based
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 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.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
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
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
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:
- type
- value
type: object
type: array
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
{{- end}}

View File

@ -1,5 +1,5 @@
{{- if .Values.enableCustomMetricsApi }}
apiVersion: apiregistration.k8s.io/v1
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1beta1.custom.metrics.k8s.io
@ -12,4 +12,4 @@ spec:
insecureSkipTLSVerify: {{ .Values.tls.skipTLSVerify }}
groupPriorityMinimum: 100
versionPriority: 100
{{- end}}
{{- end}}

View File

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

View File

@ -1,5 +1,5 @@
{{- if .Values.enableExternalMetricsApi }}
apiVersion: apiregistration.k8s.io/v1
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1beta1.external.metrics.k8s.io

View File

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

View File

@ -1,151 +0,0 @@
{{- if .Values.scalingSchedule.enabled }}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: scalingschedules.zalando.org
spec:
group: zalando.org
names:
categories:
- all
kind: ScalingSchedule
listKind: ScalingScheduleList
plural: scalingschedules
singular: scalingschedule
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ScalingSchedule describes a namespaced time based metric to be
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 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.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
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
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
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:
- type
- value
type: object
type: array
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
{{- end}}

View File

@ -4,7 +4,7 @@ replicas: 1
registry:
image: registry.opensource.zalan.do/teapot/kube-metrics-adapter
imageTag: v0.2.0
imageTag: v0.1.9
imagePullPolicy: IfNotPresent
service:
@ -22,7 +22,6 @@ http2MaxStreamsPerConnection:
listerKubeConfig:
skipperBackendsAnnotation:
skipperIngressMetrics:
skipperRouteGroupMetrics:
token:
vmodule:
@ -93,17 +92,3 @@ resources:
requests:
cpu: 100m
memory: 100Mi
scalingSchedule:
enabled: false
nodeSelector:
kubernetes.io/os: linux
tolerations: []
affinity: {}
priorityClassName: ""
podAnnotations: {}

View File

@ -64,22 +64,12 @@ rules:
- statefulsets
verbs:
- get
# only relevant if running with the flag:
# --skipper-ingress-metrics
- apiGroups:
- networking.k8s.io
- extensions
resources:
- ingresses
verbs:
- get
# only relevant if running with the flag:
# --skipper-routegroup-metrics
- apiGroups:
- zalando.org
resources:
- routegroups
verbs:
- get
- apiGroups:
- autoscaling
resources:
@ -88,22 +78,6 @@ rules:
- get
- list
- watch
- apiGroups:
- zalando.org
resources:
- clusterscalingschedules
- scalingschedules
verbs:
- get
- list
- watch
- apiGroups:
- zalando.org
resources:
- clusterscalingschedules/status
- scalingschedules/status
verbs:
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding

View File

@ -1,150 +0,0 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: scalingschedules.zalando.org
spec:
group: zalando.org
names:
categories:
- all
kind: ScalingSchedule
listKind: ScalingScheduleList
plural: scalingschedules
singular: scalingschedule
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Whether one or more schedules are currently active.
jsonPath: .status.active
name: Active
type: boolean
name: v1
schema:
openAPIV3Schema:
description: ScalingSchedule describes a namespaced time based metric to be
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 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.
type: integer
endDate:
description: Defines the ending date of a OneTime schedule.
It must be a RFC3339 formatted date.
format: date-time
type: string
period:
description: Defines the details of a Repeating schedule.
properties:
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
endTime:
description: The endTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
type: string
startTime:
description: The startTime has the format HH:MM
pattern: (([0-1][0-9])|([2][0-3])):([0-5][0-9])
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:
- type
- value
type: object
type: array
required:
- schedules
type: object
status:
description: ScalingScheduleStatus is the status section of the ScalingSchedule.
properties:
active:
default: false
description: Active is true if at least one of the schedules defined
in the scaling schedule is currently active.
type: boolean
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

View File

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

View File

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

View File

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

View File

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

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