This adapter contains an implementation of external metrics API. It is therefore suitable for use with the autoscaling/v2 Horizontal Pod Autoscaler in Kubernetes 1.6+.
git clone git@github.com:apache/skywalking-swck.git
Edit file config/adapter/adapter/kustomization.yaml
file to change your preferences. If you prefer to your private docker image, a quick path to override ADAPTER_IMG
environment variable : export ADAPTER_IMG=<private registry>/adapter:<tag>
Use make
to generate the final manifests and deploy:
make adapter-deploy
The adapter takes the standard Kubernetes generic API server arguments (including those for authentication and authorization). By default, it will attempt to using Kubernetes in-cluster config to connect to the cluster.
It takes the following addition arguments specific to configuring how the adapter talks to SkyWalking OAP cluster:
--oap-addr
The address of OAP cluster.--metric-filter-regex
A regular expression to filter metrics retrieved from OAP cluster.--refresh-interval
This is the interval at which to update the cache of available metrics from OAP cluster.External metrics allow you to autoscale your cluster based on any metric available in OAP cluster. Just provide a metric block with a name
and selector
, and use the External
metric type.
- type: External external: metric: name: <metric_name> metricSelector: matchLabels: <label_key>: <label_value> ... target: ....
label_key
is from the arguments of swctl .The options of label keys are:
service
The name of the service.instance
The name of the service instance.endpoint
The name of the endpoint.label
is optional, The labels you need to query, used for querying multi-labels metrics. Unlike swctl, this key only supports a single label due to the specification of the custom metrics API.For example, if your application name is front_gateway
, you could add the following section to your HorizontalPodAutoscaler manifest to specify that you need less than 80ms of 90th latency.
- type: External external: metric: name: service_percentile metricSelector: matchLabels: service: front_gateway # The index of [P50, P75, P90, P95, P99]. 2 is the index of P90(90%) label: "2" target: type: value value: 80