You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It includes the necessary boilerplate for setting up an implementation
9
14
(generic API server setup, registration of resources, etc), plus an
10
-
implementation for testing that allows setting metric values over HTTP.
15
+
implementation for testing that allows setting custom metric values over HTTP.
11
16
12
17
## How to use this repository
13
18
@@ -22,60 +27,62 @@ More information can be found in the [getting started
22
27
guide](/docs/getting-started.md), and the testing implementation can be
23
28
found in the [test-adapter directory](/test-adapter).
24
29
25
-
## Development for boilerplate project
26
-
27
-
### Pre-reqs
30
+
### Prerequisites
28
31
29
-
-[Go](https://golang.org/doc/install) same version of [Go as Kubernetes](https://github.com/kubernetes/community/blob/master/contributors/devel/development.md#go)
30
-
-[git](https://git-scm.com/downloads)
32
+
[Go](https://go.dev/doc/install): this library requires the same version of
33
+
[Go as Kubernetes](https://git.k8s.io/community/contributors/devel/development.md#go).
31
34
32
-
### Clone and Build the Testing Adapter
35
+
##Test Adapter
33
36
34
37
There is a test adapter in this repository that can be used for testing
35
38
changes to the repository, as a mock implementation of the APIs for
36
39
automated unit tests, and also as an example implementation.
37
40
38
-
Note that this adapter *should not* be used for production. It's for
41
+
Note that this adapter **should not** be used for production. It's for
39
42
writing automated e2e tests and serving as a sample only.
40
43
41
44
To build and deploy it:
42
45
43
46
```bash
44
-
# build the test-adapter container as $REGISTRY/k8s-test-metrics-adapter
47
+
# build the test-adapter container as $REGISTRY/k8s-test-metrics-adapter-amd64
45
48
export REGISTRY=<some-prefix>
46
49
make test-adapter-container
47
50
48
51
# push the container up to a registry (optional if your cluster is local)
# you can pipe to `jq .` to pretty-print the output, if it's installed
70
76
# (otherwise, it's not necessary)
71
-
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"| jq .
77
+
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta2"| jq .
72
78
# fetching certain custom metrics of namespaced resources
73
-
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/services/kubernetes/test-metric"| jq .
79
+
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta2/namespaces/default/services/kubernetes/test-metric"| jq .
74
80
```
75
81
76
82
If you wanted to target a simple nginx-deployment and then use this as an HPA scaler metric, something like this would work following the previous curl command:
77
-
```
78
-
apiVersion: autoscaling/v2beta2
83
+
84
+
```yaml
85
+
apiVersion: autoscaling/v2
79
86
kind: HorizontalPodAutoscaler
80
87
metadata:
81
88
name: nginx-deployment
@@ -101,22 +108,28 @@ spec:
101
108
value: 300m
102
109
```
103
110
111
+
You can also query the external metrics:
112
+
113
+
```bash
114
+
kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1" | jq .
115
+
# fetching certain custom metrics of namespaced resources
116
+
kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1/namespaces/default/my-external-metric" | jq .
117
+
```
118
+
104
119
## Compatibility
105
120
106
121
The APIs in this repository follow the standard guarantees for Kubernetes
107
122
APIs, and will follow Kubernetes releases.
108
123
109
124
## Community, discussion, contribution, and support
110
125
111
-
Learn how to engage with the Kubernetes community on the[community
112
-
page](http://kubernetes.io/community/).
126
+
Learn how to engage with the Kubernetes community on the
0 commit comments