github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/prometheus-community/prometheus-adapter/README.md (about) 1 # Prometheus Adapter 2 3 Installs the [Prometheus Adapter](https://github.com/kubernetes-sigs/prometheus-adapter) for the Custom Metrics API. Custom metrics are used in Kubernetes by [Horizontal Pod Autoscalers](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) to scale workloads based upon your own metric pulled from an external metrics provider like Prometheus. This chart complements the [metrics-server](https://github.com/helm/charts/tree/master/stable/metrics-server) chart that provides resource only metrics. 4 5 ## Prerequisites 6 7 Kubernetes 1.14+ 8 9 ## Get Helm Repositories Info 10 11 ```console 12 helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 13 helm repo update 14 ``` 15 16 _See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._ 17 18 ## Install Helm Chart 19 20 ```console 21 helm install [RELEASE_NAME] prometheus-community/prometheus-adapter 22 ``` 23 24 _See [configuration](#configuration) below._ 25 26 _See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ 27 28 ## Uninstall Helm Chart 29 30 ```console 31 helm uninstall [RELEASE_NAME] 32 ``` 33 34 This removes all the Kubernetes components associated with the chart and deletes the release. 35 36 _See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ 37 38 ## Upgrading Helm Chart 39 40 ```console 41 helm upgrade [RELEASE_NAME] [CHART] --install 42 ``` 43 44 _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ 45 46 ### To 3.0.0 47 48 Due to a change in deployment labels, the upgrade requires `helm upgrade --force` in order to re-create the deployment. 49 50 ## Configuration 51 52 See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands: 53 54 ```console 55 helm show values prometheus-community/prometheus-adapter 56 ``` 57 58 ### Prometheus Service Endpoint 59 60 To use the chart, ensure the `prometheus.url` and `prometheus.port` are configured with the correct Prometheus service endpoint. If Prometheus is exposed under HTTPS the host's CA Bundle must be exposed to the container using `extraVolumes` and `extraVolumeMounts`. 61 62 ### Adapter Rules 63 64 Additionally, the chart comes with a set of default rules out of the box but they may pull in too many metrics or not map them correctly for your needs. Therefore, it is recommended to populate `rules.custom` with a list of rules (see the [config document](https://github.com/kubernetes-sigs/prometheus-adapter/blob/master/docs/config.md) for the proper format). 65 66 ### Horizontal Pod Autoscaler Metrics 67 68 Finally, to configure your Horizontal Pod Autoscaler to use the custom metric, see the custom metrics section of the [HPA walkthrough](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics). 69 70 The Prometheus Adapter can serve three different [metrics APIs](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis): 71 72 ### Custom Metrics 73 74 Enabling this option will cause custom metrics to be served at `/apis/custom.metrics.k8s.io/v1beta1`. Enabled by default when `rules.default` is true, but can be customized by populating `rules.custom`: 75 76 ```yaml 77 rules: 78 custom: 79 - seriesQuery: '{__name__=~"^some_metric_count$"}' 80 resources: 81 template: <<.Resource>> 82 name: 83 matches: "" 84 as: "my_custom_metric" 85 metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>) 86 ``` 87 88 ### External Metrics 89 90 Enabling this option will cause external metrics to be served at `/apis/external.metrics.k8s.io/v1beta1`. Can be enabled by populating `rules.external`: 91 92 ```yaml 93 rules: 94 external: 95 - seriesQuery: '{__name__=~"^some_metric_count$"}' 96 resources: 97 template: <<.Resource>> 98 name: 99 matches: "" 100 as: "my_external_metric" 101 metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>) 102 ``` 103 104 ### Resource Metrics 105 106 Enabling this option will cause resource metrics to be served at `/apis/metrics.k8s.io/v1beta1`. Resource metrics will allow pod CPU and Memory metrics to be used in [Horizontal Pod Autoscalers](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) as well as the `kubectl top` command. Can be enabled by populating `rules.resource`: 107 108 ```yaml 109 rules: 110 resource: 111 cpu: 112 containerQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>, container!=""}[3m])) by (<<.GroupBy>>) 113 nodeQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>, id='/'}[3m])) by (<<.GroupBy>>) 114 resources: 115 overrides: 116 node: 117 resource: node 118 namespace: 119 resource: namespace 120 pod: 121 resource: pod 122 containerLabel: container 123 memory: 124 containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>, container!=""}) by (<<.GroupBy>>) 125 nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>) 126 resources: 127 overrides: 128 node: 129 resource: node 130 namespace: 131 resource: namespace 132 pod: 133 resource: pod 134 containerLabel: container 135 window: 3m 136 ``` 137 138 **NOTE:** Setting a value for `rules.resource` will also deploy the resource metrics API service, providing the same functionality as [metrics-server](https://github.com/helm/charts/tree/master/stable/metrics-server). As such it is not possible to deploy them both in the same cluster.