mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2025-05-12 08:21:54 +00:00
Compare commits
7 Commits
v0.1.18
...
ingress-up
Author | SHA1 | Date | |
---|---|---|---|
203aaeafb9 | |||
5926f1aea1 | |||
be1e1c635d | |||
094a9f9b9d | |||
47d34b328c | |||
4b5b96084b | |||
18f4c82f07 |
12
.github/workflows/ci.yaml
vendored
12
.github/workflows/ci.yaml
vendored
@ -1,7 +1,5 @@
|
||||
name: ci
|
||||
on: [push, pull_request]
|
||||
env:
|
||||
GO111MODULE: on
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
@ -9,14 +7,12 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.16'
|
||||
go-version: '^1.18'
|
||||
- run: go version
|
||||
- run: go get github.com/mattn/goveralls
|
||||
- run: go install github.com/mattn/goveralls@latest
|
||||
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_RELEASE}
|
||||
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
|
||||
GOLANGCI_RELEASE: v1.46.2
|
||||
- run: make build.docker
|
||||
- run: make test
|
||||
- run: make check
|
||||
|
72
.github/workflows/codeql-analysis.yml
vendored
Normal file
72
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "master" ]
|
||||
schedule:
|
||||
- cron: '29 17 * * 1'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'go' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||
|
||||
# - run: |
|
||||
# echo "Run, Build Application using script"
|
||||
# ./location_of_script_within_repo/buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
@ -320,7 +320,7 @@ box so users don't have to define those manually.
|
||||
|
||||
| Metric | Description | Type | Kind | K8s Versions |
|
||||
| ----------- | -------------- | ------ | ---- | ---- |
|
||||
| `requests-per-second` | Scale based on requests per second for a certain ingress or routegroup. | Object | `Ingress`, `RouteGroup` | `>=1.14` |
|
||||
| `requests-per-second` | Scale based on requests per second for a certain ingress or routegroup. | Object | `Ingress`, `RouteGroup` | `>=1.19` |
|
||||
|
||||
### Example
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: kube-metrics-adapter
|
||||
version: 0.1.11
|
||||
version: 0.1.18
|
||||
description: kube-metrics-adapter helm chart
|
||||
home: https://github.com/zalando-incubator/kube-metrics-adapter
|
||||
maintainers:
|
||||
|
@ -16,8 +16,23 @@ spec:
|
||||
labels:
|
||||
application: kube-metrics-adapter
|
||||
version: {{ .Values.registry.imageTag }}
|
||||
{{- if .Values.podAnnotations }}
|
||||
annotations: {{- toYaml .Values.podAnnotations | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceAccountName: kube-metrics-adapter
|
||||
{{- if .Values.nodeSelector }}
|
||||
nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.tolerations }}
|
||||
tolerations: {{ toYaml .Values.tolerations | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.affinity }}
|
||||
affinity: {{ toYaml .Values.affinity | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName | quote }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: kube-metrics-adapter
|
||||
image: {{ .Values.registry.image}}:{{ .Values.registry.imageTag }}
|
||||
|
@ -60,7 +60,7 @@ rules:
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- extensions
|
||||
- networking.k8s.io
|
||||
resources:
|
||||
- ingresses
|
||||
verbs:
|
||||
|
@ -95,3 +95,14 @@ resources:
|
||||
|
||||
scalingSchedule:
|
||||
enabled: false
|
||||
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
priorityClassName: ""
|
||||
|
||||
podAnnotations: {}
|
||||
|
@ -67,7 +67,6 @@ rules:
|
||||
# only relevant if running with the flag:
|
||||
# --skipper-ingress-metrics
|
||||
- apiGroups:
|
||||
- extensions
|
||||
- networking.k8s.io
|
||||
resources:
|
||||
- ingresses
|
||||
|
@ -39,7 +39,7 @@ spec:
|
||||
- type: Object
|
||||
object:
|
||||
describedObject:
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
name: custom-metrics-consumer
|
||||
metric:
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: custom-metrics-consumer
|
||||
|
16
go.mod
16
go.mod
@ -1,18 +1,18 @@
|
||||
module github.com/zalando-incubator/kube-metrics-adapter
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.42.52
|
||||
github.com/aws/aws-sdk-go v1.44.25
|
||||
github.com/influxdata/influxdb-client-go v0.2.0
|
||||
github.com/kubernetes-sigs/custom-metrics-apiserver v0.0.0-20201216091021-1b9fa998bbaa
|
||||
github.com/prometheus/client_golang v1.12.1
|
||||
github.com/prometheus/common v0.32.1
|
||||
github.com/prometheus/client_golang v1.12.2
|
||||
github.com/prometheus/common v0.34.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/spf13/cobra v1.3.0
|
||||
github.com/spf13/cobra v1.4.0
|
||||
github.com/spyzhov/ajson v0.7.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/stretchr/testify v1.7.1
|
||||
github.com/szuecs/routegroup-client v0.21.0
|
||||
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20220201095549-bbdeecaa4fc1
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
|
||||
k8s.io/api v0.23.0
|
||||
k8s.io/apimachinery v0.23.0
|
||||
k8s.io/apiserver v0.23.0
|
||||
@ -93,7 +93,7 @@ require (
|
||||
go.uber.org/zap v1.19.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 // indirect
|
||||
golang.org/x/mod v0.5.1 // indirect
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
@ -120,4 +120,4 @@ require (
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
|
@ -162,7 +162,7 @@ func (c *SkipperCollector) getCollector(ctx context.Context) (Collector, error)
|
||||
var backendWeight float64
|
||||
switch c.objectReference.Kind {
|
||||
case "Ingress":
|
||||
ingress, err := c.client.NetworkingV1beta1().Ingresses(c.objectReference.Namespace).Get(ctx, c.objectReference.Name, metav1.GetOptions{})
|
||||
ingress, err := c.client.NetworkingV1().Ingresses(c.objectReference.Namespace).Get(ctx, c.objectReference.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1beta1 "k8s.io/api/networking/v1beta1"
|
||||
netv1 "k8s.io/api/networking/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
@ -547,29 +547,31 @@ func makeIngress(client kubernetes.Interface, namespace, resourceName, backend s
|
||||
}
|
||||
annotations[anno] = string(sWeights)
|
||||
}
|
||||
ingress := &v1beta1.Ingress{
|
||||
ingress := &netv1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: resourceName,
|
||||
Annotations: annotations,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Backend: &v1beta1.IngressBackend{
|
||||
ServiceName: backend,
|
||||
Spec: netv1.IngressSpec{
|
||||
DefaultBackend: &netv1.IngressBackend{
|
||||
Service: &netv1.IngressServiceBackend{
|
||||
Name: backend,
|
||||
},
|
||||
},
|
||||
TLS: nil,
|
||||
},
|
||||
Status: v1beta1.IngressStatus{
|
||||
Status: netv1.IngressStatus{
|
||||
LoadBalancer: corev1.LoadBalancerStatus{
|
||||
Ingress: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, hostname := range hostnames {
|
||||
ingress.Spec.Rules = append(ingress.Spec.Rules, v1beta1.IngressRule{
|
||||
ingress.Spec.Rules = append(ingress.Spec.Rules, netv1.IngressRule{
|
||||
Host: hostname,
|
||||
})
|
||||
}
|
||||
_, err := client.NetworkingV1beta1().Ingresses(namespace).Create(context.TODO(), ingress, metav1.CreateOptions{})
|
||||
_, err := client.NetworkingV1().Ingresses(namespace).Create(context.TODO(), ingress, metav1.CreateOptions{})
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,7 @@ func (s *MetricStore) insertCustomMetric(value custom_metrics.MetricValue) {
|
||||
Resource: "pods",
|
||||
}
|
||||
case "Ingress":
|
||||
// group can be either `extensions` or `networking.k8s.io`
|
||||
group := "extensions"
|
||||
group := "networking.k8s.io"
|
||||
gv, err := schema.ParseGroupVersion(value.DescribedObject.APIVersion)
|
||||
if err == nil {
|
||||
group = gv.Group
|
||||
|
@ -320,7 +320,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
DescribedObject: custom_metrics.ObjectReference{
|
||||
Name: "metricObject",
|
||||
Kind: "Ingress",
|
||||
APIVersion: "extensions/v1beta1",
|
||||
APIVersion: "networking.k8s.io/v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -328,7 +328,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
list: []provider.CustomMetricInfo{
|
||||
{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -342,7 +342,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -358,7 +358,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
selector: labels.SelectorFromSet(labels.Set{"select_key": "select_value"}),
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -376,7 +376,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
DescribedObject: custom_metrics.ObjectReference{
|
||||
Name: "metricObject",
|
||||
Kind: "Ingress",
|
||||
APIVersion: "extensions/v1beta1",
|
||||
APIVersion: "networking.k8s.io/v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -384,7 +384,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
list: []provider.CustomMetricInfo{
|
||||
{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -398,7 +398,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -414,7 +414,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
selector: labels.Everything(),
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -433,7 +433,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
Name: "metricObject",
|
||||
Namespace: "right",
|
||||
Kind: "Ingress",
|
||||
APIVersion: "extensions/v1beta1",
|
||||
APIVersion: "networking.k8s.io/v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -441,7 +441,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
list: []provider.CustomMetricInfo{
|
||||
{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: true,
|
||||
@ -455,7 +455,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
name: types.NamespacedName{Name: "metricObject", Namespace: "wrong"},
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: true,
|
||||
@ -471,7 +471,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
selector: labels.Everything(),
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: true,
|
||||
@ -535,7 +535,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
||||
DescribedObject: custom_metrics.ObjectReference{
|
||||
Name: "metricObject",
|
||||
Kind: "Ingress",
|
||||
APIVersion: "extensions/v1beta1",
|
||||
APIVersion: "networking.k8s.io/v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -547,7 +547,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
||||
DescribedObject: custom_metrics.ObjectReference{
|
||||
Name: "metricObject",
|
||||
Kind: "Ingress",
|
||||
APIVersion: "extensions/v1beta1",
|
||||
APIVersion: "networking.k8s.io/v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -555,7 +555,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
||||
list: []provider.CustomMetricInfo{
|
||||
{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -569,7 +569,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
||||
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -585,7 +585,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
||||
selector: labels.Everything(),
|
||||
info: provider.CustomMetricInfo{
|
||||
GroupResource: schema.GroupResource{
|
||||
Group: "extensions",
|
||||
Group: "networking.k8s.io",
|
||||
Resource: "ingresses",
|
||||
},
|
||||
Namespaced: false,
|
||||
@ -831,7 +831,7 @@ func TestCustomMetricsStorageErrors(t *testing.T) {
|
||||
Name: "metricObject",
|
||||
Namespace: "default",
|
||||
Kind: "Ingress",
|
||||
APIVersion: "extensions/vbeta1",
|
||||
APIVersion: "networking.k8s.io/v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user