-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create new hpa template using ContainerResource
If Kube version is >=1.3.0, we switch the HPA template to use ContainerResource types instead of Resource. We also add the 'autoscaling.extraMetrics' which shall enable adding scaling for sidecar containers.
- Loading branch information
1 parent
f4ada24
commit ccbcf56
Showing
13 changed files
with
210 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{- $kubeVersion := .Capabilities.KubeVersion.GitVersion -}} | ||
{{- $containerResourceAvailable := and (not (empty $kubeVersion)) (semverCompare ">=1.3.0" $kubeVersion) -}} | ||
{{- if and .Values.deployment.autoscaling.enabled $containerResourceAvailable }} | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
{{- if .Release.Namespace }} | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} | ||
name: {{ include "hydra.fullname" . }} | ||
labels: | ||
{{- include "hydra.labels" . | nindent 4 }} | ||
spec: | ||
{{- with .Values.deployment.autoscaling.behavior }} | ||
behavior: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ include "hydra.fullname" . }} | ||
minReplicas: {{ .Values.deployment.autoscaling.minReplicas }} | ||
maxReplicas: {{ .Values.deployment.autoscaling.maxReplicas }} | ||
metrics: | ||
{{- with .Values.deployment.autoscaling.targetMemory }} | ||
- type: ContainerResource | ||
containerResource: | ||
name: memory | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.deployment.autoscaling.targetCPU}} | ||
- type: ContainerResource | ||
containerResource: | ||
name: cpu | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if not (empty .Values.deployment.autoscaling.extraMetrics) }} | ||
{{- toYaml .Values.deployment.autoscaling.extraMetrics | nindent 2 }} | ||
{{- end }} | ||
{{- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{- $kubeVersion := .Capabilities.KubeVersion.GitVersion -}} | ||
{{- $containerResourceAvailable := and (not (empty $kubeVersion)) (semverCompare ">=1.3.0" $kubeVersion) -}} | ||
{{- $autoscaling := ternary .Values.deployment.autoscaling .Values.autoscaling (not (empty .Values.deployment.autoscaling )) -}} | ||
|
||
{{- if and $autoscaling.enabled $containerResourceAvailable }} | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ include "keto.fullname" . }} | ||
{{- if .Release.Namespace }} | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} | ||
labels: | ||
{{- include "keto.labels" . | nindent 4 }} | ||
spec: | ||
{{- with $autoscaling.behavior }} | ||
behavior: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ include "keto.fullname" . }} | ||
minReplicas: {{ $autoscaling.minReplicas }} | ||
maxReplicas: {{ $autoscaling.maxReplicas }} | ||
metrics: | ||
{{- with $autoscaling.targetMemory }} | ||
- type: ContainerResource | ||
containerResource: | ||
name: memory | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with $autoscaling.targetCPU}} | ||
- type: ContainerResource | ||
containerResource: | ||
name: cpu | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if not (empty $autoscaling.extraMetrics) }} | ||
{{- toYaml $autoscaling.extraMetrics | nindent 2 }} | ||
{{- end }} | ||
{{- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{{- $kubeVersion := .Capabilities.KubeVersion.GitVersion -}} | ||
{{- $containerResourceAvailable := and (not (empty $kubeVersion)) (semverCompare ">=1.3.0" $kubeVersion) -}} | ||
{{- if and .Values.autoscaling.enabled $containerResourceAvailable }} | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ include "kratos.fullname" . }} | ||
labels: | ||
{{- include "kratos.labels" . | nindent 4 }} | ||
spec: | ||
{{- with .Values.autoscaling.behavior }} | ||
behavior: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ include "kratos.fullname" . }} | ||
minReplicas: {{ .Values.autoscaling.minReplicas }} | ||
maxReplicas: {{ .Values.autoscaling.maxReplicas }} | ||
metrics: | ||
{{- with .Values.autoscaling.targetMemory }} | ||
- type: ContainerResource | ||
containerResource: | ||
name: memory | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.autoscaling.targetCPU}} | ||
- type: ContainerResource | ||
containerResource: | ||
name: cpu | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if not (empty $.Values.autoscaling.extraMetrics) }} | ||
{{- toYaml .Values.autoscaling.extraMetrics | nindent 2 }} | ||
{{- end }} | ||
{{- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{- $kubeVersion := .Capabilities.KubeVersion.GitVersion -}} | ||
{{- $containerResourceAvailable := and (not (empty $kubeVersion)) (semverCompare ">=1.3.0" $kubeVersion) -}} | ||
{{- if and .Values.deployment.autoscaling.enabled $containerResourceAvailable }} | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ include "oathkeeper.fullname" . }} | ||
{{- if .Release.Namespace }} | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} | ||
labels: | ||
{{- include "oathkeeper.labels" . | nindent 4 }} | ||
spec: | ||
{{- with .Values.deployment.autoscaling.behavior }} | ||
behavior: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ include "oathkeeper.fullname" . }} | ||
minReplicas: {{ .Values.deployment.autoscaling.minReplicas }} | ||
maxReplicas: {{ .Values.deployment.autoscaling.maxReplicas }} | ||
metrics: | ||
{{- with .Values.deployment.autoscaling.targetMemory }} | ||
- type: ContainerResource | ||
containerResource: | ||
name: memory | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.deployment.autoscaling.targetCPU}} | ||
- type: ContainerResource | ||
containerResource: | ||
name: cpu | ||
container: {{ $.Chart.Name }} | ||
target: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if not (empty $.Values.deployment.autoscaling.extraMetrics) }} | ||
{{- toYaml .Values.deployment.autoscaling.extraMetrics | nindent 2 }} | ||
{{- end }} | ||
{{- 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