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

Scaling based on custom metrics #209

Merged
merged 3 commits into from
May 12, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s

## [Unreleased]

### Added

- Add scaling based on custom metrics ([#209](https://github.com/giantswarm/coredns-app/pull/209)).

## [1.16.0] - 2023-05-04

### Changed
Expand Down
37 changes: 21 additions & 16 deletions helm/coredns-app/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.hpa.enabled }}
apiVersion: {{ ternary "autoscaling/v2" "autoscaling/v2beta2" (.Capabilities.APIVersions.Has "autoscaling/v2") }}
kind: HorizontalPodAutoscaler
metadata:
Expand All @@ -12,23 +13,27 @@ spec:
kind: Deployment
name: coredns-workers
metrics:
{{- with .Values.hpa.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.hpa.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.hpa.metrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.hpa.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.hpa.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.hpa.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions helm/coredns-app/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@
}
}
},
"enabled": {
"type": "boolean"
},
"maxReplicas": {
"type": "integer"
},
"metrics": {
"type": "array"
},
"minReplicas": {
"type": "integer"
},
Expand Down
2 changes: 2 additions & 0 deletions helm/coredns-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ userID: 33
groupID: 33

hpa:
enabled: true
minReplicas: 2
maxReplicas: 50
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
metrics: []
# The stabilization window is used to restrict the flapping of replica count
# when the metrics used for scaling keep fluctuating.
# This is very useful for large scale clusters to prevent the CoreDNS from flapping
Expand Down