Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add k8s 1.26 and onwards support to wavefront adapter #69

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ notes.txt
apiserver.*
docker-push.sh
cmd/wavefront-query
.DS_Store
.zshrc
cmd/.DS_Store
deploy/.DS_Store
go/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ ARG BUILDPLATFORM

WORKDIR /
COPY $BUILDPLATFORM .
ENTRYPOINT ["/wavefront-adapter", "--logtostderr=true"]
ENTRYPOINT ["/wavefront-adapter"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DOCKER_IMAGE?=wavefront-hpa-adapter
# deploy/manifests/05-custom-metrics-apiserver-deployment.yaml file
#
# IMPORTANT: This is also overwritten by the release pipeline build with parameters
VERSION?=0.9.15
VERSION?=0.9.16

BINARY_NAME=wavefront-adapter
GIT_COMMIT:=$(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -74,4 +74,4 @@ update-version:
git add release/VERSION
git add deploy/manifests/05-custom-metrics-apiserver-deployment.yaml
git commit -m "Bump version to $(NEW_VERSION)"
git push --set-upstream origin bump-version-$(NEW_VERSION)
git push --set-upstream origin bump-version-$(NEW_VERSION)
12 changes: 7 additions & 5 deletions deploy/hpa-examples/hpa-cpu-usage.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-hpa-custom-metrics
spec:
minReplicas: 1
maxReplicas: 5
metrics:
- type: Pods
pods:
metricName: cpu.usage_rate
targetAverageValue: 1800m
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
Expand Down
19 changes: 11 additions & 8 deletions deploy/hpa-examples/hpa-external-selector.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-hpa-custom-metrics
spec:
minReplicas: 1
maxReplicas: 5
metrics:
- type: External
external:
metricName: my-external-metric
metricSelector:
matchLabels:
k8s-app: wavefront-proxy
targetAverageValue: 1800m
- type: External
external:
metric:
name: azure.vm.cpu
selector:
matchLabels:
k8s-app: wavefront-proxy
target:
type: AverageValue
averageValue: "30"
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
Expand Down
12 changes: 9 additions & 3 deletions deploy/hpa-examples/hpa-external.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-hpa-custom-metrics
Expand All @@ -8,8 +8,14 @@ spec:
metrics:
- type: External
external:
metricName: azure.vm.cpu
targetAverageValue: 1800m
metric:
name: azure.vm.cpu
selector:
matchLabels:
queue: "azure.vm.cpu"
target:
type: AverageValue
averageValue: "30"
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
Expand Down
20 changes: 12 additions & 8 deletions deploy/hpa-examples/hpa-node.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-hpa-custom-metrics
Expand All @@ -10,10 +10,14 @@ spec:
minReplicas: 1
maxReplicas: 5
metrics:
- type: Object
object:
target:
kind: Node
name: gke-cluster-default-pool-f63db08a-xrdh
metricName: cpu.usage_rate
targetValue: 2000m
- type: Object
object:
metric:
name: cpu.usage_rate
describedObject:
apiVersion: networking.k8s.io/v1
kind: Node
name: gke-cluster-default-pool-f63db08a-xrdh
target:
type: Value
value: 2k
9 changes: 6 additions & 3 deletions deploy/hpa-examples/hpa-pods.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-hpa-custom-metrics
Expand All @@ -8,8 +8,11 @@ spec:
metrics:
- type: Pods
pods:
metricName: cpu.request
targetAverageValue: 1800m
metric:
name: cpu-request
target:
type: AverageValue
averageValue: 1k
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ rules:
verbs:
- get
- list

- apiGroups:
- autoscaling
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ spec:
- --secure-port=6443
- --metrics-relist-interval=15m
- --external-metrics-config=/etc/adapter/config.yaml
- --logtostderr=true
ports:
- containerPort: 6443
volumeMounts:
Expand Down
1 change: 0 additions & 1 deletion deploy/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
rules:

- query: 'ts(azure.compute.vm.percentage.cpu)'
name: azure.vm.cpu
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Metrics can be specified via annotations on HPAs or via a static configuration f
The adapter can dynamically discover HPAs and source external metrics via annotations. The annotations should be of the form `wavefront.com.external.metric/<metric_name>: '<ts query>'`. For example:

```yaml
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-app
Expand Down
64 changes: 34 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ go 1.18

require (
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.22.11
k8s.io/apimachinery v0.22.11
k8s.io/client-go v0.22.11
k8s.io/component-base v0.22.11
k8s.io/metrics v0.22.11
sigs.k8s.io/custom-metrics-apiserver v1.22.0
k8s.io/api v0.23.3
k8s.io/apimachinery v0.23.3
k8s.io/client-go v0.23.3
k8s.io/component-base v0.23.3
k8s.io/metrics v0.23.3
sigs.k8s.io/custom-metrics-apiserver v1.23.0
)

require (
Expand All @@ -26,15 +26,18 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.16.0+incompatible // indirect
github.com/emicklei/go-restful-swagger12 v0.0.0-20201014110547-68ccff494617 // indirect
github.com/evanphx/json-patch v4.11.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand All @@ -44,19 +47,19 @@ require (
github.com/imdario/mergo v0.3.5 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.11.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/common v0.28.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/spf13/cobra v1.1.3 // indirect
github.com/spf13/cobra v1.2.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.0 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.0 // indirect
Expand All @@ -74,13 +77,13 @@ require (
go.opentelemetry.io/proto/otlp v0.7.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.17.0 // indirect
go.uber.org/zap v1.19.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand All @@ -89,14 +92,15 @@ require (
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
k8s.io/apiserver v0.22.0 // indirect
k8s.io/klog/v2 v2.9.0 // indirect
k8s.io/kube-openapi v0.0.0-20211110012726-3cc51fd1e909 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.23.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c
replace k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf
Loading
Loading