-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to enable HPA for ama-metrics deployment (#968)
[comment]: # (Note that your PR title should follow the conventional commit format: https://conventionalcommits.org/en/v1.0.0/#summary) # PR Description Changes to enable HPA for ama-metrics deployment. Update ME version to include changes for memory deallocation Updating ME config to tune memory deallocation Telemetry to track HPA enablement [comment]: # (The below checklist is for PRs adding new features. If a box is not checked, add a reason why it's not needed.) # New Feature Checklist - [X] List telemetry added about the feature - Added CollectorHpaEnabled in the custom dimensions - [X] Link to the one-pager about the feature - https://msazure.visualstudio.com/InfrastructureInsights/_wiki/wikis/InfrastructureInsights.wiki/686240/HPA-PRD
- Loading branch information
1 parent
2d57f49
commit 055181f
Showing
17 changed files
with
118 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Managed Prometheus support for CRD (In private preview) | ||
## Managed Prometheus support for CRD | ||
|
||
### Use Prometheus Pod and Service Monitor Custom Resources | ||
The Azure Monitor metrics add-on supports scraping Prometheus metrics using Prometheus - Pod Monitors and Service Monitors, similar to the OSS Prometheus operator. Enabling the add-on will deploy the Pod and Service Monitor custom resource definitions to allow you to create your own custom resources. | ||
|
@@ -7,12 +7,11 @@ Creating these custom resources allows for easy configuration of scrape jobs in | |
This document illustrates the steps need to setup custom resources (pod monitors and service monitors) with Azure Managed Prometheus to setup scrape jobs for the workloads running in your AKS clusters. | ||
|
||
### Pre-requisites | ||
1. You have Azure Managed Prometheus Operator model configured in the AKS cluster. Currently this feature is in private preview – please send us an email to [email protected] to enable the feature for your cluster or subscription. | ||
2. Azure Monitor Workspace is configured and receiving Azure Managed Prometheus metrics. | ||
3. The workload that you want to scrape metrics from is deployed and running on the AKS cluster. | ||
1. Azure Monitor Workspace is configured and receiving Azure Managed Prometheus metrics. | ||
2. The workload that you want to scrape metrics from is deployed and running on the AKS cluster. | ||
|
||
### Enable Azure Managed Prometheus with Operator/CRD support | ||
Once your cluster/subscription is enabled with preview, you can enable Managed Prometheus for the AKS cluster. This will deploy the Azure Monitor metrics add-on and will automatically install the custom resource definition (CRD) for pod and service monitors. The add-on will use the same custom resource definition (CRD) for pod and service monitors as open-source Prometheus, except for a change in the group name and API version. If you have existing Prometheus CRDs and custom resources on your cluster, these will not conflict with the CRDs created by the add-on. | ||
Once your cluster has Managed Prometheus enabled, Azure Monitor metrics add-on and will automatically install the custom resource definition (CRD) for pod and service monitors. The add-on will use the same custom resource definition (CRD) for pod and service monitors as open-source Prometheus, except for a change in the group name and API version. If you have existing Prometheus CRDs and custom resources on your cluster, these will not conflict with the CRDs created by the add-on. | ||
At the same time, the CRDs created for the OSS Prometheus will not be picked up by the managed Prometheus addon. This is intentional for the purposes of isolation of scrape jobs. | ||
|
||
### Create a Pod or Service Monitor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...llector/deploy/addon-chart/azure-monitor-metrics-addon/templates/_ama-metrics-helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{/* HPA merge. */}} | ||
{{/* | ||
1. Set the default HPA values for minReplicas, maxReplicas, and metrics. | ||
2. If the current HPA already exists, override the default HPA values to the current values. | ||
*/}} | ||
{{ define "ama-metrics-merge-custom-hpa" }} | ||
|
||
{{/* Set the default HPA values for minReplicas, maxReplicas, and metrics. */}} | ||
{{- $amaMetricsHpaName := "ama-metrics-hpa" }} | ||
{{- $amaMetricsAutoscaleMin := 2 -}} | ||
{{- $amaMetricsAutoscaleMax := 8 -}} | ||
|
||
amaMetricsMinReplicasFromHelper: 2 | ||
amaMetricsMaxReplicasFromHelper: 8 | ||
|
||
{{/* If the current HPA already exists, set the HPA values to the current | ||
HPA spec to preserve those values. */}} | ||
|
||
{{- $amaMetricsCurrentHPA := lookup "autoscaling/v2" "HorizontalPodAutoscaler" "kube-system" $amaMetricsHpaName }} | ||
{{- if and $amaMetricsCurrentHPA $amaMetricsCurrentHPA.spec }} | ||
{{- $amaMetricsMinReplicasFromCurrentSpec := $amaMetricsCurrentHPA.spec.minReplicas -}} | ||
{{- $amaMetricsMaxReplicasFromCurrentSpec := $amaMetricsCurrentHPA.spec.maxReplicas -}} | ||
|
||
{{- if and ($amaMetricsMinReplicasFromCurrentSpec) (gt (int $amaMetricsMinReplicasFromCurrentSpec) 0) }} | ||
{{- if ge (int $amaMetricsMinReplicasFromCurrentSpec) $amaMetricsAutoscaleMin }} | ||
amaMetricsMinReplicasFromHelper: {{ $amaMetricsMinReplicasFromCurrentSpec }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- if and ($amaMetricsMaxReplicasFromCurrentSpec) (gt (int $amaMetricsMaxReplicasFromCurrentSpec) 0) }} | ||
{{- if le (int $amaMetricsMaxReplicasFromCurrentSpec) $amaMetricsAutoscaleMax }} | ||
amaMetricsMaxReplicasFromHelper: {{ $amaMetricsMaxReplicasFromCurrentSpec }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- end }} | ||
|
||
{{- end }} | ||
|
26 changes: 26 additions & 0 deletions
26
...r/deploy/addon-chart/azure-monitor-metrics-addon/templates/ama-metrics-collector-hpa.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{- if .Values.AzureMonitorMetrics.CollectorHPAEnabled}} | ||
{{- $amaMetricsHpa := include "ama-metrics-merge-custom-hpa" . | fromYaml }} | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: ama-metrics-hpa | ||
namespace: kube-system | ||
labels: | ||
component: ama-metrics-hpa | ||
kubernetes.azure.com/managedby: aks | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: ama-metrics | ||
minReplicas: {{ $amaMetricsHpa.amaMetricsMinReplicasFromHelper }} | ||
maxReplicas: {{ $amaMetricsHpa.amaMetricsMaxReplicasFromHelper }} | ||
metrics: | ||
- type: ContainerResource | ||
containerResource: | ||
name: memory | ||
container: prometheus-collector | ||
target: | ||
averageValue: 10Gi | ||
type: AverageValue | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters